From 064ff3921d9e06d55272bc17bb8dfa9ee5c671d3 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Thu, 20 Aug 2009 01:01:05 +0300 Subject: [PATCH] bug 1084: Allow '+' and '*' in names in option manager ELinks already allowed '+' and '*' in the names of options when reading a configuration file. The option manager however didn't let the user add such options. Allow the characters there too. These characters are needed especially in the mime.type tree, where '*' is used as a replacement for '.'. For example: set mime.type.audio.prs*sid = "sid" set mime.type.application.atom+xml = "atom" This commit changes one gettextised string. --- NEWS | 2 ++ src/config/conf.c | 8 ++++---- src/config/dialogs.c | 6 ++---- src/config/options.h | 10 ++++++++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 1b6741a6..5f3b50a5 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ To be released as 0.12pre6 or 0.12rc1. systems. * bug 983: Give preference to the Content-Type specified in the HTTP header over that specified via the HTML meta tag. +* bug 1084: Allow option names containing '+' and '*' in the option + manager. Bugs that should be removed from NEWS before the 0.12.0 release: diff --git a/src/config/conf.c b/src/config/conf.c index 48fd1353..12bba7ca 100644 --- a/src/config/conf.c +++ b/src/config/conf.c @@ -208,8 +208,8 @@ parse_set(struct option *opt_tree, struct conf_parsing_state *state, /* Option name */ optname_orig = state->pos.look; - while (isident(*state->pos.look) || *state->pos.look == '*' - || *state->pos.look == '.' || *state->pos.look == '+') + while (is_option_name_char(*state->pos.look) + || *state->pos.look == '.') state->pos.look++; optname_len = state->pos.look - optname_orig; @@ -341,8 +341,8 @@ parse_unset(struct option *opt_tree, struct conf_parsing_state *state, /* Option name */ optname_orig = state->pos.look; - while (isident(*state->pos.look) || *state->pos.look == '*' - || *state->pos.look == '.' || *state->pos.look == '+') + while (is_option_name_char(*state->pos.look) + || *state->pos.look == '.') state->pos.look++; optname_len = state->pos.look - optname_orig; diff --git a/src/config/dialogs.c b/src/config/dialogs.c index 235b62f5..7ad64487 100644 --- a/src/config/dialogs.c +++ b/src/config/dialogs.c @@ -425,13 +425,11 @@ check_option_name(struct dialog_data *dlg_data, struct widget_data *widget_data) unsigned char *p; for (p = widget_data->cdata; *p; p++) - /* Not '*' since it is used internally. */ - if (!isident(*p)) { - /* FIXME: Encode '.' into '*'? */ + if (!is_option_name_char(*p)) { info_box(dlg_data->win->term, 0, N_("Bad string"), ALIGN_CENTER, N_("Option names may only contain alpha-numeric characters\n" - "in addition to '_' and '-'.")); + "in addition to '_', '-', '+', and '*'.")); return EVENT_NOT_PROCESSED; } diff --git a/src/config/options.h b/src/config/options.h index fac639d3..28bd00cf 100644 --- a/src/config/options.h +++ b/src/config/options.h @@ -318,6 +318,16 @@ extern struct option *add_opt(struct option *, unsigned char *, unsigned char *, unsigned char *, enum option_flags, enum option_type, long, long, longptr_T, unsigned char *); +/** Check whether the character @a c may be used in the name of an + * option. This does not allow the '.' used in multi-part names like + * "config.comments". If you want to allow that too, check for it + * separately. + * + * If you modify this, please update the error message in + * check_option_name(). */ +#define is_option_name_char(c) (isasciialnum(c) || (c) == '_' \ + || (c) == '-' || (c) == '+' || (c) == '*') + /* Hack which permit to disable option descriptions, to reduce elinks binary size. * It may of some use for people wanting a very small static non-i18n elinks binary, * at time of writing gain is over 25Kbytes. --Zas */