summaryrefslogtreecommitdiff
path: root/xmodmap.c
diff options
context:
space:
mode:
authorDeron Johnson <deron.johnson@sun.com>2005-02-18 17:37:21 +0000
committerDeron Johnson <deron.johnson@sun.com>2005-02-18 17:37:21 +0000
commit3141892679138098bd82a7258d8e335dff9032f9 (patch)
treef4720aa801c51cd06d4d476bdeebd85e70db743b /xmodmap.c
parent8ad5d3b908d68353d407fa8f678c93320760eb12 (diff)
Diffstat (limited to 'xmodmap.c')
-rw-r--r--xmodmap.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/xmodmap.c b/xmodmap.c
index a67493f..c59f07b 100644
--- a/xmodmap.c
+++ b/xmodmap.c
@@ -51,6 +51,16 @@ Exit(int status)
exit (status);
}
+void *
+chk_malloc(size_t n_bytes)
+{
+ void *buf = malloc(n_bytes);
+ if (!buf) {
+ fprintf(stderr, "%s: Could not allocate %d bytes\n", ProgramName, (int)n_bytes);
+ Exit(-1);
+ }
+ return buf;
+}
static char *help_message[] = {
"\nwhere options include:",
@@ -244,9 +254,10 @@ main(int argc, char *argv[])
case 's':
case 'l':
case 'c': {
- char cmd[80]; /* big enough to hold line */
+ char *cmd;
didAnything = True;
if (++i >= argc) usage ();
+ cmd = chk_malloc (strlen ("remove control = ") + strlen (argv[i]) + 1);
(void) sprintf (cmd, "remove %s = %s",
((arg[1] == 's') ? "shift" :
((arg[1] == 'l') ? "lock" :
@@ -265,10 +276,10 @@ main(int argc, char *argv[])
case '3':
case '4':
case '5': {
- char cmd[80]; /* big enough to hold line */
+ char *cmd;
didAnything = True;
if (++i >= argc) usage ();
-
+ cmd = chk_malloc (strlen ("add modX = ") + strlen (argv[i]) + 1);
(void) sprintf (cmd, "add mod%c = %s", arg[1], argv[i]);
process_line (cmd);
continue;
@@ -281,9 +292,10 @@ main(int argc, char *argv[])
case 's':
case 'l':
case 'c': {
- char cmd[80]; /* big enough to hold line */
+ char *cmd;
didAnything = True;
if (++i >= argc) usage ();
+ cmd = chk_malloc (strlen ("add control = ") + strlen (argv[i]) + 1);
(void) sprintf (cmd, "add %s = %s",
((arg[1] == 's') ? "shift" :
((arg[1] == 'l') ? "lock" :