Introduce ARG* macros to simplify arg handling.
This commit is contained in:
parent
c4e4f05fa6
commit
b137773914
2
Makefile
2
Makefile
|
@ -36,7 +36,7 @@ dist: clean
|
|||
@echo creating dist tarball
|
||||
@mkdir -p tabbed-${VERSION}
|
||||
@cp -R LICENSE Makefile README config.def.h config.mk \
|
||||
tabbed.1 ${SRC} tabbed-${VERSION}
|
||||
tabbed.1 arg.h ${SRC} tabbed-${VERSION}
|
||||
@tar -cf tabbed-${VERSION}.tar tabbed-${VERSION}
|
||||
@gzip tabbed-${VERSION}.tar
|
||||
@rm -rf tabbed-${VERSION}
|
||||
|
|
49
tabbed.c
49
tabbed.c
|
@ -15,6 +15,8 @@
|
|||
#include <X11/Xproto.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "arg.h"
|
||||
|
||||
/* XEMBED messages */
|
||||
#define XEMBED_EMBEDDED_NOTIFY 0
|
||||
#define XEMBED_WINDOW_ACTIVATE 1
|
||||
|
@ -150,6 +152,8 @@ static Client *clients = NULL, *sel = NULL, *lastsel = NULL;
|
|||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||
static char winid[64];
|
||||
static char **cmd = NULL;
|
||||
|
||||
char *argv0;
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
|
||||
|
@ -874,37 +878,22 @@ usage(void)
|
|||
int
|
||||
main(int argc, char *argv[]) {
|
||||
int detach = 0;
|
||||
char _argc;
|
||||
char **_argv;
|
||||
|
||||
for(argv0 = *argv, argv++, argc--;
|
||||
argv[0] && argv[0][1] && argv[0][0] == '-';
|
||||
argc--, 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) {
|
||||
case 'v':
|
||||
die("tabbed-"VERSION", © 2009-2011"
|
||||
" tabbed engineers, see LICENSE"
|
||||
" for details.\n");
|
||||
case 's':
|
||||
doinitspawn = False;
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
case 'd':
|
||||
detach = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ARGBEGIN {
|
||||
case 'v':
|
||||
die("tabbed-"VERSION", © 2009-2011"
|
||||
" tabbed engineers, see LICENSE"
|
||||
" for details.\n");
|
||||
case 's':
|
||||
doinitspawn = False;
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
case 'd':
|
||||
detach = 1;
|
||||
break;
|
||||
} ARGEND;
|
||||
|
||||
if(argc < 1)
|
||||
doinitspawn = False;
|
||||
setcmd(argc, argv);
|
||||
|
|
Loading…
Reference in a new issue