Mercurial > hg > toybox
diff lib/args.c @ 504:a497beb97eee
Add "-" type to optargs and teach tail.c to use it. Tighten up help text, use xzalloc() and xputc() as appropriate.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 28 Feb 2012 00:29:52 -0600 |
parents | bc4615e2e339 |
children | c2f39708a4c4 |
line wrap: on
line diff
--- a/lib/args.c Mon Feb 27 21:56:49 2012 -0600 +++ b/lib/args.c Tue Feb 28 00:29:52 2012 -0600 @@ -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 @@ 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)