nldev

NetLink DEVice manager; a lightweight netlink frontend for mdev.
git clone git://r-36.net/nldev
Log | Files | Refs | LICENSE

commit 080088cdab3baa53275cc371c0d6270ada36cc3b
parent 025a4aef1a05cf523fbdf98ed71fd2e7b902d7fd
Author: Christoph Lohmann <20h@r-36.net>
Date:   Mon, 27 Jul 2015 17:26:56 +0200

Update arg.h and remove the compiler warning about DEFAULT SOURCE.

Diffstat:
arg.h | 22++++++++++++++++++----
config.mk | 2+-
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/arg.h b/arg.h @@ -8,20 +8,23 @@ 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;\ @@ -34,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 diff --git a/config.mk b/config.mk @@ -13,7 +13,7 @@ INCS = -I. -I/usr/include LIBS = -L/usr/lib -lc # flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_GNU_SOURCE +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} LDFLAGS = -static -g ${LIBS} #LDFLAGS = -s ${LIBS}