aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorJonathan Clairembault <jonathan@clairembault.fr>2012-11-23 00:06:28 +0100
committerJonathan Clairembault <jonathan@clairembault.fr>2012-11-23 00:06:28 +0100
commit939fa7408fa68af8568fd07de64a1606af0a0c06 (patch)
tree86dda7e86cadc1831dd5d69277ec926eb3d43f6b /lib/lib.c
parenta5f8c733d478a57ad03c0b0efe7fa995e4c364a2 (diff)
downloadtoybox-939fa7408fa68af8568fd07de64a1606af0a0c06.tar.gz
Add expand command as described in POSIX-2008.
Erratum: Do not handle backspace.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 57000ac7..36f78ceb 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -1182,6 +1182,17 @@ char* make_human_readable(unsigned long long size, unsigned long unit)
return NULL; //not reached
}
+// strtoul with exit on error
+unsigned long xstrtoul(const char *nptr, char **endptr, int base)
+{
+ unsigned long l;
+ errno = 0;
+ l = strtoul(nptr, endptr, base);
+ if (errno)
+ perror_exit("xstrtoul");
+ return l;
+}
+
/*
* used to get the interger value.
*/