From b73d8e3c2d3b606295453940e602d173924cd380 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 28 Feb 2012 00:29:52 -0600 Subject: Add "-" type to optargs and teach tail.c to use it. Tighten up help text, use xzalloc() and xputc() as appropriate. --- lib/args.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/args.c') 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 @@ // 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 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) -- cgit v1.2.3