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:
		
							
								
								
									
										3
									
								
								cfg.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								cfg.c
									
									
									
									
									
								
							@@ -140,7 +140,8 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int quiet)
 | 
				
			|||||||
		if (condition == -1)
 | 
							if (condition == -1)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (cmd_string_parse(p, &cmdlist, path, line, &cause1) != 0) {
 | 
							cmdlist = cmd_string_parse(p, path, line, &cause1);
 | 
				
			||||||
 | 
							if (cmdlist == NULL) {
 | 
				
			||||||
			free(buf);
 | 
								free(buf);
 | 
				
			||||||
			if (cause1 == NULL)
 | 
								if (cause1 == NULL)
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -175,7 +175,8 @@ cmd_command_prompt_callback(void *data, const char *s, int done)
 | 
				
			|||||||
		return (1);
 | 
							return (1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cmd_string_parse(new_template, &cmdlist, NULL, 0, &cause) != 0) {
 | 
						cmdlist = cmd_string_parse(new_template, NULL, 0, &cause);
 | 
				
			||||||
 | 
						if (cmdlist == NULL) {
 | 
				
			||||||
		if (cause != NULL) {
 | 
							if (cause != NULL) {
 | 
				
			||||||
			new_item = cmdq_get_callback(cmd_command_prompt_error,
 | 
								new_item = cmdq_get_callback(cmd_command_prompt_error,
 | 
				
			||||||
			    cause);
 | 
								    cause);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -112,7 +112,8 @@ cmd_confirm_before_callback(void *data, const char *s, __unused int done)
 | 
				
			|||||||
	if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
 | 
						if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
 | 
				
			||||||
		return (0);
 | 
							return (0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cmd_string_parse(cdata->cmd, &cmdlist, NULL, 0, &cause) != 0) {
 | 
						cmdlist = cmd_string_parse(cdata->cmd, NULL, 0, &cause);
 | 
				
			||||||
 | 
						if (cmdlist == NULL) {
 | 
				
			||||||
		if (cause != NULL) {
 | 
							if (cause != NULL) {
 | 
				
			||||||
			new_item = cmdq_get_callback(cmd_confirm_before_error,
 | 
								new_item = cmdq_get_callback(cmd_confirm_before_error,
 | 
				
			||||||
			    cause);
 | 
								    cause);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,7 +90,8 @@ cmd_display_panes_callback(struct client *c, struct window_pane *wp)
 | 
				
			|||||||
	xasprintf(&expanded, "%%%u", wp->id);
 | 
						xasprintf(&expanded, "%%%u", wp->id);
 | 
				
			||||||
	cmd = cmd_template_replace(template, expanded, 1);
 | 
						cmd = cmd_template_replace(template, expanded, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
 | 
						cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
 | 
				
			||||||
 | 
						if (cmdlist == NULL) {
 | 
				
			||||||
		if (cause != NULL) {
 | 
							if (cause != NULL) {
 | 
				
			||||||
			new_item = cmdq_get_callback(cmd_display_panes_error,
 | 
								new_item = cmdq_get_callback(cmd_display_panes_error,
 | 
				
			||||||
			    cause);
 | 
								    cause);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,7 +96,8 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
		free(shellcmd);
 | 
							free(shellcmd);
 | 
				
			||||||
		if (cmd == NULL)
 | 
							if (cmd == NULL)
 | 
				
			||||||
			return (CMD_RETURN_NORMAL);
 | 
								return (CMD_RETURN_NORMAL);
 | 
				
			||||||
		if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
 | 
							cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
 | 
				
			||||||
 | 
							if (cmdlist == NULL) {
 | 
				
			||||||
			if (cause != NULL) {
 | 
								if (cause != NULL) {
 | 
				
			||||||
				cmdq_error(item, "%s", cause);
 | 
									cmdq_error(item, "%s", cause);
 | 
				
			||||||
				free(cause);
 | 
									free(cause);
 | 
				
			||||||
@@ -167,7 +168,8 @@ cmd_if_shell_callback(struct job *job)
 | 
				
			|||||||
	if (cmd == NULL)
 | 
						if (cmd == NULL)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cmd_string_parse(cmd, &cmdlist, file, line, &cause) != 0) {
 | 
						cmdlist = cmd_string_parse(cmd, file, line, &cause);
 | 
				
			||||||
 | 
						if (cmdlist == NULL) {
 | 
				
			||||||
		if (cause != NULL)
 | 
							if (cause != NULL)
 | 
				
			||||||
			new_item = cmdq_get_callback(cmd_if_shell_error, cause);
 | 
								new_item = cmdq_get_callback(cmd_if_shell_error, cause);
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,7 +115,8 @@ cmd_set_hook_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
		cmdq_error(item, "no command to set hook: %s", name);
 | 
							cmdq_error(item, "no command to set hook: %s", name);
 | 
				
			||||||
		return (CMD_RETURN_ERROR);
 | 
							return (CMD_RETURN_ERROR);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
 | 
						cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
 | 
				
			||||||
 | 
						if (cmdlist == NULL) {
 | 
				
			||||||
		if (cause != NULL) {
 | 
							if (cause != NULL) {
 | 
				
			||||||
			cmdq_error(item, "%s", cause);
 | 
								cmdq_error(item, "%s", cause);
 | 
				
			||||||
			free(cause);
 | 
								free(cause);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										40
									
								
								cmd-string.c
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								cmd-string.c
									
									
									
									
									
								
							@@ -54,32 +54,17 @@ cmd_string_ungetc(size_t *p)
 | 
				
			|||||||
	(*p)--;
 | 
						(*p)--;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					struct cmd_list *
 | 
				
			||||||
 * Parse command string. Returns -1 on error. If returning -1, cause is error
 | 
					cmd_string_parse(const char *s, const char *file, u_int line, char **cause)
 | 
				
			||||||
 * string, or NULL for empty command.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
int
 | 
					 | 
				
			||||||
cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
 | 
					 | 
				
			||||||
    u_int line, char **cause)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	size_t		p;
 | 
						size_t		  p = 0;
 | 
				
			||||||
	int		ch, i, argc, rval;
 | 
						int		  ch, i, argc = 0;
 | 
				
			||||||
	char	      **argv, *buf, *t;
 | 
						char		**argv = NULL, *buf = NULL, *t;
 | 
				
			||||||
	const char     *whitespace, *equals;
 | 
						const char	 *whitespace, *equals;
 | 
				
			||||||
	size_t		len;
 | 
						size_t		  len = 0;
 | 
				
			||||||
 | 
						struct cmd_list	 *cmdlist = NULL;
 | 
				
			||||||
	argv = NULL;
 | 
					 | 
				
			||||||
	argc = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	buf = NULL;
 | 
					 | 
				
			||||||
	len = 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*cause = NULL;
 | 
						*cause = NULL;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	*cmdlist = NULL;
 | 
					 | 
				
			||||||
	rval = -1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	p = 0;
 | 
					 | 
				
			||||||
	for (;;) {
 | 
						for (;;) {
 | 
				
			||||||
		ch = cmd_string_getc(s, &p);
 | 
							ch = cmd_string_getc(s, &p);
 | 
				
			||||||
		switch (ch) {
 | 
							switch (ch) {
 | 
				
			||||||
@@ -133,12 +118,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
 | 
				
			|||||||
			if (argc == 0)
 | 
								if (argc == 0)
 | 
				
			||||||
				goto out;
 | 
									goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			*cmdlist = cmd_list_parse(argc, argv, file, line,
 | 
								cmdlist = cmd_list_parse(argc, argv, file, line, cause);
 | 
				
			||||||
			    cause);
 | 
					 | 
				
			||||||
			if (*cmdlist == NULL)
 | 
					 | 
				
			||||||
				goto out;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			rval = 0;
 | 
					 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
		case '~':
 | 
							case '~':
 | 
				
			||||||
			if (buf == NULL) {
 | 
								if (buf == NULL) {
 | 
				
			||||||
@@ -171,7 +151,7 @@ out:
 | 
				
			|||||||
		free(argv);
 | 
							free(argv);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (rval);
 | 
						return (cmdlist);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,7 +85,8 @@ control_callback(struct client *c, int closed, __unused void *data)
 | 
				
			|||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (cmd_string_parse(line, &cmdlist, NULL, 0, &cause) != 0) {
 | 
							cmdlist = cmd_string_parse(line, NULL, 0, &cause);
 | 
				
			||||||
 | 
							if (cmdlist == NULL) {
 | 
				
			||||||
			item = cmdq_get_callback(control_error, cause);
 | 
								item = cmdq_get_callback(control_error, cause);
 | 
				
			||||||
			cmdq_append(c, item);
 | 
								cmdq_append(c, item);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -379,12 +379,10 @@ key_bindings_init(void)
 | 
				
			|||||||
	u_int		 i;
 | 
						u_int		 i;
 | 
				
			||||||
	struct cmd_list	*cmdlist;
 | 
						struct cmd_list	*cmdlist;
 | 
				
			||||||
	char		*cause;
 | 
						char		*cause;
 | 
				
			||||||
	int		 error;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < nitems(defaults); i++) {
 | 
						for (i = 0; i < nitems(defaults); i++) {
 | 
				
			||||||
		error = cmd_string_parse(defaults[i], &cmdlist,
 | 
							cmdlist = cmd_string_parse(defaults[i], "<default>", i, &cause);
 | 
				
			||||||
		    "<default-keys>", i, &cause);
 | 
							if (cmdlist == NULL)
 | 
				
			||||||
		if (error != 0)
 | 
					 | 
				
			||||||
			fatalx("bad default key");
 | 
								fatalx("bad default key");
 | 
				
			||||||
		cmdq_append(NULL, cmdq_get_command(cmdlist, NULL, NULL, 0));
 | 
							cmdq_append(NULL, cmdq_get_command(cmdlist, NULL, NULL, 0));
 | 
				
			||||||
		cmd_list_free(cmdlist);
 | 
							cmd_list_free(cmdlist);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1825,8 +1825,7 @@ void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...);
 | 
				
			|||||||
void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...);
 | 
					void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* cmd-string.c */
 | 
					/* cmd-string.c */
 | 
				
			||||||
int	cmd_string_parse(const char *, struct cmd_list **, const char *,
 | 
					struct cmd_list	*cmd_string_parse(const char *, const char *, u_int, char **);
 | 
				
			||||||
	    u_int, char **);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* cmd-wait-for.c */
 | 
					/* cmd-wait-for.c */
 | 
				
			||||||
void	cmd_wait_for_flush(void);
 | 
					void	cmd_wait_for_flush(void);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -255,7 +255,8 @@ window_choose_data_run(struct window_choose_data *cdata)
 | 
				
			|||||||
	if (cdata->command == NULL)
 | 
						if (cdata->command == NULL)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cmd_string_parse(cdata->command, &cmdlist, NULL, 0, &cause) != 0) {
 | 
						cmdlist = cmd_string_parse(cdata->command, NULL, 0, &cause);
 | 
				
			||||||
 | 
						if (cmdlist == NULL) {
 | 
				
			||||||
		if (cause != NULL) {
 | 
							if (cause != NULL) {
 | 
				
			||||||
			*cause = toupper((u_char) *cause);
 | 
								*cause = toupper((u_char) *cause);
 | 
				
			||||||
			status_message_set(cdata->start_client, "%s", cause);
 | 
								status_message_set(cdata->start_client, "%s", cause);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user