mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Count brackets in #{?...} so that nested conditional formats work, from
Daniel De Graaf.
This commit is contained in:
		
							
								
								
									
										34
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								format.c
									
									
									
									
									
								
							@@ -670,7 +670,7 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
 | 
				
			|||||||
	char		*copy, *copy0, *endptr, *ptr, *saved, *trimmed, *value;
 | 
						char		*copy, *copy0, *endptr, *ptr, *saved, *trimmed, *value;
 | 
				
			||||||
	size_t		 valuelen;
 | 
						size_t		 valuelen;
 | 
				
			||||||
	u_long		 limit = 0;
 | 
						u_long		 limit = 0;
 | 
				
			||||||
	int		 modifiers = 0;
 | 
						int		 modifiers = 0, brackets;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Make a copy of the key. */
 | 
						/* Make a copy of the key. */
 | 
				
			||||||
	copy0 = copy = xmalloc(keylen + 1);
 | 
						copy0 = copy = xmalloc(keylen + 1);
 | 
				
			||||||
@@ -718,20 +718,26 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
 | 
				
			|||||||
			goto fail;
 | 
								goto fail;
 | 
				
			||||||
		*ptr = '\0';
 | 
							*ptr = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		value = saved = format_find(ft, copy + 1, modifiers);
 | 
							value = ptr + 1;
 | 
				
			||||||
		if (value != NULL && *value != '\0' &&
 | 
							saved = format_find(ft, copy + 1, modifiers);
 | 
				
			||||||
		    (value[0] != '0' || value[1] != '\0')) {
 | 
					
 | 
				
			||||||
			value = ptr + 1;
 | 
							brackets = 0;
 | 
				
			||||||
			ptr = strchr(value, ',');
 | 
							for (ptr = ptr + 1; *ptr != '\0'; ptr++) {
 | 
				
			||||||
			if (ptr == NULL)
 | 
								if (*ptr == '{')
 | 
				
			||||||
				goto fail;
 | 
									brackets++;
 | 
				
			||||||
			*ptr = '\0';
 | 
								if (*ptr == '}')
 | 
				
			||||||
		} else {
 | 
									brackets--;
 | 
				
			||||||
			ptr = strchr(ptr + 1, ',');
 | 
								if (*ptr == ',' && brackets == 0)
 | 
				
			||||||
			if (ptr == NULL)
 | 
									break;
 | 
				
			||||||
				goto fail;
 | 
					 | 
				
			||||||
			value = ptr + 1;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if (*ptr == '\0')
 | 
				
			||||||
 | 
								goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (saved != NULL && *saved != '\0' &&
 | 
				
			||||||
 | 
							    (saved[0] != '0' || saved[1] != '\0')) {
 | 
				
			||||||
 | 
								*ptr = '\0';
 | 
				
			||||||
 | 
							} else
 | 
				
			||||||
 | 
								value = ptr + 1;
 | 
				
			||||||
		value = format_expand(ft, value);
 | 
							value = format_expand(ft, value);
 | 
				
			||||||
		free(saved);
 | 
							free(saved);
 | 
				
			||||||
		saved = value;
 | 
							saved = value;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								screen.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								screen.c
									
									
									
									
									
								
							@@ -194,8 +194,6 @@ screen_resize_y(struct screen *s, u_int sy)
 | 
				
			|||||||
		 * Now just increase the history size, if possible, to take
 | 
							 * Now just increase the history size, if possible, to take
 | 
				
			||||||
		 * over the lines which are left. If history is off, delete
 | 
							 * over the lines which are left. If history is off, delete
 | 
				
			||||||
		 * lines from the top.
 | 
							 * lines from the top.
 | 
				
			||||||
		 *
 | 
					 | 
				
			||||||
		 * XXX Should apply history limit?
 | 
					 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		available = s->cy;
 | 
							available = s->cy;
 | 
				
			||||||
		if (gd->flags & GRID_HISTORY)
 | 
							if (gd->flags & GRID_HISTORY)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user