mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	json: handle comments when stripping
Or else everything becomes part of the first comment.
This commit is contained in:
		
							parent
							
								
									0be2959f11
								
							
						
					
					
						commit
						78e2e2c27b
					
				
					 1 changed files with 17 additions and 7 deletions
				
			
		| 
						 | 
					@ -287,19 +287,29 @@ static inline int spa_json_parse_string(const char *val, int len, char *result)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const char *p;
 | 
						const char *p;
 | 
				
			||||||
	if (!spa_json_is_string(val, len)) {
 | 
						if (!spa_json_is_string(val, len)) {
 | 
				
			||||||
		bool skip = false;
 | 
							bool skip = false, comment = false;
 | 
				
			||||||
		for (p = val; p < val + len; p++) {
 | 
							for (p = val; p < val + len; p++) {
 | 
				
			||||||
			switch (*p) {
 | 
								switch (*p) {
 | 
				
			||||||
			case '\n': case '\r': case '\b': case '\t': case '\f':
 | 
								case '#':
 | 
				
			||||||
 | 
									comment = true;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								case '\n': case '\r':
 | 
				
			||||||
 | 
									comment = false;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								case '\b': case '\t': case '\f':
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			case ' ':
 | 
								case ' ':
 | 
				
			||||||
 | 
									if (!comment) {
 | 
				
			||||||
					if (!skip)
 | 
										if (!skip)
 | 
				
			||||||
						*result++ = *p;
 | 
											*result++ = *p;
 | 
				
			||||||
					skip = true;
 | 
										skip = true;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
 | 
									if (!comment) {
 | 
				
			||||||
					*result++ = *p;
 | 
										*result++ = *p;
 | 
				
			||||||
					skip = false;
 | 
										skip = false;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue