diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | xmodmap.c | 38 |
2 files changed, 28 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac index c84299a..bbd9e94 100644 --- a/configure.ac +++ b/configure.ac @@ -44,7 +44,7 @@ XORG_DEFAULT_OPTIONS AC_CHECK_FUNCS([strncasecmp asprintf]) # Checks for pkg-config packages -PKG_CHECK_MODULES(XMODMAP, x11 xproto >= 7.0.17) +PKG_CHECK_MODULES(XMODMAP, [x11 xproto >= 7.0.25]) dnl Allow checking code with lint, sparse, etc. XORG_WITH_LINT @@ -121,8 +121,8 @@ static const char help_message[] = "\n"; -static void -_X_NORETURN +static void +_X_NORETURN _X_COLD usage(int exitcode) { fprintf (stderr, "usage: %s [-options ...] [filename]\n", ProgramName); @@ -130,6 +130,22 @@ usage(int exitcode) Exit (exitcode); } +static void +_X_NORETURN _X_COLD +missing_arg(const char *arg) +{ + fprintf (stderr, "%s: %s requires an argument\n\n", ProgramName, arg); + usage(1); +} + +static void +_X_NORETURN _X_COLD +unknown_arg(const char *arg) +{ + fprintf (stderr, "%s: unrecognized argument %s\n\n", ProgramName, arg); + usage(1); +} + static const char grammar_message[] = " pointer = default reset pointer buttons to default\n" " pointer = NUMBER ... set pointer button codes\n" @@ -187,7 +203,7 @@ main(int argc, char *argv[]) if (arg[0] == '-') { switch (arg[1]) { case 'd': /* -display host:dpy */ - if (++i >= argc) usage (1); + if (++i >= argc) missing_arg(arg); displayname = argv[i]; break; case 'g': /* -grammar */ @@ -240,7 +256,7 @@ main(int argc, char *argv[]) continue; case 'e': /* -e expression */ didAnything = True; - if (++i >= argc) usage (1); + if (++i >= argc) missing_arg(arg); process_line (argv[i]); continue; case 'p': /* -p... */ @@ -258,14 +274,14 @@ main(int argc, char *argv[]) printKeyTableExprs = True; break; default: - usage (1); + unknown_arg(arg); } break; case 'p': /* -pp */ printPointerMap = True; break; default: - usage (1); + unknown_arg(arg); /* NOTREACHED */ } didAnything = True; @@ -308,7 +324,7 @@ main(int argc, char *argv[]) case 'c': { char *cmd; didAnything = True; - if (++i >= argc) usage (1); + if (++i >= argc) missing_arg(arg); if (asprintf (&cmd, "remove %s = %s", ((arg[1] == 's') ? "shift" : ((arg[1] == 'l') ? "lock" : @@ -318,7 +334,7 @@ main(int argc, char *argv[]) continue; } default: - usage (1); + unknown_arg(arg); /*NOTREACHED*/ } } else if (arg[0] == '+') { /* old xmodmap args */ @@ -330,7 +346,7 @@ main(int argc, char *argv[]) case '5': { char *cmd; didAnything = True; - if (++i >= argc) usage (1); + if (++i >= argc) missing_arg(arg); if (asprintf (&cmd, "add mod%c = %s", arg[1], argv[i]) == -1) FatalError("Could not allocate memory for add cmd"); process_line (cmd); @@ -346,7 +362,7 @@ main(int argc, char *argv[]) case 'c': { char *cmd; didAnything = True; - if (++i >= argc) usage (1); + if (++i >= argc) missing_arg(arg); if (asprintf (&cmd, "add %s = %s", ((arg[1] == 's') ? "shift" : ((arg[1] == 'l') ? "lock" : @@ -356,7 +372,7 @@ main(int argc, char *argv[]) continue; } default: - usage (1); + unknown_arg(arg); } } else { didAnything = True; |