diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-09-16 16:51:45 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-09-16 16:51:45 +0200 |
commit | e00e4b169975eafdab7479e30c1773c00ec29943 (patch) | |
tree | bb7d5771c3fea8d2a15a1858ab66e25e3de00796 | |
parent | 09e3e442e122d5e6fcab9f36712401ced40ee090 (diff) |
-rw-r--r-- | number.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -3,6 +3,7 @@ #include <stdlib.h> #include <string.h> #include <stdbool.h> +#include <ctype.h> #include <inttypes.h> __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); } } |