summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2006-06-25 11:14:44 +0000
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2006-06-25 11:14:44 +0000
commitdb0264db2af7c86959aeb821504c9dcd72134425 (patch)
tree044b12dab42fddf21229d26e408b0273ac27b9e2 /src/server
parentef139a3a5e41fbcbabdf4be0ecbbb5591448ad2e (diff)
downloadopenocd+libswd-db0264db2af7c86959aeb821504c9dcd72134425.tar.gz
openocd+libswd-db0264db2af7c86959aeb821504c9dcd72134425.tar.bz2
openocd+libswd-db0264db2af7c86959aeb821504c9dcd72134425.tar.xz
openocd+libswd-db0264db2af7c86959aeb821504c9dcd72134425.zip
- added "version" command (patch from John Hartman, thanks)
- fixed bug in telnet history handling (patch from John Hartman, thanks) - OpenOCD version has been changed from SVN revision number to date/time git-svn-id: svn://svn.berlios.de/openocd/trunk@74 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/server')
-rw-r--r--src/server/telnet_server.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index 3ff3456a..a2704e9c 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -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);