mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Merge branch 'obsd-master'
This commit is contained in:
		
							
								
								
									
										22
									
								
								arguments.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								arguments.c
									
									
									
									
									
								
							@@ -98,6 +98,22 @@ args_copy_value(struct args_value *to, struct args_value *from)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Type to string. */
 | 
				
			||||||
 | 
					static const char *
 | 
				
			||||||
 | 
					args_type_to_string (enum args_type type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						switch (type)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						case ARGS_NONE:
 | 
				
			||||||
 | 
							return "NONE";
 | 
				
			||||||
 | 
						case ARGS_STRING:
 | 
				
			||||||
 | 
							return "STRING";
 | 
				
			||||||
 | 
						case ARGS_COMMANDS:
 | 
				
			||||||
 | 
							return "COMMANDS";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return "INVALID";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Get value as string. */
 | 
					/* Get value as string. */
 | 
				
			||||||
static const char *
 | 
					static const char *
 | 
				
			||||||
args_value_as_string(struct args_value *value)
 | 
					args_value_as_string(struct args_value *value)
 | 
				
			||||||
@@ -250,8 +266,8 @@ args_parse(const struct args_parse *parse, struct args_value *values,
 | 
				
			|||||||
			value = &values[i];
 | 
								value = &values[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			s = args_value_as_string(value);
 | 
								s = args_value_as_string(value);
 | 
				
			||||||
			log_debug("%s: %u = %s (type %d)", __func__, i, s,
 | 
								log_debug("%s: %u = %s (type %s)", __func__, i, s,
 | 
				
			||||||
			    value->type);
 | 
								    args_type_to_string (value->type));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (parse->cb != NULL) {
 | 
								if (parse->cb != NULL) {
 | 
				
			||||||
				type = parse->cb(args, args->count, cause);
 | 
									type = parse->cb(args, args->count, cause);
 | 
				
			||||||
@@ -796,6 +812,8 @@ args_make_commands(struct args_command_state *state, int argc, char **argv,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = xstrdup(state->cmd);
 | 
						cmd = xstrdup(state->cmd);
 | 
				
			||||||
 | 
						log_debug("%s: %s", __func__, cmd);
 | 
				
			||||||
 | 
						cmd_log_argv(argc, argv, __func__);
 | 
				
			||||||
	for (i = 0; i < argc; i++) {
 | 
						for (i = 0; i < argc; i++) {
 | 
				
			||||||
		new_cmd = cmd_template_replace(cmd, argv[i], i + 1);
 | 
							new_cmd = cmd_template_replace(cmd, argv[i], i + 1);
 | 
				
			||||||
		log_debug("%s: %%%u %s: %s", __func__, i + 1, argv[i], new_cmd);
 | 
							log_debug("%s: %%%u %s: %s", __func__, i + 1, argv[i], new_cmd);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -179,10 +179,10 @@ cmd_command_prompt_callback(struct client *c, void *data, const char *s,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (s == NULL)
 | 
						if (s == NULL)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (done) {
 | 
						if (done) {
 | 
				
			||||||
		if (cdata->flags & PROMPT_INCREMENTAL)
 | 
							if (cdata->flags & PROMPT_INCREMENTAL)
 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
 | 
					 | 
				
			||||||
		cmd_append_argv(&cdata->argc, &cdata->argv, s);
 | 
							cmd_append_argv(&cdata->argc, &cdata->argv, s);
 | 
				
			||||||
		if (++cdata->current != cdata->count) {
 | 
							if (++cdata->current != cdata->count) {
 | 
				
			||||||
			prompt = &cdata->prompts[cdata->current];
 | 
								prompt = &cdata->prompts[cdata->current];
 | 
				
			||||||
@@ -193,8 +193,11 @@ cmd_command_prompt_callback(struct client *c, void *data, const char *s,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	argc = cdata->argc;
 | 
						argc = cdata->argc;
 | 
				
			||||||
	argv = cmd_copy_argv(cdata->argc, cdata->argv);
 | 
						argv = cmd_copy_argv(cdata->argc, cdata->argv);
 | 
				
			||||||
	cmd_append_argv(&argc, &argv, s);
 | 
						if (!done)
 | 
				
			||||||
 | 
							cmd_append_argv(&argc, &argv, s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (done) {
 | 
						if (done) {
 | 
				
			||||||
 | 
							cmd_free_argv(cdata->argc, cdata->argv);
 | 
				
			||||||
		cdata->argc = argc;
 | 
							cdata->argc = argc;
 | 
				
			||||||
		cdata->argv = cmd_copy_argv(argc, argv);
 | 
							cdata->argv = cmd_copy_argv(argc, argv);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								cmd-parse.y
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								cmd-parse.y
									
									
									
									
									
								
							@@ -1615,13 +1615,24 @@ yylex_token(int ch)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for (;;) {
 | 
						for (;;) {
 | 
				
			||||||
		/* EOF or \n are always the end of the token. */
 | 
							/* EOF or \n are always the end of the token. */
 | 
				
			||||||
		if (ch == EOF || (state == NONE && ch == '\n'))
 | 
							if (ch == EOF) {
 | 
				
			||||||
 | 
								log_debug("%s: end at EOF", __func__);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (state == NONE && ch == '\n') {
 | 
				
			||||||
 | 
								log_debug("%s: end at EOL", __func__);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Whitespace or ; or } ends a token unless inside quotes. */
 | 
							/* Whitespace or ; or } ends a token unless inside quotes. */
 | 
				
			||||||
		if ((ch == ' ' || ch == '\t' || ch == ';' || ch == '}') &&
 | 
							if (state == NONE && (ch == ' ' || ch == '\t')) {
 | 
				
			||||||
		    state == NONE)
 | 
								log_debug("%s: end at WS", __func__);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (state == NONE && (ch == ';' || ch == '}')) {
 | 
				
			||||||
 | 
								log_debug("%s: end at %c", __func__, ch);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * Spaces and comments inside quotes after \n are removed but
 | 
							 * Spaces and comments inside quotes after \n are removed but
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user