diff options
author | sabetts <sabetts> | 2002-02-01 09:17:35 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2002-02-01 09:17:35 +0000 |
commit | 5ca712fc606b1839de5bcbe80833fa9d3a17332d (patch) | |
tree | a7daabf975a14649cbbaf4f054508b7ab59cd657 /src/actions.c | |
parent | 7457d9f3ac419123239f0e02fbcdfd0db1013138 (diff) | |
download | ratpoison-5ca712fc606b1839de5bcbe80833fa9d3a17332d.zip |
* src/actions.c (command): bail out if alias recursion gets too deep.
* src/conf.h (MAX_ALIAS_RECURSIVE_DEPTH): new define
* src/bar.c (bar_x): update to work with all X11 gravity values.
(bar_y): likewise
* src/actions.c (cmd_defbargravity): Rename from
cmd_defbarloc. Dependant code updated.
(cmd_defbargravity): accept all gravity arguments.
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/actions.c b/src/actions.c index e0d4188..bbb50b9 100644 --- a/src/actions.c +++ b/src/actions.c @@ -85,7 +85,7 @@ static user_command user_commands[] = /*@end (tag required for genrpbindings) */ /* Commands to set default behavior. */ - {"defbarloc", cmd_defbarloc, arg_STRING}, + {"defbargravity", cmd_defbargravity, arg_STRING}, {"msgwait", cmd_msgwait, arg_STRING}, {"defborder", cmd_defborder, arg_STRING}, {"deffont", cmd_deffont, arg_STRING}, @@ -840,6 +840,8 @@ cmd_version (int interactive, void *data) char * command (int interactive, char *data) { + /* This static counter is used to exit from recursive alias calls. */ + static int alias_recursive_depth = 0; char *result = NULL; char *cmd, *rest; char *input; @@ -894,7 +896,12 @@ command (int interactive, char *data) if (rest != NULL) sbuf_printf_concat (s, " %s", rest); - result = command (interactive, sbuf_get (s)); + alias_recursive_depth++; + if (alias_recursive_depth >= MAX_ALIAS_RECURSIVE_DEPTH) + message (" command: alias recursion has exceeded maximum depth "); + else + result = command (interactive, sbuf_get (s)); + alias_recursive_depth--; sbuf_free (s); goto done; @@ -1695,37 +1702,27 @@ cmd_msgwait (int interactive, void *data) } char * -cmd_defbarloc (int interactive, void *data) +cmd_defbargravity (int interactive, void *data) { - int loc; + int gravity; if (data == NULL && !interactive) return xstrdup (wingravity_to_string (defaults.bar_location)); if (data == NULL) { - message (" defbarloc: One argument required "); + message (" defbargravity: One argument required "); return NULL; } - if ((loc = parse_wingravity (data)) < 0) + if ((gravity = parse_wingravity (data)) < 0) { - message (" defbarloc: Bad location "); + message (" defbargravity: Bad location "); return NULL; } - - switch (loc) + else { - case NorthWestGravity: - case NorthEastGravity: - case SouthWestGravity: - case SouthEastGravity: - defaults.bar_location = loc; - break; - - default: - message (" defbarloc: Bad location "); - break; + defaults.bar_location = gravity; } return NULL; |