Unsetting CMDCHARS sets it back to the default
Previously you could unset CMDCHARS and the effect would be to treat it like it was set to DEFAULT_CMDCHARS, except that some code was missing the fallback (eg. ignore_last_nick()) which would make it crash. Instead of having the fallback everywhere, just make it so that you can't unset the variable - if you try, it sets it to DEFAULT_CMDCHARS. This reflects what the behaviour has always been, it just makes it explicit to the user and the bonus is we don't have the test it for NULL everywhere.
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
[Changes 1.2.2]
|
[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
|
* Fix a double-free bug when a window on an alternate screen queries an exec
|
||||||
process. (caf)
|
process. (caf)
|
||||||
|
|
||||||
|
|||||||
@@ -4111,21 +4111,18 @@ void command_completion(char unused, char *not_used)
|
|||||||
|
|
||||||
char *line = NULL,
|
char *line = NULL,
|
||||||
*com,
|
*com,
|
||||||
*cmdchars,
|
|
||||||
*rest,
|
*rest,
|
||||||
firstcmdchar[2] = "/";
|
firstcmdchar[2] = "/";
|
||||||
|
const char *cmdchars = get_string_var(CMDCHARS_VAR);
|
||||||
const IrcCommand *command;
|
const IrcCommand *command;
|
||||||
#ifdef WANT_DLL
|
#ifdef WANT_DLL
|
||||||
IrcCommandDll *dll = NULL;
|
IrcCommandDll *dll = NULL;
|
||||||
#endif
|
#endif
|
||||||
char buffer[BIG_BUFFER_SIZE];
|
char buffer[BIG_BUFFER_SIZE];
|
||||||
|
|
||||||
|
|
||||||
malloc_strcpy(&line, get_input());
|
malloc_strcpy(&line, get_input());
|
||||||
if ((com = next_arg(line, &rest)) != NULL)
|
if ((com = next_arg(line, &rest)) != NULL)
|
||||||
{
|
{
|
||||||
if (!(cmdchars = get_string_var(CMDCHARS_VAR)))
|
|
||||||
cmdchars = DEFAULT_CMDCHARS;
|
|
||||||
if (*com == '/' || strchr(cmdchars, *com))
|
if (*com == '/' || strchr(cmdchars, *com))
|
||||||
{
|
{
|
||||||
*firstcmdchar = *cmdchars;
|
*firstcmdchar = *cmdchars;
|
||||||
@@ -4439,12 +4436,12 @@ 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
|
* characters or anything (beyond those specific for a given command being
|
||||||
* executed).
|
* 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;
|
static unsigned int level = 0;
|
||||||
unsigned int display,
|
unsigned int display,
|
||||||
old_display_var;
|
old_display_var;
|
||||||
char *cmdchars;
|
const char *cmdchars = get_string_var(CMDCHARS_VAR);
|
||||||
const char *com;
|
const char *com;
|
||||||
char *this_cmd = NULL;
|
char *this_cmd = NULL;
|
||||||
int args_flag = 0,
|
int args_flag = 0,
|
||||||
@@ -4461,10 +4458,6 @@ static unsigned int level = 0;
|
|||||||
debugyell("Executing [%d] %s", level, line);
|
debugyell("Executing [%d] %s", level, line);
|
||||||
level++;
|
level++;
|
||||||
|
|
||||||
if (!(cmdchars = get_string_var(CMDCHARS_VAR)))
|
|
||||||
cmdchars = DEFAULT_CMDCHARS;
|
|
||||||
|
|
||||||
|
|
||||||
this_cmd = LOCAL_COPY(line);
|
this_cmd = LOCAL_COPY(line);
|
||||||
set_current_command(this_cmd);
|
set_current_command(this_cmd);
|
||||||
add_to_hist = 1;
|
add_to_hist = 1;
|
||||||
|
|||||||
@@ -1183,12 +1183,9 @@ static char *alias_target (void)
|
|||||||
|
|
||||||
static char *alias_cmdchar (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);
|
return m_strdup(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -983,15 +983,12 @@ BUILT_IN_KEYBINDING(toggle_insert_mode)
|
|||||||
|
|
||||||
BUILT_IN_KEYBINDING(input_msgreply)
|
BUILT_IN_KEYBINDING(input_msgreply)
|
||||||
{
|
{
|
||||||
char *cmdchar;
|
const char *cmdchar = get_string_var(CMDCHARS_VAR);
|
||||||
char *line, *cmd, *t;
|
char *line, *cmd, *t;
|
||||||
char *snick;
|
char *snick;
|
||||||
NickTab *nick = NULL;
|
NickTab *nick = NULL;
|
||||||
int got_space = 0;
|
int got_space = 0;
|
||||||
|
|
||||||
if (!(cmdchar = get_string_var(CMDCHARS_VAR)))
|
|
||||||
cmdchar = DEFAULT_CMDCHARS;
|
|
||||||
|
|
||||||
t = line = m_strdup(get_input());
|
t = line = m_strdup(get_input());
|
||||||
if (t)
|
if (t)
|
||||||
got_space = strchr(t, ' ') ? 1 : 0;
|
got_space = strchr(t, ' ') ? 1 : 0;
|
||||||
@@ -1172,14 +1169,10 @@ BUILT_IN_KEYBINDING(send_line)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *line,
|
const char *cmdchar = get_string_var(CMDCHARS_VAR);
|
||||||
*cmdchar,
|
char *line = get_input();
|
||||||
*tmp = NULL;
|
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)
|
if (line && (*line != *cmdchar) && get_int_var(NICK_COMPLETION_VAR) && !current_window->query_nick)
|
||||||
{
|
{
|
||||||
char auto_comp_char;
|
char auto_comp_char;
|
||||||
@@ -2528,7 +2521,7 @@ int count = 0,
|
|||||||
enum completion type = NO_COMPLETION;
|
enum completion type = NO_COMPLETION;
|
||||||
char *inp = NULL;
|
char *inp = NULL;
|
||||||
char *possible = NULL, *old_pos = NULL;
|
char *possible = NULL, *old_pos = NULL;
|
||||||
char *cmdchar;
|
const char *cmdchar = get_string_var(CMDCHARS_VAR);
|
||||||
char *suggested = NULL;
|
char *suggested = NULL;
|
||||||
int got_space = 0;
|
int got_space = 0;
|
||||||
char *get = NULL;
|
char *get = NULL;
|
||||||
@@ -2546,8 +2539,7 @@ Ext_Name_Type *extcomp = ext_completion;
|
|||||||
if (*inp && inp[strlen(inp)-1] == ' ')
|
if (*inp && inp[strlen(inp)-1] == ' ')
|
||||||
got_space = 1;
|
got_space = 1;
|
||||||
wcount = word_count(inp);
|
wcount = word_count(inp);
|
||||||
if (!(cmdchar = get_string_var(CMDCHARS_VAR)))
|
|
||||||
cmdchar = "/";
|
|
||||||
switch(wcount)
|
switch(wcount)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ static void set_clock_format (Window *, char *, int);
|
|||||||
static void set_dcc_timeout(Window *, char *, int);
|
static void set_dcc_timeout(Window *, char *, int);
|
||||||
void BX_set_scrollback_size (Window *, char *, int);
|
void BX_set_scrollback_size (Window *, char *, int);
|
||||||
static void set_use_socks(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_inbound (Window *, char *, int);
|
||||||
static void set_mangle_outbound (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 },
|
{ "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_CHECK",0, INT_TYPE_VAR, 0, NULL, NULL, 0, 0 },
|
||||||
{ "CLONE_COUNT",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 },
|
{ "COLOR",0, BOOL_TYPE_VAR, 1, NULL, NULL, 0, 0 },
|
||||||
{ "COMMAND_MODE",0, BOOL_TYPE_VAR, DEFAULT_COMMAND_MODE, 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 },
|
{ "COMMENT_BREAKAGE",0, BOOL_TYPE_VAR, 0, NULL, NULL, 0, 0 },
|
||||||
@@ -1561,6 +1562,11 @@ extern int use_socks;
|
|||||||
use_socks = 0;
|
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)
|
int parse_mangle (char *value, int nvalue, char **rv)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user