summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/parse-util.c11
-rw-r--r--src/basic/parse-util.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c
index 503a895731..11849ade0b 100644
--- a/src/basic/parse-util.c
+++ b/src/basic/parse-util.c
@@ -533,7 +533,7 @@ int parse_fractional_part_u(const char **p, size_t digits, unsigned *res) {
return 0;
}
-int parse_percent(const char *p) {
+int parse_percent_unbounded(const char *p) {
const char *pc, *n;
unsigned v;
int r;
@@ -546,8 +546,15 @@ int parse_percent(const char *p) {
r = safe_atou(n, &v);
if (r < 0)
return r;
+
+ return (int) v;
+}
+
+int parse_percent(const char *p) {
+ int v = parse_percent_unbounded(p);
+
if (v > 100)
return -ERANGE;
- return (int) v;
+ return v;
}
diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h
index 73441bb6fd..f0fa5f9752 100644
--- a/src/basic/parse-util.h
+++ b/src/basic/parse-util.h
@@ -106,4 +106,5 @@ int safe_atod(const char *s, double *ret_d);
int parse_fractional_part_u(const char **s, size_t digits, unsigned *res);
+int parse_percent_unbounded(const char *p);
int parse_percent(const char *p);