Javier Segura <[email protected]> escribió:
> Hi all,
>
> this small patch adds support for load/save history on radare2. Also
> fixes dietline.c to make use of r_util.
>
> first path, so don't be mad with me!!
Hi,
I have just fixed a pair o bugs in readline/core regarding histoy, I
attach a diff with the most relevant changes.
So, pull the last r2 tip ;)
enjoy!
diff -r c26f57fbdb5d -r f000dda8fabe libr/core/cmd.c
--- a/libr/core/cmd.c Wed Apr 01 00:51:02 2009 +0000
+++ b/libr/core/cmd.c Thu Apr 02 15:15:16 2009 +0200
@@ -1314,8 +1379,7 @@
if (cmd[0])
fprintf(stderr, "Invalid command: '%s'\n", command);
ret = 1;
- } else
- if (log) r_line_hist_add(command);
+ }
}
if (log) r_line_hist_add(command);
if (restoreseek)
diff -r c26f57fbdb5d -r f000dda8fabe libr/line/dietline.c
--- a/libr/line/dietline.c Wed Apr 01 00:51:02 2009 +0000
+++ b/libr/line/dietline.c Thu Apr 02 15:15:16 2009 +0200
@@ -31,6 +31,7 @@
char **r_line_history = NULL;
int r_line_histsize = R_LINE_HISTSIZE;
int r_line_histidx = 0;
+int r_line_histtop = 0;
int r_line_autosave = 0; // TODO
int r_line_disable = 0; // TODO use fgets..no autocompletion
@@ -170,22 +172,23 @@
return 1;
}
R_API int r_line_hist_add(const char *line)
{
#if HAVE_LIB_READLINE
add_history(line);
#endif
- if (r_line_histidx>=r_line_histsize)
- r_line_histidx = 0; // workaround
+ if (r_line_histtop>=r_line_histsize)
+ r_line_histtop = r_line_histidx = 0; // workaround
if (*line) { // && r_line_histidx < r_line_histsize) {
- r_line_history[r_line_histidx++] = strdup(line);
+ r_line_history[r_line_histtop++] = strdup(line);
+ r_line_histidx = r_line_histtop;
return 1;
}
return 0;
//#endif
}
_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org