diff options
author | Rob Landley <rob@landley.net> | 2012-02-28 00:29:52 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-02-28 00:29:52 -0600 |
commit | b73d8e3c2d3b606295453940e602d173924cd380 (patch) | |
tree | e27f1493aaf74291e83e9f7bfe146c57959855d7 /lib | |
parent | f793d5347f08bdb742e8ad8a2cc5a7d30e6bd623 (diff) | |
download | toybox-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')
-rw-r--r-- | lib/args.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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) |