diff options
Diffstat (limited to 'src/twm.c')
-rw-r--r-- | src/twm.c | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -229,6 +229,20 @@ usage(void) exit(EXIT_FAILURE); } +static Bool +brief_opt(const char *param, const char *option) +{ + size_t have = strlen(++param); + size_t want = strlen(option); + Bool result = False; + + if (have <= want) { + if (!strncmp(param, option, have)) + result = True; + } + return result; +} + /*********************************************************************** * * Procedure: @@ -263,45 +277,53 @@ main(int argc, char *argv[]) printf("%s %s\n", ProgramName, Version); exit(EXIT_SUCCESS); case 'd': /* -display dpy */ - if (strcmp(&argv[i][1], "display")) + if (!brief_opt(argv[i], "display")) usage(); if (++i >= argc) usage(); display_name = argv[i]; continue; case 's': /* -single */ + if (!brief_opt(argv[i], "single")) + usage(); MultiScreen = FALSE; continue; #ifdef XPRINT case 'n': /* -noprint */ - if (strcmp(&argv[i][1], "noprint")) + if (!brief_opt(argv[i], "noprint")) usage(); NoPrintscreens = True; continue; #endif /* XPRINT */ case 'f': /* -file twmrcfilename */ + if (!brief_opt(argv[i], "file")) + usage(); if (++i >= argc) usage(); InitFile = argv[i]; continue; case 'v': /* -verbose */ + if (!brief_opt(argv[i], "verbose")) + usage(); PrintErrorMessages = True; continue; case 'c': /* -clientId */ - if (strcmp(&argv[i][1], "clientId")) + if (!brief_opt(argv[i], "clientId")) usage(); if (++i >= argc) usage(); client_id = argv[i]; continue; case 'r': /* -restore */ - if (strcmp(&argv[i][1], "restore")) + if (!brief_opt(argv[i], "restore")) usage(); if (++i >= argc) usage(); restore_filename = argv[i]; continue; case 'q': /* -quiet */ + if (!brief_opt(argv[i], "quiet")) + usage(); PrintErrorMessages = False; continue; } |