diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2015-11-18 22:01:29 +0100 |
---|---|---|
committer | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2015-11-18 22:01:29 +0100 |
commit | fbb838b3b0d30ee41de648d667fa89a2d6b41076 (patch) | |
tree | d49924299ac52da43a3b23c09aa0acfcbff480fd /src/core | |
parent | ac04fa741355888d814c693e7e2b793c5413c3eb (diff) | |
parent | d4676c985553dc957e863e814097beba9bcc279e (diff) | |
download | irssi-fbb838b3b0d30ee41de648d667fa89a2d6b41076.zip |
Merge pull request #350 from LemonBoy/fix-99
Strip trailing whitespace from commands
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/commands.c | 5 | ||||
-rw-r--r-- | src/core/commands.h | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/core/commands.c b/src/core/commands.c index 9e451bc8..88d1208c 100644 --- a/src/core/commands.c +++ b/src/core/commands.c @@ -748,6 +748,11 @@ int cmd_get_params(const char *data, gpointer *free_me, int count, ...) if (cnt == 0 && count & PARAM_FLAG_GETREST) { /* get rest */ arg = datad; + + /* strip the trailing whitespace */ + if (count & PARAM_FLAG_STRIP_TRAILING_WS) { + arg = g_strchomp(arg); + } } else { arg = (count & PARAM_FLAG_NOQUOTES) ? cmd_get_param(&datad) : diff --git a/src/core/commands.h b/src/core/commands.h index d65185e5..72105ad3 100644 --- a/src/core/commands.h +++ b/src/core/commands.h @@ -152,6 +152,8 @@ int command_have_option(const char *cmd, const char *option); #define PARAM_FLAG_OPTCHAN 0x00010000 /* optional channel in first argument, but don't treat "*" as current channel */ #define PARAM_FLAG_OPTCHAN_NAME (0x00020000|PARAM_FLAG_OPTCHAN) +/* strip the trailing whitespace */ +#define PARAM_FLAG_STRIP_TRAILING_WS 0x00040000 char *cmd_get_param(char **data); char *cmd_get_quoted_param(char **data); |