From 7e0023389f81cc84cf5337f19b5e14a414763f73 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Tue, 10 Apr 2012 17:42:57 +0200 Subject: [PATCH] Allow also to save invalid commands. --- main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index c8fe5cb..c4a2e7c 100644 --- a/main.c +++ b/main.c @@ -1978,7 +1978,7 @@ process_set_line(char *line) { gboolean process_line(char *line) { - char *c = line; + char *c = line, *command_hist; int i; size_t len, length = strlen(line); gboolean found = FALSE, success = FALSE; @@ -1989,13 +1989,14 @@ process_line(char *line) { /* Ignore blank lines. */ if (c[0] == '\0') return TRUE; + + command_hist = g_strdup(c); for (i = 0; i < LENGTH(commands); i++) { if (commands[i].cmd == NULL) break; len = strlen(commands[i].cmd); if (length >= len && !strncmp(c, commands[i].cmd, len) && (c[len] == ' ' || !c[len])) { found = TRUE; - save_command_history(c); a.i = commands[i].arg.i; a.s = g_strdup(length > len + 1 ? &c[len + 1] : commands[i].arg.s); success = commands[i].func(&a); @@ -2003,6 +2004,10 @@ process_line(char *line) { break; } } + + save_command_history(command_hist); + g_free(command_hist); + if (!found) { a.i = Error; a.s = g_strdup_printf("Not a browser command: %s", c); -- 2.11.4.GIT