[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7526] parsetexi more on macros
From: |
gavinsmith0123 |
Subject: |
[7526] parsetexi more on macros |
Date: |
Mon, 21 Nov 2016 09:51:08 +0000 (UTC) |
Revision: 7526
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7526
Author: gavin
Date: 2016-11-21 09:51:08 +0000 (Mon, 21 Nov 2016)
Log Message:
-----------
parsetexi more on macros
Modified Paths:
--------------
trunk/tp/parsetexi/handle_commands.c
trunk/tp/parsetexi/input.c
trunk/tp/parsetexi/input.h
trunk/tp/parsetexi/macro.c
trunk/tp/parsetexi/parser.c
Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c 2016-11-20 21:06:21 UTC (rev
7525)
+++ trunk/tp/parsetexi/handle_commands.c 2016-11-21 09:51:08 UTC (rev
7526)
@@ -132,7 +132,7 @@
ELEMENT **where = 0;
if (cmd == CM_shortcontents)
- cmd == CM_summarycontents;
+ cmd = CM_summarycontents;
if (!current->line_nr.line_nr)
current->line_nr = line_nr;
switch (cmd)
@@ -289,10 +289,17 @@
if (!strchr (line, '\n'))
{
char *line2;
+ LINE_NR save_ln;
+
input_push_text (strdup (line), 0);
+
+ save_ln = line_nr;
line2 = new_line ();
if (line2)
- line = line2;
+ {
+ line = line2;
+ line_nr = save_ln;
+ }
}
misc = new_element (ET_NONE);
Modified: trunk/tp/parsetexi/input.c
===================================================================
--- trunk/tp/parsetexi/input.c 2016-11-20 21:06:21 UTC (rev 7525)
+++ trunk/tp/parsetexi/input.c 2016-11-21 09:51:08 UTC (rev 7526)
@@ -199,6 +199,21 @@
return strdup (t.text);
}
+int
+expanding_macro (char *macro)
+{
+ int i;
+ for (i = 0; i < input_number; i++)
+ {
+ if (input_stack[i].line_nr.macro
+ && !strcmp (input_stack[i].line_nr.macro, macro))
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
+
/* Return value to be freed by caller. Return null if we are out of input. */
char *
next_text (void)
Modified: trunk/tp/parsetexi/input.h
===================================================================
--- trunk/tp/parsetexi/input.h 2016-11-20 21:06:21 UTC (rev 7525)
+++ trunk/tp/parsetexi/input.h 2016-11-21 09:51:08 UTC (rev 7526)
@@ -8,6 +8,7 @@
void input_push_text_with_line_nos (char *text, int starting);
void input_push_file (char *filename);
void input_reset_input_stack (void);
+int expanding_macro (char *macro);
extern LINE_NR line_nr;
Modified: trunk/tp/parsetexi/macro.c
===================================================================
--- trunk/tp/parsetexi/macro.c 2016-11-20 21:06:21 UTC (rev 7525)
+++ trunk/tp/parsetexi/macro.c 2016-11-21 09:51:08 UTC (rev 7526)
@@ -551,6 +551,16 @@
goto funexit;
}
+ if (macro->cmd == CM_macro)
+ {
+ if (expanding_macro (command_name(cmd)))
+ {
+ line_error ("recursive call of macro %s is not allowed; "
+ "use @rmacro if needed", command_name(cmd));
+ goto funexit;
+ }
+ }
+
/* Free arguments. */
if (arguments)
{
Modified: trunk/tp/parsetexi/parser.c
===================================================================
--- trunk/tp/parsetexi/parser.c 2016-11-20 21:06:21 UTC (rev 7525)
+++ trunk/tp/parsetexi/parser.c 2016-11-21 09:51:08 UTC (rev 7526)
@@ -865,6 +865,12 @@
line_error_ext (1, ¯o->element->line_nr,
"here is the previous definition of `%s'", name);
}
+ else if (!(existing & USER_COMMAND_BIT))
+ {
+ line_error_ext (1, ¤t->line_nr,
+ "redefining Texinfo language command: @%s",
+ name);
+ }
}
if (!lookup_extra_key (current, "invalid_syntax"))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7526] parsetexi more on macros,
gavinsmith0123 <=