- Fix ."raw cmd" to interpret raw cmd output
  - Fix .cmd~str to interpret grepped output
* r_cons
  - Add r_cons_filter() to apply cons filters (grep, html...)
* Update TODO
This commit is contained in:
Nibble 2010-08-17 01:27:24 +02:00
parent 1fa134ca4f
commit f41acb4729
3 changed files with 17 additions and 5 deletions

View File

@ -168,10 +168,19 @@ R_API const char *r_cons_get_buffer() {
return I.buffer;
}
R_API void r_cons_filter() {
/* grep*/
if (I.grep.nstrings>0||I.grep.tokenfrom!=0||I.grep.tokento!=ST32_MAX||I.grep.line!=-1)
r_cons_grepbuf (I.buffer, I.buffer_len);
/* html */
/* TODO */
}
R_API void r_cons_flush() {
const char *tee = I.teefile;
if (I.noflush)
return;
r_cons_filter ();
if (I.is_interactive) {
if (I.buffer_len > CONS_MAX_USER) {
if (!r_cons_yesno ('n',"Do you want to print %d bytes? (y/N)",
@ -181,9 +190,6 @@ R_API void r_cons_flush() {
}
}
}
if (I.grep.nstrings>0||I.grep.tokenfrom!=0||I.grep.tokento!=ST32_MAX||I.grep.line!=-1)
r_cons_grepbuf (I.buffer, I.buffer_len);
if (tee&&tee[0]) {
FILE *d = fopen (tee, "a+");
if (d != NULL) {

View File

@ -2724,6 +2724,10 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
cmd = r_str_trim_head_tail (cmd);
/* quoted / raw command */
if (cmd[0] =='.' && cmd[1] == '"') {
ret = r_cmd_call (core->cmd, cmd);
return ret;
}
if (cmd[0] =='"') {
if (cmd[len-1] != '"') {
eprintf ("parse: Missing ending '\"'\n");
@ -3573,9 +3577,10 @@ R_API char *r_core_cmd_str(RCore *core, const char *cmd) {
eprintf ("Invalid command: %s\n", cmd);
retstr = strdup ("");
} else {
const char *static_str = r_cons_get_buffer();
r_cons_filter ();
const char *static_str = r_cons_get_buffer ();
retstr = strdup (static_str?static_str:"");
r_cons_reset();
r_cons_reset ();
}
return retstr;
}

View File

@ -173,6 +173,7 @@ R_API void r_cons_printf(const char *format, ...);
R_API void r_cons_strcat(const char *str);
R_API void r_cons_memcat(const char *str, int len);
R_API void r_cons_newline();
R_API void r_cons_filter();
R_API void r_cons_flush();
R_API void r_cons_visual_flush();
R_API void r_cons_visual_write (char *buffer);