mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 15:10:53 +00:00
Save/restore macros in projects fix #4050
This commit is contained in:
parent
d0f0629655
commit
530dbe72c1
@ -424,6 +424,23 @@ R_API void r_cmd_macro_list(RCmdMacro *mac) {
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: use mac->cb_printf which is r_cons_printf at the end
|
||||
R_API void r_cmd_macro_meta(RCmdMacro *mac) {
|
||||
RCmdMacroItem *m;
|
||||
int j;
|
||||
RListIter *iter;
|
||||
r_list_foreach (mac->macros, iter, m) {
|
||||
mac->cb_printf ("(%s %s, ", m->name, m->args);
|
||||
for (j=0; m->code[j]; j++) {
|
||||
if (m->code[j]=='\n')
|
||||
mac->cb_printf (", ");
|
||||
else mac->cb_printf ("%c", m->code[j]);
|
||||
}
|
||||
mac->cb_printf (")\n");
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
(define name value
|
||||
f $0 @ $1)
|
||||
|
@ -7,7 +7,7 @@ static int cmd_macro(void *data, const char *input) {
|
||||
switch (*input) {
|
||||
case ')': r_cmd_macro_break (&core->rcmd->macro, input+1); break;
|
||||
case '-': r_cmd_macro_rm (&core->rcmd->macro, input+1); break;
|
||||
case '*':
|
||||
case '*': r_cmd_macro_meta (&core->rcmd->macro); break;
|
||||
case '\0': r_cmd_macro_list (&core->rcmd->macro); break;
|
||||
case '(':
|
||||
case '?': {
|
||||
@ -39,7 +39,7 @@ static int cmd_macro(void *data, const char *input) {
|
||||
for (i=0; buf[i]; i++) {
|
||||
switch (buf[i]) {
|
||||
case '(': j++; break;
|
||||
case ')': j--;
|
||||
case ')': j--;
|
||||
if (buf[i+1] =='(') {
|
||||
buf[i+1] = 0;
|
||||
mustcall = i+2;
|
||||
|
@ -330,6 +330,9 @@ R_API int r_core_project_save(RCore *core, const char *file) {
|
||||
r_cons_flush ();
|
||||
r_core_cmd (core, "ah*", 0);
|
||||
r_cons_flush ();
|
||||
r_str_write (fd, "# macros\n");
|
||||
r_core_cmd (core, "(*", 0);
|
||||
r_cons_flush ();
|
||||
r_cons_printf ("# seek\n"
|
||||
"s 0x%08"PFMT64x"\n", core->offset);
|
||||
r_cons_flush ();
|
||||
|
@ -108,6 +108,7 @@ R_API void r_cmd_macro_init(RCmdMacro *mac);
|
||||
R_API int r_cmd_macro_add(RCmdMacro *mac, const char *name);
|
||||
R_API int r_cmd_macro_rm(RCmdMacro *mac, const char *_name);
|
||||
R_API void r_cmd_macro_list(RCmdMacro *mac);
|
||||
R_API void r_cmd_macro_meta(RCmdMacro *mac);
|
||||
R_API int r_cmd_macro_call(RCmdMacro *mac, const char *name);
|
||||
R_API int r_cmd_macro_break(RCmdMacro *mac, const char *value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user