aboutsummaryrefslogtreecommitdiff
path: root/lib/args.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-02-28 00:29:52 -0600
committerRob Landley <rob@landley.net>2012-02-28 00:29:52 -0600
commitb73d8e3c2d3b606295453940e602d173924cd380 (patch)
treee27f1493aaf74291e83e9f7bfe146c57959855d7 /lib/args.c
parentf793d5347f08bdb742e8ad8a2cc5a7d30e6bd623 (diff)
downloadtoybox-b73d8e3c2d3b606295453940e602d173924cd380.tar.gz
Add "-" type to optargs and teach tail.c to use it. Tighten up help text, use xzalloc() and xputc() as appropriate.
Diffstat (limited to 'lib/args.c')
-rw-r--r--lib/args.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/args.c b/lib/args.c
index 8b209d97..918119c6 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -18,6 +18,7 @@
// <LOW - die if less than LOW
// >HIGH - die if greater than HIGH
// =DEFAULT - value if not specified
+// - plus a signed long argument defaulting to negative
// . plus a double precision floating point argument (with CFG_TOYBOX_FLOAT)
// Chop this out with USE_TOYBOX_FLOAT() around option string
// Same <LOW>HIGH=DEFAULT as #
@@ -148,8 +149,9 @@ static int gotflag(struct getoptflagstate *gof)
while (*list) list=&((*list)->next);
*list = xzalloc(sizeof(struct arg_list));
(*list)->arg = arg;
- } else if (type == '#') {
+ } else if (type == '#' || type == '-') {
long l = atolx(arg);
+ if (type == '-' && !ispunct(*arg)) l*=-1;
if (l < opt->val[0].l)
error_exit("-%c < %ld", opt->c, opt->val[0].l);
if (l > opt->val[1].l)