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:
Kevin Easton
2017-02-16 23:42:52 +11:00
parent debfebf3a7
commit 686344314f
5 changed files with 44 additions and 54 deletions

View File

@@ -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;