- added "version" command (patch from John Hartman, thanks)
[openocd.git] / src / server / telnet_server.c
index 3ff3456a3d47d204140c647e4472caf39b089638..a2704e9cc00d05bff96457ca4ca07372d3911275 100644 (file)
@@ -254,28 +254,31 @@ int telnet_input(connection_t *connection)
                                                                        return ERROR_SERVER_REMOTE_CLOSED;
                                                                }
                                                        }
-                                                       
-                                                       /* if the history slot is already taken, free it */
-                                                       if (t_con->history[t_con->next_history])
+
+                                                       /* Save only non-blank lines in the history */
+                                                       if (t_con->line_size > 0)
                                                        {
-                                                               free(t_con->history[t_con->next_history]);
-                                                       }
-                                                       
-                                                       /* add line to history */
-                                                       t_con->history[t_con->next_history++] = strdup(t_con->line);
+                                                               /* if the history slot is already taken, free it */
+                                                               if (t_con->history[t_con->next_history])
+                                                               {
+                                                                       free(t_con->history[t_con->next_history]);
+                                                               }
+               
+                                                               /* add line to history */
+                                                               t_con->history[t_con->next_history] = strdup(t_con->line);
+
+                                                               /* wrap history at TELNET_LINE_HISTORY_SIZE */
+                                                               t_con->next_history = (t_con->next_history + 1) % TELNET_LINE_HISTORY_SIZE;
                                                        
-                                                       /* current history line starts at the new entry */
-                                                       t_con->current_history = t_con->next_history;
+                                                               /* current history line starts at the new entry */
+                                                               t_con->current_history = t_con->next_history;
                                                        
-                                                       if (t_con->history[t_con->current_history])
-                                                       {
-                                                               free(t_con->history[t_con->current_history]);
+                                                               if (t_con->history[t_con->current_history])
+                                                               {
+                                                                       free(t_con->history[t_con->current_history]);
+                                                               }
+                                                               t_con->history[t_con->current_history] = strdup("");
                                                        }
-                                                       t_con->history[t_con->current_history] = strdup("");
-                                                       
-                                                       /* wrap history at TELNET_LINE_HISTORY_SIZE */
-                                                       if (t_con->next_history > TELNET_LINE_HISTORY_SIZE - 1)
-                                                               t_con->next_history = 0;
                                                        
                                                        if (!t_con->suppress_prompt)
                                                        {
@@ -394,7 +397,7 @@ int telnet_input(connection_t *connection)
                                        }
                                        else if (*buf_p == 'A') /* cursor up */
                                        {
-                                               int last_history = (t_con->current_history - 1 >= 0) ? t_con->current_history - 1 : 127;
+                                               int last_history = (t_con->current_history > 0) ? t_con->current_history - 1 : TELNET_LINE_HISTORY_SIZE-1;
                                                if (t_con->history[last_history])
                                                {
                                                        telnet_clear_line(connection, t_con);
@@ -408,7 +411,7 @@ int telnet_input(connection_t *connection)
                                        }
                                        else if (*buf_p == 'B') /* cursor down */
                                        {
-                                               int next_history = (t_con->current_history + 1 < 128) ? t_con->current_history + 1 : 0;
+                                               int next_history = (t_con->current_history + 1) % TELNET_LINE_HISTORY_SIZE;
                                                if (t_con->history[next_history])
                                                {
                                                        telnet_clear_line(connection, t_con);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)