fixing arg handling in dmenu (thanks to Sander for his report)

This commit is contained in:
Anselm R. Garbe 2006-10-23 10:12:09 +02:00
parent bb480fb4b0
commit f633276774
2 changed files with 19 additions and 13 deletions

View File

@ -1,5 +1,5 @@
# dmenu version # dmenu version
VERSION = 1.3 VERSION = 1.4
# Customize below to fit your system # Customize below to fit your system

30
main.c
View File

@ -286,18 +286,24 @@ main(int argc, char *argv[]) {
timeout.tv_sec = 3; timeout.tv_sec = 3;
/* command line args */ /* command line args */
for(i = 1; i < argc; i++) for(i = 1; i < argc; i++)
if(!strncmp(argv[i], "-font", 6)) if(!strncmp(argv[i], "-font", 6)) {
font = argv[++i]; if(++i < argc) font = argv[i];
else if(!strncmp(argv[i], "-normbg", 8)) }
normbg = argv[++i]; else if(!strncmp(argv[i], "-normbg", 8)) {
else if(!strncmp(argv[i], "-normfg", 8)) if(++i < argc) normbg = argv[i];
normfg = argv[++i]; }
else if(!strncmp(argv[i], "-selbg", 7)) else if(!strncmp(argv[i], "-normfg", 8)) {
selbg = argv[++i]; if(++i < argc) normfg = argv[i];
else if(!strncmp(argv[i], "-selfg", 7)) }
selfg = argv[++i]; else if(!strncmp(argv[i], "-selbg", 7)) {
else if(!strncmp(argv[i], "-t", 3)) if(++i < argc) selbg = argv[i];
timeout.tv_sec = atoi(argv[++i]); }
else if(!strncmp(argv[i], "-selfg", 7)) {
if(++i < argc) selfg = argv[i];
}
else if(!strncmp(argv[i], "-t", 3)) {
if(++i < argc) timeout.tv_sec = atoi(argv[i]);
}
else if(!strncmp(argv[i], "-v", 3)) { else if(!strncmp(argv[i], "-v", 3)) {
fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);