vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

arg.h (731B)


      1 #define SET(x) ((x)=0,(void)(x))
      2 
      3 #define	ARGBEGIN	for((argv0?0:(argv0=(*argv))),argv++,argc--;\
      4 			    argv[0] && argv[0][0]=='-' && argv[0][1];\
      5 			    argc--, argv++) {\
      6 				char *_args, *_argt;\
      7 				Rune _argc;\
      8 				_args = &argv[0][1];\
      9 				if(_args[0]=='-' && _args[1]==0){\
     10 					argc--; argv++; break;\
     11 				}\
     12 				_argc = 0;\
     13 				while(*_args && (_args += chartorune(&_argc, _args)))\
     14 				switch(_argc)
     15 #define	ARGEND		SET(_argt);USED(_argt);USED(_argc);USED(_args);}USED(argv);USED(argc);
     16 #define	ARGF()		(_argt=_args, _args="",\
     17 				(*_argt? _argt: argv[1]? (argc--, *++argv): 0))
     18 #define	EARGF(x)	(_argt=_args, _args="",\
     19 				(*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
     20 
     21 #define	ARGC()		_argc
     22