X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=util.h;h=d0fd66dda4d71a75ffa6d84a709aa44c578a9f7a;hb=a7610064ae4fbccfcff8b91656dfee3f55d21c9c;hp=273ece89f1be7729a2963d12080805e682757018;hpb=2d368c149b90a7b284035f8883eb0c3e64a2caab;p=elogind.git diff --git a/util.h b/util.h index 273ece89f..d0fd66dda 100644 --- a/util.h +++ b/util.h @@ -163,10 +163,14 @@ bool ignore_file(const char *filename); } \ type name##_from_string(const char *s) { \ type i; \ + unsigned u = 0; \ 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__