X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fserver%2Ftelnet_server.c;fp=src%2Fserver%2Ftelnet_server.c;h=97af3d97f1a7c5172998c95b6bf5ada318a105b4;hp=b01046d9adfe18084422dc069ae15defcaa3328f;hb=391782318723915bd259eadf9469251c13c8fa9c;hpb=08ee7bb982b16742f52cfdc6c649d82ffa2eb177 diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index b01046d9ad..97af3d97f1 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -199,7 +199,7 @@ static void telnet_save_history(struct telnet_connection *t_con) i = t_con->current_history + 1; i %= TELNET_LINE_HISTORY_SIZE; - while (t_con->history[i] == NULL && num > 0) { + while (!t_con->history[i] && num > 0) { i++; i %= TELNET_LINE_HISTORY_SIZE; num--; @@ -640,7 +640,7 @@ static int telnet_input(struct connection *connection) /* save only non-blank not repeating lines in the history */ char *prev_line = t_con->history[(t_con->current_history > 0) ? t_con->current_history - 1 : TELNET_LINE_HISTORY_SIZE-1]; - if (*t_con->line && (prev_line == NULL || + if (*t_con->line && (!prev_line || strcmp(t_con->line, prev_line))) { /* if the history slot is already taken, free it */ free(t_con->history[t_con->next_history]);