geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit cf8dcb97a53fa14b89ade9088299ba8c1e8d7dc7
parent f7fa209ff3d253fe62813d925468f7fe14ebc507
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun, 12 Jun 2011 17:36:55 +0200

Adding parameter grouping.

Diffstat:
arg.h | 29+++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/arg.h b/arg.h @@ -5,13 +5,30 @@ extern char *argv0; -#define ARGBEGIN for(argv0 = *argv, argv++, argc--;\ - argv[0] && argv[0][0]=='-' && argv[0][1];\ - argc--, argv++) {\ +#define ARGBEGIN for(argv0 = *argv, argv++, argc--;\ + argv[0] && argv[0][1]\ + && argv[0][0] == '-';\ + argc--, argv++) {\ char _argc;\ - _argc = argv[0][1];\ - switch(_argc) -#define ARGEND USED(_argc);} USED(argv);USED(argc); + char **_argv;\ + if(argv[0][1] == '-' && argv[0][2] == '\0') {\ + argv++;\ + argc--;\ + break;\ + }\ + for(argv[0]++, _argv = argv; argv[0][0];\ + argv[0]++) {\ + if(_argv != argv)\ + break;\ + _argc = argv[0][0];\ + switch(_argc) + +#define ARGEND }\ + USED(_argc);\ + }\ + USED(argv);\ + USED(argc); + #define EARGF(x) ((argv[1] == nil)? ((x), abort(), (char *)0) :\ (argc--, argv++, argv[0]))