diff --git a/Changelog b/Changelog index 64cd1e3..3d70bf8 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2.2] +* Unsetting CMDCHARS sets it back to the default. (caf) + * Fix a double-free bug when a window on an alternate screen queries an exec process. (caf) diff --git a/source/commands.c b/source/commands.c index 4865e0f..c990aca 100644 --- a/source/commands.c +++ b/source/commands.c @@ -4111,21 +4111,18 @@ void command_completion(char unused, char *not_used) char *line = NULL, *com, - *cmdchars, *rest, firstcmdchar[2] = "/"; + const char *cmdchars = get_string_var(CMDCHARS_VAR); const IrcCommand *command; #ifdef WANT_DLL IrcCommandDll *dll = NULL; #endif char buffer[BIG_BUFFER_SIZE]; - malloc_strcpy(&line, get_input()); if ((com = next_arg(line, &rest)) != NULL) { - if (!(cmdchars = get_string_var(CMDCHARS_VAR))) - cmdchars = DEFAULT_CMDCHARS; if (*com == '/' || strchr(cmdchars, *com)) { *firstcmdchar = *cmdchars; @@ -4439,20 +4436,20 @@ void BX_parse_line (const char *name, char *org_line, const char *args, int hist * characters or anything (beyond those specific for a given command being * executed). */ -int BX_parse_command(register char *line, int hist_flag, char *sub_args) +int BX_parse_command(char *line, int hist_flag, char *sub_args) { -static unsigned int level = 0; - unsigned int display, - old_display_var; - char *cmdchars; - const char *com; - char *this_cmd = NULL; - int args_flag = 0, - add_to_hist, - cmdchar_used = 0; - int noisy = 1; + static unsigned int level = 0; + unsigned int display, + old_display_var; + const char *cmdchars = get_string_var(CMDCHARS_VAR); + const char *com; + char *this_cmd = NULL; + int args_flag = 0, + add_to_hist, + cmdchar_used = 0; + int noisy = 1; - int old_alias_debug = alias_debug; + int old_alias_debug = alias_debug; if (!line || !*line) return 0; @@ -4461,10 +4458,6 @@ static unsigned int level = 0; debugyell("Executing [%d] %s", level, line); level++; - if (!(cmdchars = get_string_var(CMDCHARS_VAR))) - cmdchars = DEFAULT_CMDCHARS; - - this_cmd = LOCAL_COPY(line); set_current_command(this_cmd); add_to_hist = 1; diff --git a/source/functions.c b/source/functions.c index 88420d1..4c45b08 100644 --- a/source/functions.c +++ b/source/functions.c @@ -1183,12 +1183,9 @@ static char *alias_target (void) static char *alias_cmdchar (void) { - char *cmdchars, tmp[2]; + const char *cmdchars = get_string_var(CMDCHARS_VAR); + char tmp[2] = { cmdchars[0], 0 }; - if ((cmdchars = get_string_var(CMDCHARS_VAR)) == NULL) - cmdchars = DEFAULT_CMDCHARS; - tmp[0] = cmdchars[0]; - tmp[1] = 0; return m_strdup(tmp); } diff --git a/source/input.c b/source/input.c index fc64b15..7dbe233 100644 --- a/source/input.c +++ b/source/input.c @@ -983,14 +983,11 @@ BUILT_IN_KEYBINDING(toggle_insert_mode) BUILT_IN_KEYBINDING(input_msgreply) { -char *cmdchar; -char *line, *cmd, *t; -char *snick; -NickTab *nick = NULL; -int got_space = 0; - - if (!(cmdchar = get_string_var(CMDCHARS_VAR))) - cmdchar = DEFAULT_CMDCHARS; + const char *cmdchar = get_string_var(CMDCHARS_VAR); + char *line, *cmd, *t; + char *snick; + NickTab *nick = NULL; + int got_space = 0; t = line = m_strdup(get_input()); if (t) @@ -1172,14 +1169,10 @@ BUILT_IN_KEYBINDING(send_line) } else { - char *line, - *cmdchar, - *tmp = NULL; + const char *cmdchar = get_string_var(CMDCHARS_VAR); + char *line = get_input(); + char *tmp = m_strdup(line); - line = get_input(); - if (!(cmdchar = get_string_var(CMDCHARS_VAR))) - cmdchar = "/"; - malloc_strcpy(&tmp, line); if (line && (*line != *cmdchar) && get_int_var(NICK_COMPLETION_VAR) && !current_window->query_nick) { char auto_comp_char; @@ -2523,17 +2516,17 @@ char buffer[BIG_BUFFER_SIZE+1]; BUILT_IN_KEYBINDING(tab_completion) { -int count = 0, - wcount = 0; -enum completion type = NO_COMPLETION; -char *inp = NULL; -char *possible = NULL, *old_pos = NULL; -char *cmdchar; -char *suggested = NULL; -int got_space = 0; -char *get = NULL; -Ext_Name_Type *extcomp = ext_completion; - + int count = 0, + wcount = 0; + enum completion type = NO_COMPLETION; + char *inp = NULL; + char *possible = NULL, *old_pos = NULL; + const char *cmdchar = get_string_var(CMDCHARS_VAR); + char *suggested = NULL; + int got_space = 0; + char *get = NULL; + Ext_Name_Type *extcomp = ext_completion; + /* * is this the != second word, then just complete from the * channel nicks. if it is the second word, grab the first word, and @@ -2546,8 +2539,7 @@ Ext_Name_Type *extcomp = ext_completion; if (*inp && inp[strlen(inp)-1] == ' ') got_space = 1; wcount = word_count(inp); - if (!(cmdchar = get_string_var(CMDCHARS_VAR))) - cmdchar = "/"; + switch(wcount) { case 0: diff --git a/source/vars.c b/source/vars.c index ea32975..a66ceef 100644 --- a/source/vars.c +++ b/source/vars.c @@ -90,6 +90,7 @@ static void set_clock_format (Window *, char *, int); static void set_dcc_timeout(Window *, char *, int); void BX_set_scrollback_size (Window *, char *, int); static void set_use_socks(Window *, char *, int); +static void set_cmdchars(Window *, char *, int); static void set_mangle_inbound (Window *, char *, int); static void set_mangle_outbound (Window *, char *, int); @@ -166,7 +167,7 @@ static IrcVariable irc_variable[] = { "CLOCK_FORMAT",0, STR_TYPE_VAR, 0, NULL, set_clock_format, 0, 0 }, { "CLONE_CHECK",0, INT_TYPE_VAR, 0, NULL, NULL, 0, 0 }, { "CLONE_COUNT",0, INT_TYPE_VAR, 0, NULL, NULL, 0, 0 }, - { "CMDCHARS",0, STR_TYPE_VAR, 0, NULL, NULL, 0, 0 }, + { "CMDCHARS",0, STR_TYPE_VAR, 0, NULL, set_cmdchars, 0, 0 }, { "COLOR",0, BOOL_TYPE_VAR, 1, NULL, NULL, 0, 0 }, { "COMMAND_MODE",0, BOOL_TYPE_VAR, DEFAULT_COMMAND_MODE, NULL, NULL, 0, 0 }, { "COMMENT_BREAKAGE",0, BOOL_TYPE_VAR, 0, NULL, NULL, 0, 0 }, @@ -1561,6 +1562,11 @@ extern int use_socks; use_socks = 0; } +/* CMDCHARS cannot be unset - unsetting it just sets it back to the default. */ +static void set_cmdchars(Window *win, char *value, int unused) +{ + set_string_var(CMDCHARS_VAR, value ? value : DEFAULT_CMDCHARS); +} int parse_mangle (char *value, int nvalue, char **rv) {