tabbed

Fork of suckless' tabbed with my personal patches
git clone https://git.instinctive.eu/tabbed.git
Log | Files | Refs | README | LICENSE

commit d488a80a1e3d999629de1d4f5be3cec23139041f
parent ffa2dbeb645a3a3d6883d569107b1efd49472035
Author: Christoph Lohmann <20h@r-36.net>
Date:   Tue, 27 Nov 2012 21:17:10 +0100

Adding the form of -r1, which will result in -r 1 in arg.h.
Diffstat:
Marg.h | 29++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/arg.h b/arg.h @@ -1,26 +1,30 @@ /* - * See LICENSE file for copyright and license details. + * Copy me if you can. + * by 20h */ -#ifndef __CMD_H__ -#define __CMD_H__ +#ifndef __ARG_H__ +#define __ARG_H__ extern char *argv0; -#define USED(x) ((void)(x)) +#define USED(x) ((void)(x)) +/* use main(int argc, char *argv[]) */ #define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ argv[0] && argv[0][1]\ && argv[0][0] == '-';\ argc--, argv++) {\ char _argc;\ char **_argv;\ + int brk;\ if (argv[0][1] == '-' && argv[0][2] == '\0') {\ argv++;\ argc--;\ break;\ }\ - for (argv[0]++, _argv = argv; argv[0][0];\ + for (brk = 0, argv[0]++, _argv = argv;\ + argv[0][0] && !brk;\ argv[0]++) {\ if (_argv != argv)\ break;\ @@ -33,8 +37,19 @@ extern char *argv0; USED(argv);\ USED(argc); -#define EARGF(x) ((argv[1] == NULL)? ((x), abort(), (char *)0) :\ - (argc--, argv++, argv[0])) +#define ARGC() _argc + +#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ + ((x), abort(), (char *)0) :\ + (brk = 1, (argv[0][1] != '\0')?\ + (&argv[0][1]) :\ + (argc--, argv++, argv[0]))) + +#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ + (char *)0 :\ + (brk = 1, (argv[0][1] != '\0')?\ + (&argv[0][1]) :\ + (argc--, argv++, argv[0]))) #endif