* edit-widget.h: Add new field macro_depth to control depth of

macro recursion.
* edit.c (edit_execute_macro): Make static.  Increment
macro_depth on entry, decrement on exit, don't allow it to be
too large.
This commit is contained in:
Pavel Roskin 2002-10-21 02:06:03 +00:00
parent 341c4775c5
commit 63983758e0
3 changed files with 17 additions and 2 deletions

View File

@ -1,5 +1,11 @@
2002-10-20 Pavel Roskin <proski@gnu.org>
* edit-widget.h: Add new field macro_depth to control depth of
macro recursion.
* edit.c (edit_execute_macro): Make static. Increment
macro_depth on entry, decrement on exit, don't allow it to be
too large.
* wordproc.c (line_start): Remove incorrect optimization abusing
static varaibles. Internal formatting should be usable now.

View File

@ -116,6 +116,7 @@ struct editor_widget {
/* macro stuff */
int macro_i; /* -1 if not recording index to macro[] otherwise */
int macro_depth; /* depth of the macro recursion */
struct macro macro[MAX_MACRO_LENGTH];
};

View File

@ -1920,7 +1920,7 @@ static void check_and_wrap_line (WEdit * edit)
}
}
void edit_execute_macro (WEdit * edit, struct macro macro[], int n);
static void edit_execute_macro (WEdit *edit, struct macro macro[], int n);
int edit_translate_key (WEdit * edit, unsigned int x_keycode, long x_key, int x_state, int *cmd, int *ch)
{
@ -2586,14 +2586,22 @@ int edit_execute_command (WEdit * edit, int command, int char_for_insertion)
return r;
}
void edit_execute_macro (WEdit * edit, struct macro macro[], int n)
static void
edit_execute_macro (WEdit *edit, struct macro macro[], int n)
{
int i = 0;
if (edit->macro_depth++ > 256) {
edit_error_dialog (_(" Error "), _("Macro recursion is too deep"));
edit->macro_depth--;
return;
}
edit->force |= REDRAW_PAGE;
for (; i < n; i++) {
edit_execute_cmd (edit, macro[i].command, macro[i].ch);
}
edit_update_screen (edit);
edit->macro_depth--;
}
/* User edit menu, like user menu (F2) but only in editor. */