[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8209] parsetexi update
From: |
gavinsmith0123 |
Subject: |
[8209] parsetexi update |
Date: |
Sat, 22 Sep 2018 17:22:42 -0400 (EDT) |
Revision: 8209
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8209
Author: gavin
Date: 2018-09-22 17:22:41 -0400 (Sat, 22 Sep 2018)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/tp/Texinfo/XS/parsetexi/end_line.c
trunk/tp/Texinfo/XS/parsetexi/parser.c
trunk/tp/Texinfo/XS/parsetexi/separator.c
Modified: trunk/tp/Texinfo/XS/parsetexi/end_line.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/end_line.c 2018-09-22 19:37:31 UTC (rev
8208)
+++ trunk/tp/Texinfo/XS/parsetexi/end_line.c 2018-09-22 21:22:41 UTC (rev
8209)
@@ -293,69 +293,30 @@
add_to_element_contents (line_args, E); \
} while (0)
+ ELEMENT *arg = line_command->args.list[0];
ELEMENT *line_args;
- ELEMENT *arg = line_command->args.list[0];
- ELEMENT *argarg = 0;
enum command_id cmd;
char *line;
int i;
- line_args = new_element (ET_NONE);
-
cmd = line_command->cmd;
+ if (arg->contents.number == 0)
+ {
+ command_error (line_command, "@%s missing argument", command_name(cmd));
+ add_extra_integer (line_command, "missing_argument", 1);
+ return 0;
+ }
- /* Find the argument, and check there is only one. */
- i = 0;
- while (i < arg->contents.number)
+ if (arg->contents.number > 1 || arg->contents.list[0]->text.end == 0)
{
- /* Ignore all the elements checked
- in trim_spaces_comment_from_content. */
- enum element_type t;
- t = contents_child_by_index(arg, i)->type;
-
- if (t == ET_empty_spaces_after_command
- || t == ET_empty_spaces_before_argument
- || t == ET_empty_space_at_end_def_bracketed
- || t == ET_empty_spaces_after_close_brace
- || t == ET_spaces_at_end
- || t == ET_space_at_end_block_command
- || t == ET_empty_line_after_command
- || contents_child_by_index(arg, i)->cmd == CM_c
- || contents_child_by_index(arg, i)->cmd == CM_comment)
- {
- i++;
- continue;
- }
- if (!argarg)
- {
- argarg = contents_child_by_index(arg, i);
- i++;
- continue;
- }
- else
- {
- /* Error - too many arguments. */
- line_error ("superfluous argument to @%s",
- command_name (cmd));
- break;
- }
+ line_error ("superfluous argument to @%s", command_name (cmd));
}
+ if (arg->contents.list[0]->text.end == 0)
+ return 0;
- if (!argarg)
- {
- command_error (line_command, "@%s missing argument", command_name(cmd));
- add_extra_integer (line_command, "missing_argument", 1);
- return 0;
- }
- if (argarg->text.end == 0)
- {
- line_error ("superfluous argument to @%s",
- command_name (cmd));
- return 0;
- }
+ line_args = new_element (ET_NONE);
+ line = arg->contents.list[0]->text.text;
- line = argarg->text.text;
-
switch (cmd)
{
case CM_alias:
Modified: trunk/tp/Texinfo/XS/parsetexi/parser.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.c 2018-09-22 19:37:31 UTC (rev
8208)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.c 2018-09-22 21:22:41 UTC (rev
8209)
@@ -482,44 +482,40 @@
last_elt = last_contents_child (current);
char *text = element_text (last_elt);
- if (!text || !*text || last_elt->type)
- return;
- int text_len = strlen (text);
+ int text_len = last_elt->text.end;
/* Does the text end in whitespace? */
- if (strchr (whitespace_chars, text[text_len - 1]))
+
+ /* If text all whitespace */
+ if (text[strspn (text, whitespace_chars)] == '\0')
{
- /* If text all whitespace */
- if (text[strspn (text, whitespace_chars)] == '\0')
- {
- add_extra_string_dup (current, "spaces_after_argument",
- last_elt->text.text);
- pop_element_from_contents (current);
- /* FIXME: destroy_element? */
- }
- else
- {
- int i, trailing_spaces;
- static TEXT t;
+ add_extra_string_dup (current, "spaces_after_argument",
+ last_elt->text.text);
+ pop_element_from_contents (current);
+ /* FIXME: destroy_element? */
+ }
+ else
+ {
+ int i, trailing_spaces;
+ static TEXT t;
- text_reset (&t);
+ text_reset (&t);
- trailing_spaces = 0;
- for (i = strlen (text) - 1;
- i > 0 && strchr (whitespace_chars, text[i]);
- i--)
- trailing_spaces++;
+ trailing_spaces = 0;
+ for (i = strlen (text) - 1;
+ i > 0 && strchr (whitespace_chars, text[i]);
+ i--)
+ trailing_spaces++;
- text_append_n (&t,
- text + text_len - trailing_spaces,
- trailing_spaces);
+ text_append_n (&t,
+ text + text_len - trailing_spaces,
+ trailing_spaces);
- text[text_len - trailing_spaces] = '\0';
- last_elt->text.end -= trailing_spaces;
+ text[text_len - trailing_spaces] = '\0';
+ last_elt->text.end -= trailing_spaces;
- add_extra_string_dup (current, "spaces_after_argument",
- t.text);
- }
+ add_extra_string_dup (current, "spaces_after_argument",
+ t.text);
}
}
@@ -532,38 +528,33 @@
last_elt = last_contents_child (current);
text = element_text (last_elt);
- if (!text || !*text || last_elt->type)
- return;
- text_len = strlen (text);
- /* Does the text end in whitespace? */
- if (strchr (whitespace_chars, text[text_len - 1]))
+ text_len = last_elt->text.end;
+
+ /* If text all whitespace */
+ if (text[strspn (text, whitespace_chars)] == '\0')
{
- /* If text all whitespace */
- if (text[strspn (text, whitespace_chars)] == '\0')
- {
- last_elt->type = ET_space_at_end_menu_node;
- }
- else
- {
- ELEMENT *new_spaces;
- int i, trailing_spaces;
+ last_elt->type = ET_space_at_end_menu_node;
+ }
+ else
+ {
+ ELEMENT *new_spaces;
+ int i, trailing_spaces;
- trailing_spaces = 0;
- for (i = strlen (text) - 1;
- i > 0 && strchr (whitespace_chars, text[i]);
- i--)
- trailing_spaces++;
+ trailing_spaces = 0;
+ for (i = strlen (text) - 1;
+ i > 0 && strchr (whitespace_chars, text[i]);
+ i--)
+ trailing_spaces++;
- new_spaces = new_element (ET_space_at_end_menu_node);
- text_append_n (&new_spaces->text,
- text + text_len - trailing_spaces,
- trailing_spaces);
- text[text_len - trailing_spaces] = '\0';
- last_elt->text.end -= trailing_spaces;
+ new_spaces = new_element (ET_space_at_end_menu_node);
+ text_append_n (&new_spaces->text,
+ text + text_len - trailing_spaces,
+ trailing_spaces);
+ text[text_len - trailing_spaces] = '\0';
+ last_elt->text.end -= trailing_spaces;
- add_to_element_contents (current, new_spaces);
- }
+ add_to_element_contents (current, new_spaces);
}
}
@@ -570,6 +561,10 @@
void
isolate_last_space (ELEMENT *current)
{
+ char *text;
+ ELEMENT *last_elt;
+ int text_len;
+
if (current->contents.number == 0)
return;
@@ -583,6 +578,18 @@
if (current->contents.number == 0)
return;
+ last_elt = last_contents_child (current);
+ text = element_text (last_elt);
+ if (!text || !*text
+ || (last_elt->type && (!current->type
+ || current->type != ET_misc_line_arg)))
+ return;
+
+ text_len = last_elt->text.end;
+ /* Does the text end in whitespace? */
+ if (!strchr (whitespace_chars, text[text_len - 1]))
+ return;
+
if (current->type == ET_menu_entry_node)
isolate_last_space_menu_entry_node (current);
else
Modified: trunk/tp/Texinfo/XS/parsetexi/separator.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/separator.c 2018-09-22 19:37:31 UTC (rev
8208)
+++ trunk/tp/Texinfo/XS/parsetexi/separator.c 2018-09-22 21:22:41 UTC (rev
8209)
@@ -429,7 +429,8 @@
else if (closed_command == CM_errormsg) // 5173
{
char *arg = current->contents.list[0]->text.text;
- line_error (arg);
+ if (arg)
+ line_error (arg);
}
else if (closed_command == CM_U)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8209] parsetexi update,
gavinsmith0123 <=