diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-07-16 13:58:09 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-07-16 13:58:09 +0300 |
commit | 3a16bc5620b4c664248bc5b5c586ddd0103f7050 (patch) | |
tree | ac32d299f907f5288cfffc10dceab87b1b682d8b | |
parent | 4549c2d6d9f7533541eb9ee4f4cf3190b94565f7 (diff) | |
download | wydawca-3a16bc5620b4c664248bc5b5c586ddd0103f7050.tar.gz wydawca-3a16bc5620b4c664248bc5b5c586ddd0103f7050.tar.bz2 |
Bugfix
* src/config.c: Case-insensitive comparison for syslog facility
and priority names.
-rw-r--r-- | src/config.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/config.c b/src/config.c index 6342f2f..692dbd5 100644 --- a/src/config.c +++ b/src/config.c @@ -24,11 +24,16 @@ struct keyword { int tok; }; +enum { + CASE_SENSITIVE, + CASE_INSENSITIVE +}; + static int -keyword_to_tok(const char *str, struct keyword *kw, int *pres) +keyword_to_tok(const char *str, struct keyword *kw, int ci, int *pres) { for (; kw->name; kw++) - if (strcmp(kw->name, str) == 0) { + if ((ci ? strcasecmp : strcmp)(kw->name, str) == 0) { *pres = kw->tok; return 0; } @@ -80,7 +85,7 @@ int wy_strtofac(const char *str) { int res; - if (keyword_to_tok(str, kwfac, &res)) + if (keyword_to_tok(str, kwfac, CASE_INSENSITIVE, &res)) return -1; return res; } @@ -89,7 +94,7 @@ int wy_strtopri(const char *str) { int res; - if (keyword_to_tok(str, kwpri, &res)) + if (keyword_to_tok(str, kwpri, CASE_INSENSITIVE, &res)) return -1; return res; } @@ -234,7 +239,7 @@ string_to_wy_event(grecs_locus_t *locus, const char *val, enum wy_event *pret) { int res; - if (keyword_to_tok(val, event_tab, &res)) { + if (keyword_to_tok(val, event_tab, CASE_SENSITIVE, &res)) { grecs_error(locus, 0, _("unknown notification event: %s"), val); return 1; @@ -386,7 +391,7 @@ parse_single_statmask(grecs_locus_t *locus, const grecs_value_t *val, return 0; } - if (keyword_to_tok(arg, stat_tab, &x)) { + if (keyword_to_tok(arg, stat_tab, CASE_SENSITIVE, &x)) { grecs_error(&val->locus, 0, _("unknown statistics type: %s"), arg); return 1; @@ -613,7 +618,7 @@ get_backup_version(grecs_locus_t *locus, const char *ctx, const char *version) if (version == 0 || *version == 0) return numbered_existing_backups; - else if (keyword_to_tok(version, backup_tab, &d)) { + else if (keyword_to_tok(version, backup_tab, CASE_SENSITIVE, &d)) { if (ctx) grecs_error(locus, 0, _("%s: ambiguous backup type `%s'"), ctx, @@ -890,7 +895,7 @@ string_to_dictionary_id(grecs_locus_t *locus, }; int res; - if (keyword_to_tok(str, id_tab, &res)) { + if (keyword_to_tok(str, id_tab, CASE_SENSITIVE, &res)) { grecs_error(locus, 0, _("unknown dictionary ID: %s"), str); return 1; } |