Commits

Anonymous committed 5351121

Allow also to save invalid commands.

committer: Hannes Schueller <hannes@yllr.net>

  • Participants
  • Parent commits 9e45c04

Comments (0)

Files changed (1)

 
 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;
     /* 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);
             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);