diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2007-08-29 12:53:35 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2007-08-29 12:53:35 +0000 |
commit | 882b72cd0ca5b72e2faf3abb7de8945cabc41d08 (patch) | |
tree | 191f4aa0b63e007e0cec20425fd7ae79acba7adc /src | |
parent | ebae0cb7d571431bb867575ec6a362a10df99b04 (diff) | |
download | weechat-882b72cd0ca5b72e2faf3abb7de8945cabc41d08.zip |
Added string length limit for setup file options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/command.c | 14 | ||||
-rw-r--r-- | src/common/weechat.c | 18 | ||||
-rw-r--r-- | src/common/weeconfig.c | 4 |
3 files changed, 32 insertions, 4 deletions
diff --git a/src/common/command.c b/src/common/command.c index 367126e01..1db3a2774 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -3878,7 +3878,19 @@ weechat_cmd_set (t_irc_server *server, t_irc_channel *channel, weechat_options[last_section][last_option].default_string : _("empty")); break; case OPTION_TYPE_STRING: - gui_printf (NULL, _(" . type string (any string)\n")); + switch (weechat_options[last_section][last_option].max) + { + case 0: + gui_printf (NULL, _(" . type string (any string)\n")); + break; + case 1: + gui_printf (NULL, _(" . type: char (any char)\n")); + break; + default: + gui_printf (NULL, _(" . type string (any string, limit: %d chars)\n"), + weechat_options[last_section][last_option].max); + break; + } gui_printf (NULL, _(" . default value: '%s'\n"), (weechat_options[last_section][last_option].default_string) ? weechat_options[last_section][last_option].default_string : _("empty")); diff --git a/src/common/weechat.c b/src/common/weechat.c index 54b65c89a..b15668a7d 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -187,8 +187,22 @@ weechat_display_config_options () weechat_options[i][j].default_string : _("empty")); break; case OPTION_TYPE_STRING: - weechat_iconv_fprintf (stdout, _(" . type: string\n")); - weechat_iconv_fprintf (stdout, _(" . values: any string\n")); + switch (weechat_options[i][j].max) + { + case 0: + weechat_iconv_fprintf (stdout, _(" . type: string\n")); + weechat_iconv_fprintf (stdout, _(" . values: any string\n")); + break; + case 1: + weechat_iconv_fprintf (stdout, _(" . type: char\n")); + weechat_iconv_fprintf (stdout, _(" . values: any char\n")); + break; + default: + weechat_iconv_fprintf (stdout, _(" . type: string\n")); + weechat_iconv_fprintf (stdout, _(" . values: any string (limit: %d chars)\n"), + weechat_options[i][j].max); + break; + } weechat_iconv_fprintf (stdout, _(" . default value: '%s'\n"), (weechat_options[i][j].default_string) ? weechat_options[i][j].default_string : _("empty")); diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index 3ea15a363..2a64c6838 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -290,7 +290,7 @@ t_config_option weechat_options_look[] = "%a, %d %b %Y", NULL, NULL, &cfg_look_day_change_timestamp, config_change_noop }, { "look_read_marker", N_("use a marker on servers/channels to show first unread line"), N_("use a marker on servers/channels to show first unread line"), - OPTION_TYPE_STRING, 0, 0, 0, + OPTION_TYPE_STRING, 0, 1, 0, " ", NULL, NULL, &cfg_look_read_marker, config_change_read_marker }, { "look_input_format", N_("format for input prompt"), N_("format for input prompt ('%c' is replaced by channel or server, " @@ -1430,6 +1430,8 @@ config_option_set_value (t_config_option *option, char *value) return -1; break; case OPTION_TYPE_STRING: + if ((option->max > 0) && (utf8_strlen (value) > option->max)) + return -1; if (*(option->ptr_string)) free (*(option->ptr_string)); *(option->ptr_string) = strdup (value); |