[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7165] parsetexi update
From: |
gavinsmith0123 |
Subject: |
[7165] parsetexi update |
Date: |
Sat, 14 May 2016 11:22:41 +0000 (UTC) |
Revision: 7165
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7165
Author: gavin
Date: 2016-05-14 11:22:40 +0000 (Sat, 14 May 2016)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/tp/parsetexi/api.c
trunk/tp/parsetexi/end_line.c
trunk/tp/parsetexi/handle_commands.c
trunk/tp/parsetexi/macro.c
trunk/tp/parsetexi/parser.c
Modified: trunk/tp/parsetexi/api.c
===================================================================
--- trunk/tp/parsetexi/api.c 2016-05-14 09:59:15 UTC (rev 7164)
+++ trunk/tp/parsetexi/api.c 2016-05-14 11:22:40 UTC (rev 7165)
@@ -63,7 +63,7 @@
void
parse_file (char *filename)
{
- debug_output = 0;
+ debug_output = 1;
parse_texi_file (filename);
}
Modified: trunk/tp/parsetexi/end_line.c
===================================================================
--- trunk/tp/parsetexi/end_line.c 2016-05-14 09:59:15 UTC (rev 7164)
+++ trunk/tp/parsetexi/end_line.c 2016-05-14 11:22:40 UTC (rev 7165)
@@ -80,7 +80,7 @@
} while (0)
ELEMENT *args = new_element (ET_NONE);
- char *p, *q;
+ char *p, *q, *r;
char *value;
switch (cmd)
@@ -139,7 +139,31 @@
break;
}
case CM_clear:
+ {
+ char *flag;
+ p = line;
+ p += strspn (p, whitespace_chars);
+ if (!*p)
+ goto clear_no_name;
+ q = p;
+ flag = read_command_name (&q);
+ if (!flag)
+ goto clear_invalid;
+ r = q + strspn (q, whitespace_chars);
+ if (*r)
+ goto clear_invalid; /* Trailing argument. */
+
+ ADD_ARG (p, q - p);
+ clear_value (p, q - p);
+
break;
+clear_no_name:
+ line_error ("@clear requires a name");
+ break;
+clear_invalid:
+ line_error ("bad name for @clear");
+ break;
+ }
case CM_unmacro:
p = line;
p += strspn (p, whitespace_chars);
Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c 2016-05-14 09:59:15 UTC (rev
7164)
+++ trunk/tp/parsetexi/handle_commands.c 2016-05-14 11:22:40 UTC (rev
7165)
@@ -817,8 +817,6 @@
if (cmd == CM_ifcommandnotdefined)
iftrue = !iftrue;
}
- debug ("CONDITIONAL @%s %s: %d", command_name(cmd), flag,
- iftrue);
}
else if (0)
{
@@ -857,7 +855,7 @@
// open a new element (which we shall later remove, in
// process_remaining_on_line ("CLOSED conditional").
- debug ("CONDITIONAL %s", command_name(cmd));
+ debug ("CONDITIONAL %s %d", command_name(cmd), iftrue);
if (iftrue)
push_conditional_stack (cmd);
else
Modified: trunk/tp/parsetexi/macro.c
===================================================================
--- trunk/tp/parsetexi/macro.c 2016-05-14 09:59:15 UTC (rev 7164)
+++ trunk/tp/parsetexi/macro.c 2016-05-14 11:22:40 UTC (rev 7165)
@@ -524,15 +524,50 @@
void
store_value (char *name, char *value)
{
- if (value_number == value_space)
+ int i;
+ VALUE *v = 0;
+ int len;
+
+ len = strlen (name);
+
+ /* Check if already defined. */
+ for (i = 0; i < value_number; i++)
{
- value_list = realloc (value_list, (value_space += 5) * sizeof (VALUE));
+ if (!memcmp (value_list[i].name, name, len) && !value_list[i].name[len])
+ {
+ v = &value_list[i];
+ free (v->name); free (v->value);
+ break;
+ }
}
- value_list[value_number].name = strdup (name);
- value_list[value_number++].value = strdup (value);
+
+ if (!v)
+ {
+ if (value_number == value_space)
+ {
+ value_list = realloc (value_list, (value_space += 5) * sizeof
(VALUE));
+ }
+ v = &value_list[value_number++];
+ }
+
+ v->name = strdup (name);
+ v->value = strdup (value);
}
-/* TODO: What if it is already defined? */
+void
+clear_value (char *name, int len)
+{
+ int i;
+ for (i = 0; i < value_number; i++)
+ {
+ if (!memcmp (value_list[i].name, name, len) && !value_list[i].name[len])
+ {
+ value_list[i].name[0] = '\0';
+ value_list[i].value[0] = '\0';
+ }
+ }
+}
+
char *
fetch_value (char *name, int len)
{
Modified: trunk/tp/parsetexi/parser.c
===================================================================
--- trunk/tp/parsetexi/parser.c 2016-05-14 09:59:15 UTC (rev 7164)
+++ trunk/tp/parsetexi/parser.c 2016-05-14 11:22:40 UTC (rev 7165)
@@ -721,10 +721,11 @@
ELEMENT *e;
char *p = line;
p += strspn (p, whitespace_chars);
- if (!strncmp (p, command_name(current->cmd),
- strlen (command_name(current->cmd))))
+ if (*p == '@'
+ && !strncmp (p + 1, command_name(current->cmd),
+ strlen (command_name(current->cmd))))
{
- line = p;
+ line = p + 1;
p += strlen (command_name(current->cmd));
e = new_element (ET_NONE);
e->cmd = current->cmd;
@@ -877,9 +878,12 @@
if (q)
{
/* Save up to the delimiter character. */
- ELEMENT *e = new_element (ET_raw);
- text_append_n (&e->text, line, q - line);
- add_to_element_contents (current, e);
+ if (q != line)
+ {
+ ELEMENT *e = new_element (ET_raw);
+ text_append_n (&e->text, line, q - line);
+ add_to_element_contents (current, e);
+ }
line = q + 1;
debug ("END VERB");
/* The '}' will close the @verb command in handle_separator below. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7165] parsetexi update,
gavinsmith0123 <=