aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-09-09 22:05:10 -0500
committerRob Landley <rob@landley.net>2017-09-09 22:05:10 -0500
commitf900298d7932af7930da362b0d5b92fef5545b01 (patch)
tree0db170282fe687744639e98eb23f492e3ab4f69c /lib
parent7f2b0ceabdf5121bb2f502e93e1ed6c738493d51 (diff)
downloadtoybox-f900298d7932af7930da362b0d5b92fef5545b01.tar.gz
Last commit used xstrtod(), forgot to check it in.
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.h1
-rw-r--r--lib/xwrap.c13
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/lib.h b/lib/lib.h
index 9325a89b..a9a92fd9 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -168,6 +168,7 @@ unsigned xgetuid(char *name);
unsigned xgetgid(char *name);
void xsetuser(struct passwd *pwd);
char *xreadlink(char *name);
+double xstrtod(char *s);
long xparsetime(char *arg, long units, long *fraction);
void xpidfile(char *name);
void xregcomp(regex_t *preg, char *rexec, int cflags);
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 83f54a0a..74da0ed1 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -755,6 +755,19 @@ long long xsendfile(int in, int out)
return total;
}
+double xstrtod(char *s)
+{
+ char *end;
+ double d;
+
+ errno = 0;
+ d = strtod(s, &end);
+ if (!errno && *end) errno = E2BIG;
+ if (errno) perror_exit("strtod %s", s);
+
+ return d;
+}
+
// parse fractional seconds with optional s/m/h/d suffix
long xparsetime(char *arg, long units, long *fraction)
{