diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-04-06 23:37:20 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-04-06 23:37:20 +0200 |
commit | d3725859f3d80972d7da3a73b92e58a06ac7d69a (patch) | |
tree | 704f6bd4b32b41fc87baa561d2a064b1938f03ba | |
parent | 2d368c149b90a7b284035f8883eb0c3e64a2caab (diff) |
util: when parsing strings lookup tables accept integer strings, too
-rw-r--r-- | util.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -163,10 +163,14 @@ bool ignore_file(const char *filename); } \ type name##_from_string(const char *s) { \ type i; \ + unsigned u; \ assert(s); \ for (i = 0; i < (type)ELEMENTSOF(name##_table); i++) \ if (streq(name##_table[i], s)) \ return i; \ + if (safe_atou(s, &u) >= 0 && \ + u < ELEMENTSOF(name##_table)) \ + return (type) u; \ return (type) -1; \ } \ struct __useless_struct_to_allow_trailing_semicolon__ |