projects
/
libusual.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1dc0fd0
)
cfparser: use strtol() in set_int
author
Marko Kreen
<markokr@gmail.com>
Thu, 19 Jan 2012 11:17:51 +0000
(13:17 +0200)
committer
Marko Kreen
<markokr@gmail.com>
Thu, 19 Jan 2012 11:17:51 +0000
(13:17 +0200)
This allows octal and hex prefixes, also error detection.
usual/cfparser.c
patch
|
blob
|
blame
|
history
diff --git
a/usual/cfparser.c
b/usual/cfparser.c
index 55dbd757ad81881c9e364c388bc538faacd093a9..934fb3dd8acf0d88f3567f999700ca5b30828e0b 100644
(file)
--- a/
usual/cfparser.c
+++ b/
usual/cfparser.c
@@
-350,7
+350,12
@@
bool cf_load_file(const struct CfContext *cf, const char *fn)
bool cf_set_int(struct CfValue *cv, const char *value)
{
int *ptr = cv->value_p;
- *ptr = atoi(value);
+ char *end;
+ long val;
+ val = strtol(value, &end, 0);
+ if (end == value)
+ return false;
+ *ptr = val;
return true;
}