diff options
author | sabetts <sabetts> | 2001-09-09 09:38:42 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2001-09-09 09:38:42 +0000 |
commit | 3cf42573ad5487e6895cc4d0f1f2b0acbfa77894 (patch) | |
tree | 2c7b77fde66bc0b855a231dd24b67cf338464d1d /src/actions.c | |
parent | b96d97252175a842fdd144e1660093577a5ab8bc (diff) | |
download | ratpoison-3cf42573ad5487e6895cc4d0f1f2b0acbfa77894.zip |
(cmd_defbartimeout): merge the 2 ifs.
(cmd_defbartimeout): verify that the number is positive.
(cmd_defborder): likewise
(cmd_defwinname): gobble leading whitespace. Use strings as
arguments, not numbers.
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/src/actions.c b/src/actions.c index 1d3509e..857bc9e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1006,7 +1006,7 @@ cmd_windows (int interactive, void *data) else { window_list = sbuf_new (0); - get_window_list (defaults.window_fmt, "\n", window_list, &dummy, &dummy); + get_window_list ((char *)data, "\n", window_list, &dummy, &dummy); tmp = sbuf_get (window_list); free (window_list); @@ -1439,13 +1439,19 @@ cmd_defmaxsizepos (int interactive, void *data) char * cmd_defbartimeout (int interactive, void *data) { - if (data == NULL) return NULL; + int tmp; - if (sscanf (data, "%d", &defaults.bar_timeout) < 1) + if (data == NULL + || sscanf (data, "%d", &tmp) < 1) { message (" defbartimeout: One argument required "); } + if (tmp >= 0) + defaults.bar_timeout = tmp; + else + message (" defbartimeout: Bad argument "); + return NULL; } @@ -1572,15 +1578,24 @@ cmd_defpadding (int interactive, void *data) char * cmd_defborder (int interactive, void *data) { + int tmp; rp_window *win; if (data == NULL) return NULL; - if (sscanf (data, "%d", &defaults.window_border_width) < 1) + if (sscanf (data, "%d", &tmp) < 1) { message (" defborder: One argument required "); } + if (tmp >= 0) + defaults.window_border_width = tmp; + else + { + message (" defborder: Bad argument "); + return NULL; + } + /* Update all the visible windows. */ for (win = rp_mapped_window_sentinel->next; win != rp_mapped_window_sentinel; @@ -1620,7 +1635,8 @@ cmd_defwaitcursor (int interactive, void *data) char * cmd_defwinfmt (int interactive, void *data) { - if (data == NULL) return NULL; + if (data == NULL) + return NULL; free (defaults.window_fmt); defaults.window_fmt = strdup (data); @@ -1637,11 +1653,29 @@ cmd_defwinfmt (int interactive, void *data) char * cmd_defwinname (int interactive, void *data) { - if (data == NULL - || sscanf (data, "%d", &defaults.win_name) < 1) + char *name; + + if (data == NULL) { message (" defwinname: One argument required "); + return NULL; } + /* Gobble whitespace */ + name = (char *)data; + while (*name == ' ') + name++; + + /* FIXME: Using strncmp is sorta dirty since `title' and + `titlefoobar' would both match. But its quick and dirty. */ + if (!strncmp (name, "title", 5)) + defaults.win_name = 0; + else if (!strncmp (name, "name", 4)) + defaults.win_name = 1; + else if (!strncmp (name, "class", 5)) + defaults.win_name = 2; + else + message (" defwinname: Bad argument "); + return NULL; } |