projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2d368c1
)
util: when parsing strings lookup tables accept integer strings, too
author
Lennart Poettering
<lennart@poettering.net>
Tue, 6 Apr 2010 21:37:20 +0000
(23:37 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Tue, 6 Apr 2010 21:37:20 +0000
(23:37 +0200)
util.h
patch
|
blob
|
history
diff --git
a/util.h
b/util.h
index
273ece8
..
af39acc
100644
(file)
--- 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; \
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__