mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	If foo doesn't exist and can't be expanded in #{?foo,a,b} then assume it
is false.
This commit is contained in:
		
							
								
								
									
										14
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								format.c
									
									
									
									
									
								
							| @@ -1042,8 +1042,18 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, | |||||||
| 		*ptr = '\0'; | 		*ptr = '\0'; | ||||||
|  |  | ||||||
| 		found = format_find(ft, copy + 1, modifiers); | 		found = format_find(ft, copy + 1, modifiers); | ||||||
| 		if (found == NULL) | 		if (found == NULL) { | ||||||
|  | 			/* | ||||||
|  | 			 * If the conditional not found, try to expand it. If | ||||||
|  | 			 * the expansion doesn't have any effect, then assume | ||||||
|  | 			 * false. | ||||||
|  | 			 */ | ||||||
| 			found = format_expand(ft, copy + 1); | 			found = format_expand(ft, copy + 1); | ||||||
|  | 			if (strcmp(found, copy + 1) == 0) { | ||||||
|  | 				free(found); | ||||||
|  | 				found = xstrdup(""); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
| 		if (format_choose(ptr + 1, &left, &right) != 0) | 		if (format_choose(ptr + 1, &left, &right) != 0) | ||||||
| 			goto fail; | 			goto fail; | ||||||
|  |  | ||||||
| @@ -1098,8 +1108,8 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, | |||||||
| 		value = new; | 		value = new; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/* Expand the buffer and copy in the value. */ |  | ||||||
| done: | done: | ||||||
|  | 	/* Expand the buffer and copy in the value. */ | ||||||
| 	valuelen = strlen(value); | 	valuelen = strlen(value); | ||||||
| 	while (*len - *off < valuelen + 1) { | 	while (*len - *off < valuelen + 1) { | ||||||
| 		*buf = xreallocarray(*buf, 2, *len); | 		*buf = xreallocarray(*buf, 2, *len); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user