Skip to content

Commit

Permalink
Fix history up issue reported by @jduck
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed May 14, 2017
1 parent 9c356a9 commit 2b4ef99
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libr/cons/dietline.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,26 @@ static int r_line_readchar() {
}

R_API int r_line_hist_add(const char *line) {
if (!line || !*line) {
return false;
}
if (!I.history.data) {
inithist ();
}
/* ignore dup */
if (I.history.index != I.history.top) {
if (I.history.index + 1 != I.history.top) {
I.history.data[I.history.top++] = strdup (line);
}
I.history.index = I.history.top;
return true;
}
if (I.history.top > 0) {
const char *data = I.history.data[I.history.top - 1];
if (data && !strcmp (line, data)) {
return false;
}
}
if (!line || !*line) {
return false;
}
if (I.history.top == I.history.size) {
int i;
free (I.history.data[0]);
Expand Down

0 comments on commit 2b4ef99

Please sign in to comment.