tabbed

Simple tabbing application for X11.
git clone git://r-36.net/tabbed
Log | Files | Refs | README | LICENSE

commit b137773914989ad9e6158f286ff0bb247db4d5ea
parent c4e4f05fa6e5044cb668cd5db4ffbd933a6469d8
Author: Christoph Lohmann <20h@r-36.net>
Date:   Fri,  6 Apr 2012 20:44:47 +0200

Introduce ARG* macros to simplify arg handling.
Diffstat:
Makefile | 2+-
tabbed.c | 51++++++++++++++++++++-------------------------------
2 files changed, 21 insertions(+), 32 deletions(-)

diff --git a/Makefile b/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} diff --git a/tabbed.c b/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);