Fix -c option, and make -k accept -c option better

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-03-23 21:35:34 +01:00
parent be12562ab7
commit 507ef3c21d
1 changed files with 7 additions and 4 deletions

View File

@ -177,7 +177,7 @@ main(int argc, char *argv[])
struct sockaddr_un *addr; struct sockaddr_un *addr;
Client *c; Client *c;
XSetWindowAttributes wa; XSetWindowAttributes wa;
Bool xsync = False; Bool xsync = False, confcheck = False;
static struct option long_options[] = static struct option long_options[] =
{ {
{"help", 0, NULL, 'h'}, {"help", 0, NULL, 'h'},
@ -202,7 +202,7 @@ main(int argc, char *argv[])
} }
/* check args */ /* check args */
while((opt = getopt_long(argc, argv, "vhkcs:", while((opt = getopt_long(argc, argv, "vhkc:s",
long_options, NULL)) != -1) long_options, NULL)) != -1)
switch(opt) switch(opt)
{ {
@ -214,12 +214,12 @@ main(int argc, char *argv[])
break; break;
case 'c': case 'c':
if(a_strlen(optarg)) if(a_strlen(optarg))
confpath = optarg; confpath = a_strdup(optarg);
else else
eprint("-c option requires a file name\n"); eprint("-c option requires a file name\n");
break; break;
case 'k': case 'k':
return config_check(confpath); confcheck = True;
break; break;
case 's': case 's':
xsync = True; xsync = True;
@ -229,6 +229,9 @@ main(int argc, char *argv[])
/* Text won't be printed correctly otherwise */ /* Text won't be printed correctly otherwise */
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
if(confcheck)
return config_check(confpath);
/* X stuff */ /* X stuff */
if(!(dpy = XOpenDisplay(NULL))) if(!(dpy = XOpenDisplay(NULL)))
eprint("cannot open display\n"); eprint("cannot open display\n");