[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7206] parsetexi invalid nestings
From: |
gavinsmith0123 |
Subject: |
[7206] parsetexi invalid nestings |
Date: |
Thu, 9 Jun 2016 19:27:50 +0000 (UTC) |
Revision: 7206
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7206
Author: gavin
Date: 2016-06-09 19:27:50 +0000 (Thu, 09 Jun 2016)
Log Message:
-----------
parsetexi invalid nestings
Modified Paths:
--------------
trunk/tp/parsetexi/close.c
trunk/tp/parsetexi/indices.c
trunk/tp/parsetexi/macro.c
trunk/tp/parsetexi/parser.c
Modified: trunk/tp/parsetexi/close.c
===================================================================
--- trunk/tp/parsetexi/close.c 2016-06-07 19:17:15 UTC (rev 7205)
+++ trunk/tp/parsetexi/close.c 2016-06-09 19:27:50 UTC (rev 7206)
@@ -35,7 +35,7 @@
command_name(current->cmd));
else if (interrupting_command)
command_error (current,
- "%s seen before @%s closing brace",
+ "@%s seen before @%s closing brace",
command_name(interrupting_command),
command_name(current->cmd));
else
@@ -273,7 +273,7 @@
}
else if (interrupting_command)
{
- line_error ("`%s' seen before @end %s",
+ line_error ("@%s seen before @end %s",
command_name(interrupting_command),
command_name(current->cmd));
}
Modified: trunk/tp/parsetexi/indices.c
===================================================================
--- trunk/tp/parsetexi/indices.c 2016-06-07 19:17:15 UTC (rev 7205)
+++ trunk/tp/parsetexi/indices.c 2016-06-09 19:27:50 UTC (rev 7206)
@@ -275,7 +275,7 @@
add_extra_index_entry (current, "index_entry", ier);
- if (!current_node && !current_section)
+ if (!current_region () && !current_node && !current_section)
line_warn ("entry for index `%s' outside of any node", idx->name);
}
Modified: trunk/tp/parsetexi/macro.c
===================================================================
--- trunk/tp/parsetexi/macro.c 2016-06-07 19:17:15 UTC (rev 7205)
+++ trunk/tp/parsetexi/macro.c 2016-06-09 19:27:50 UTC (rev 7206)
@@ -141,14 +141,17 @@
/* Disregard trailing whitespace. */
q2 = q;
- while (q2 > q && strchr (whitespace_chars, q2[-1]))
+ while (q2 > args_ptr && strchr (whitespace_chars, q2[-1]))
q2--;
if (q2 == args_ptr)
{
// 1126 - argument is completely whitespace
if (index == 0)
- break; /* Empty arg list, like "@macro m { }". */
+ {
+ args_ptr = q + 1;
+ break; /* Empty arg list, like "@macro m { }". */
+ }
line_error ("bad or empty @%s formal argument:",
command_name(cmd));
}
@@ -185,8 +188,13 @@
}
line = args_ptr;
- /* FIXME: What if there is stuff after the '}'? */
- line += strlen (line); /* Discard rest of line. */
+ line += strspn (line, whitespace_chars);
+ if (*line && *line != '@')
+ {
+ line_error ("bad syntax for @%s argument: %s",
+ command_name(cmd), line);
+ }
+ //line += strlen (line); /* Discard rest of line. */
funexit:
*line_inout = line;
@@ -390,17 +398,27 @@
if (!bs)
{
// error - malformed
+ return;
abort ();
}
*bs = '\0';
pos = lookup_macro_parameter (ptext, macro);
if (pos == -1)
- abort ();
+ {
+ line_error ("\\ in @%s expansion followed `%s' instead of "
+ "parameter name or \\",
+ macro->args.list[0]->text.text,
+ ptext);
+ text_append (expanded, "\\");
+ text_append (expanded, ptext);
+ }
+ else
+ {
+ if (arguments && arguments[pos])
+ text_append (expanded, arguments[pos]);
+ }
*bs = '\\';
-
- if (arguments && arguments[pos])
- text_append (expanded, arguments[pos]);
ptext = bs + 1;
}
}
Modified: trunk/tp/parsetexi/parser.c
===================================================================
--- trunk/tp/parsetexi/parser.c 2016-06-07 19:17:15 UTC (rev 7205)
+++ trunk/tp/parsetexi/parser.c 2016-06-09 19:27:50 UTC (rev 7206)
@@ -695,6 +695,7 @@
}
#define GET_A_NEW_LINE 0
+#define STILL_MORE_TO_PROCESS 1
/* line 3725 */
/* *LINEP is a pointer into the line being processed. It is advanced past any
@@ -1186,15 +1187,15 @@
this happens in the first place. */
add_to_element_contents (current, new_element (ET_NONE));
line++; /* past '}' */
+ retval = STILL_MORE_TO_PROCESS;
}
else
{
line++; /* past '}' */
- input_push_text (strdup (line), 0);
+ input_push_text (strdup (line), line_nr.macro);
input_push_text (strdup (value), 0);
- line = new_line ();
+ retval = GET_A_NEW_LINE;
}
- retval = 1;
goto funexit;
}
else
@@ -1236,14 +1237,25 @@
/* 4233 invalid nestings */
if (current->parent && current->parent->cmd)
{
- int ok = 0;
+ int ok = 0; /* Whether nesting is allowed. */
+
enum command_id outer = current->parent->cmd;
unsigned long outer_flags = command_data(outer).flags;
unsigned long cmd_flags = command_data(cmd).flags;
// much TODO here.
- if (outer_flags & CF_index_entry_command)
+ if (outer_flags & CF_root && current->type != ET_misc_line_arg)
+ ok = 1; // 4242
+ else if (outer_flags & CF_block
+ && current->type != ET_block_line_arg)
+ ok = 1; // 4247
+ else if (outer == CM_item
+ || outer == CM_itemx
+ && current->type != ET_misc_line_arg)
+ ok = 1; // 4252
+
+ else if (outer_flags & CF_index_entry_command)
{
// 563 in_simple_text_commands
if (cmd_flags & (CF_brace | CF_nobrace))
@@ -1262,8 +1274,123 @@
else
ok = 1;
}
+ else if (outer_flags & CF_accent) // 358
+ {
+ if (cmd_flags & (CF_nobrace | CF_accent))
+ ok = 1;
+ else if (cmd_flags & CF_brace
+ && command_data(cmd).data == 0)
+ ok = 1; /* glyph command */
+ if (cmd == CM_c || cmd == CM_comment)
+ ok = 1;
+ }
+ else if ((outer_flags & CF_brace // full text
+ && (command_data(outer).data == BRACE_style
+ || command_data(outer).data == BRACE_inline))
+ || outer == CM_center // full line
+ || outer == CM_exdent
+ || outer == CM_item
+ || outer == CM_itemx
+ || (outer_flags & (CF_sectioning | CF_def))) // full line
+ // no refs
+ {
+ if (cmd_flags & (CF_brace | CF_nobrace)) // 370
+ ok = 1;
+ else if (cmd == CM_c
+ || cmd == CM_comment
+ || cmd == CM_refill
+ || cmd == CM_noindent
+ || cmd == CM_indent
+ || cmd == CM_columnfractions
+ || cmd == CM_set
+ || cmd == CM_clear
+ || cmd == CM_end) // 373
+ ok = 1;
+
+ if (outer == CM_center
+ || outer == CM_exdent
+ || outer == CM_item
+ || outer == CM_itemx) // full line commands 445
+ {
+ /* These are stricter than the "full text" commands
+ about what they contain. */
+ if (cmd == CM_indent || cmd == CM_noindent)
+ ok = 0;
+ }
+ if (outer_flags & (CF_sectioning | CF_def))
+ // full line no refs 420
+ {
+ if (cmd == CM_titlefont
+ || cmd == CM_anchor
+ || cmd == CM_footnote
+ || cmd == CM_verb
+ || cmd == CM_indent || cmd == CM_noindent)
+ ok = 0;
+ }
+ }
+
+ /* 403 "commands that only accept simple text as an argument" */
+ else if ((outer_flags & CF_misc
+ && (command_data(outer).data >= 0
+ || (command_data(outer).data == MISC_line
+ && !(outer_flags & (CF_def | CF_sectioning)))
+ || command_data(outer).data == MISC_text)
+ && outer != CM_center
+ && outer != CM_exdent) // 423
+ || outer == CM_titlefont // 425
+ || outer == CM_anchor
+ || outer == CM_xref
+ || outer == CM_ref
+ || outer == CM_pxref
+ || outer == CM_inforef
+ || outer == CM_shortcaption
+ || outer == CM_math
+ || outer == CM_indicateurl
+ || outer == CM_email
+ || outer == CM_uref
+ || outer == CM_url
+ || outer == CM_image
+ || outer == CM_abbr
+ || outer == CM_acronym
+ || outer == CM_dmn
+ || outer == CM_ctrl
+ || outer == CM_errormsg
+ || (outer_flags & CF_block // 475
+ && !(outer_flags & CF_def)
+ && command_data(outer).data != BLOCK_raw
+ && command_data(outer).data != BLOCK_conditional))
+ {
+ if (cmd_flags & (CF_brace | CF_nobrace)) // 370
+ ok = 1;
+ else if (cmd == CM_c
+ || cmd == CM_comment
+ || cmd == CM_refill
+ || cmd == CM_noindent
+ || cmd == CM_indent
+ || cmd == CM_columnfractions
+ || cmd == CM_set
+ || cmd == CM_clear
+ || cmd == CM_end) // 373
+ ok = 1;
+ if (cmd == CM_titlefont
+ || cmd == CM_anchor
+ || cmd == CM_footnote
+ || cmd == CM_verb
+ || cmd == CM_indent
+ || cmd == CM_noindent) // 397
+ ok = 0;
+
+ if (cmd == CM_xref
+ || cmd == CM_ref
+ || cmd == CM_pxref
+ || cmd == CM_inforef) // 404
+ ok = 0;
+ }
else
{
+ /* Default to valid nesting, for example for commands for which
+ it is not defined which commands can occur within them (e.g.
+ @tab?). */
ok = 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7206] parsetexi invalid nestings,
gavinsmith0123 <=