[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7164] parsetexi update
From: |
gavinsmith0123 |
Subject: |
[7164] parsetexi update |
Date: |
Sat, 14 May 2016 09:59:15 +0000 (UTC) |
Revision: 7164
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7164
Author: gavin
Date: 2016-05-14 09:59:15 +0000 (Sat, 14 May 2016)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/tp/parsetexi/Parsetexi.pm
trunk/tp/parsetexi/Parsetexi.xs
trunk/tp/parsetexi/api.c
trunk/tp/parsetexi/end_line.c
trunk/tp/parsetexi/handle_commands.c
trunk/tp/parsetexi/handle_commands.h
trunk/tp/parsetexi/macro.c
Modified: trunk/tp/parsetexi/Parsetexi.pm
===================================================================
--- trunk/tp/parsetexi/Parsetexi.pm 2016-05-13 20:13:38 UTC (rev 7163)
+++ trunk/tp/parsetexi/Parsetexi.pm 2016-05-14 09:59:15 UTC (rev 7164)
@@ -167,6 +167,12 @@
store_value ($v, "<<UNKNOWN VALUE>>");
}
}
+ } elsif ($key eq 'expanded_formats') {
+ clear_expanded_formats ();
+
+ for my $f (@{$parser->{$key}}) {
+ add_expanded_format ($f);
+ }
} else {
#warn "ignoring parser configuration value \"$key\"\n";
}
Modified: trunk/tp/parsetexi/Parsetexi.xs
===================================================================
--- trunk/tp/parsetexi/Parsetexi.xs 2016-05-13 20:13:38 UTC (rev 7163)
+++ trunk/tp/parsetexi/Parsetexi.xs 2016-05-14 09:59:15 UTC (rev 7164)
@@ -119,3 +119,10 @@
void
reset_parser ()
+void
+clear_expanded_formats ()
+
+void
+add_expanded_format (format)
+ char *format
+
Modified: trunk/tp/parsetexi/api.c
===================================================================
--- trunk/tp/parsetexi/api.c 2016-05-13 20:13:38 UTC (rev 7163)
+++ trunk/tp/parsetexi/api.c 2016-05-14 09:59:15 UTC (rev 7164)
@@ -46,10 +46,16 @@
reset_parser (void)
{
wipe_user_commands ();
+ wipe_values ();
+ wipe_macros ();
init_index_commands ();
wipe_errors ();
reset_context_stack ();
reset_floats ();
+ clear_expanded_formats ();
+ add_expanded_format ("plaintext");
+ add_expanded_format ("info");
+
current_node = current_section = 0;
}
@@ -58,7 +64,6 @@
parse_file (char *filename)
{
debug_output = 0;
- reset_parser ();
parse_texi_file (filename);
}
@@ -74,7 +79,6 @@
parse_string (char *string)
{
ELEMENT *root;
- reset_parser ();
root = new_element (ET_root_line);
input_push_text (strdup (string), 0);
Root = parse_texi (root);
@@ -85,7 +89,6 @@
parse_text (char *string)
{
ELEMENT *root;
- reset_parser ();
root = new_element (ET_text_root);
input_push_text_with_line_nos (strdup (string), 1);
Root = parse_texi (root);
@@ -396,7 +399,12 @@
newSVpv (f->contents.list[j]->text.text,
f->contents.list[j]->text.end));
}
- /* else an error? */
+ else
+ {
+ /* Empty strings permitted. */
+ av_push (av,
+ newSVpv ("", 0));
+ }
}
break;
}
Modified: trunk/tp/parsetexi/end_line.c
===================================================================
--- trunk/tp/parsetexi/end_line.c 2016-05-13 20:13:38 UTC (rev 7163)
+++ trunk/tp/parsetexi/end_line.c 2016-05-14 09:59:15 UTC (rev 7164)
@@ -661,7 +661,8 @@
ADD_ARG(line);
}
else
- line_error ("expected @%s on or off, not `%s'", line);
+ line_error ("expected @%s on or off, not `%s'",
+ command_name(cmd), line);
break;
}
Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c 2016-05-13 20:13:38 UTC (rev
7163)
+++ trunk/tp/parsetexi/handle_commands.c 2016-05-14 09:59:15 UTC (rev
7164)
@@ -698,6 +698,48 @@
/* then adjust according to raise-/lowersections. */
}
+ /* TODO: Allow user to change which formats are true. */
+struct expanded_format {
+ char *format;
+ int expandedp;
+};
+static struct expanded_format expanded_formats[] = {
+ "html", 0,
+ "docbook", 0,
+ "plaintext", 1,
+ "tex", 0,
+ "xml", 0,
+ "info", 1,
+};
+
+void
+clear_expanded_formats (void)
+{
+ int i;
+ for (i = 0; i < sizeof (expanded_formats)/sizeof (*expanded_formats);
+ i++)
+ {
+ expanded_formats[i].expandedp = 0;
+ }
+}
+
+void
+add_expanded_format (char *format)
+{
+ int i;
+ for (i = 0; i < sizeof (expanded_formats)/sizeof (*expanded_formats);
+ i++)
+ {
+ if (!strcmp (format, expanded_formats[i].format))
+ {
+ expanded_formats[i].expandedp = 1;
+ break;
+ }
+ }
+ if (!strcmp (format, "plaintext"))
+ add_expanded_format ("info");
+}
+
/* line 4632 */
/* A command name has been read that starts a multiline block, which should
end in @end <command name>. The block will be processed until
@@ -792,20 +834,6 @@
/* Handle @if* and @ifnot* */
/* FIXME: Check @if and @ifnot* a nicer way, without memcmp. */
- struct expanded_format {
- char *format;
- int expandedp;
- };
- static struct expanded_format expanded_formats[] = {
- "html", 0,
- "docbook", 0,
- "plaintext", 1,
- "tex", 0,
- "xml", 0,
- "info", 1,
- };
- /* TODO: Allow user to change which formats are true. */
-
p = command_name(cmd) + 2; /* After "if". */
if (!memcmp (p, "not", 3))
p += 3; /* After "not". */
Modified: trunk/tp/parsetexi/handle_commands.h
===================================================================
--- trunk/tp/parsetexi/handle_commands.h 2016-05-13 20:13:38 UTC (rev
7163)
+++ trunk/tp/parsetexi/handle_commands.h 2016-05-14 09:59:15 UTC (rev
7164)
@@ -7,3 +7,6 @@
enum command_id cmd_id);
int check_no_text (ELEMENT *current);
int register_global_command (enum command_id cmd, ELEMENT *current);
+
+void clear_expanded_formats (void);
+void add_expanded_format (char *format);
Modified: trunk/tp/parsetexi/macro.c
===================================================================
--- trunk/tp/parsetexi/macro.c 2016-05-13 20:13:38 UTC (rev 7163)
+++ trunk/tp/parsetexi/macro.c 2016-05-14 09:59:15 UTC (rev 7164)
@@ -38,26 +38,37 @@
/* Macro definition. */
+static MACRO *lookup_macro (enum command_id cmd);
+
void
new_macro (char *name, ELEMENT *macro)
{
enum command_id new;
+ MACRO *m = 0;
- if (macro_number == macro_space)
+ /* Check for an existing definition first for us to overwrite. */
+ new = lookup_command (name);
+ if (new)
+ m = lookup_macro (new);
+ if (!m)
{
- macro_list = realloc (macro_list, (macro_space += 5) * sizeof (MACRO));
- if (!macro_list)
- abort ();
+ if (macro_number == macro_space)
+ {
+ macro_list = realloc (macro_list,
+ (macro_space += 5) * sizeof (MACRO));
+ if (!macro_list)
+ abort ();
+ }
+ new = add_texinfo_command (name);
+ m = ¯o_list[macro_number];
+ m->cmd = new;
+ macro_number++;
+ new &= ~USER_COMMAND_BIT;
+ user_defined_command_data[new].flags |= CF_MACRO;
}
- macro_list[macro_number].macro_name = name; /* strdup ? */
- macro_list[macro_number].element = macro;
-
- new = add_texinfo_command (name);
- macro_list[macro_number++].cmd = new;
- new &= ~USER_COMMAND_BIT;
-
- user_defined_command_data[new].flags |= CF_MACRO;
+ m->macro_name = name; /* strdup ? */
+ m->element = macro;
}
// 1088
@@ -414,6 +425,12 @@
remove_texinfo_command (cmd);
}
+void
+wipe_macros (void)
+{
+ macro_number = 0;
+}
+
// 3898
/* CMD is the macro command. */
ELEMENT *
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7164] parsetexi update,
gavinsmith0123 <=