summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-08-31 00:18:55 -0400
committerNick Mathewson <nickm@torproject.org>2009-08-31 00:18:55 -0400
commit00b37f071d2c96612892340f5f883b869033d6a1 (patch)
tree35d484780d5ca53aae43a5a90e9d032c6b1c08a5 /src/common/util.c
parent0bb59f1c38eef467a353faf1a30cf93b64209a27 (diff)
downloadtor-00b37f071d2c96612892340f5f883b869033d6a1.tar.gz
tor-00b37f071d2c96612892340f5f883b869033d6a1.zip
Revise parsing of time and memory units to handle spaces.
When we added support for fractional units (like 1.5 MB) I broke support for giving units with no space (like 2MB). This patch should fix that. It also adds a propoer tor_parse_double(). Fix for bug 1076. Bugfix on 0.2.2.1-alpha.
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 234180c4d4..19839e23a1 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -735,6 +735,17 @@ tor_parse_ulong(const char *s, int base, unsigned long min,
CHECK_STRTOX_RESULT();
}
+/** As tor_parse_long(), but return a double. */
+double
+tor_parse_double(const char *s, double min, double max, int *ok, char **next)
+{
+ char *endptr;
+ double r;
+
+ r = strtod(s, &endptr);
+ CHECK_STRTOX_RESULT();
+}
+
/** As tor_parse_log, but return a unit64_t. Only base 10 is guaranteed to
* work for now. */
uint64_t