From e00e4b169975eafdab7479e30c1773c00ec29943 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 16 Sep 2016 16:51:45 +0200 Subject: Fix negative number parsing --- number.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/number.c b/number.c index 4c1f9b2..24bcc33 100644 --- a/number.c +++ b/number.c @@ -3,6 +3,7 @@ #include #include #include +#include #include __attribute__((noreturn)) void usage(int argc,char **argv){ @@ -145,6 +146,14 @@ int main(int argc,char **argv){ usage(argc,argv); } if(argv[i][0]=='-'){ + if(isdigit(argv[i][1])){ + if(numstr==NULL)numstr=argv[i]; + else { + fprintf(stderr,"Unexpected second number '%s'\n",argv[i]); + usage(argc,argv); + } + continue; + } for(int j=1;argv[i][j];j++){ switch(argv[i][j]){ case 'c': capfirst=true; break; @@ -157,7 +166,7 @@ int main(int argc,char **argv){ } else { if(numstr==NULL)numstr=argv[i]; else { - fprintf(stderr,"Unexpected second bare argument '%s'\n",argv[i]); + fprintf(stderr,"Unexpected second number '%s'\n",argv[i]); usage(argc,argv); } } -- cgit v1.2.3-70-g09d2