[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6857] parsetexi update
From: |
Gavin D. Smith |
Subject: |
[6857] parsetexi update |
Date: |
Mon, 14 Dec 2015 17:47:22 +0000 |
Revision: 6857
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6857
Author: gavin
Date: 2015-12-14 17:47:20 +0000 (Mon, 14 Dec 2015)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/parsetexi/api.c
trunk/parsetexi/commands.c
trunk/parsetexi/commands.h
trunk/parsetexi/convert.c
trunk/parsetexi/macro.c
trunk/parsetexi/parser.c
trunk/parsetexi/separator.c
Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c 2015-12-13 23:12:52 UTC (rev 6856)
+++ trunk/parsetexi/api.c 2015-12-14 17:47:20 UTC (rev 6857)
@@ -121,6 +121,8 @@
sv = newRV_inc ((SV *) av);
for (i = 0; i < e->number; i++)
{
+ if (!e->list[i]) /* For arrays only, allow elements to be undef. */
+ av_push (av, newSV (0));
if (!e->list[i]->hv)
{
if (e->list[i]->parent_type != route_not_in_tree)
@@ -234,7 +236,7 @@
|| e->cmd == CM_TeX
|| (command_data(e->cmd).flags & CF_accent)
|| (command_data(e->cmd).flags & CF_brace
- && (command_data(e->cmd).data > 0 // 4838
+ && (command_data(e->cmd).data >= 0
|| command_data(e->cmd).data == BRACE_style
|| command_data(e->cmd).data == BRACE_context))
|| e->cmd == CM_node) // FIXME special case
@@ -342,28 +344,15 @@
STORE(newRV_inc ((SV *)av));
for (j = 0; j < f->contents.number; j++)
{
- AV *av2;
+ SV *array;
ELEMENT *g;
g = f->contents.list[j];
- av2 = newAV ();
- av_push (av, newRV_inc ((SV *)av2));
-
- for (k = 0; k < g->contents.number; k++)
- {
- ELEMENT *h;
- h = g->contents.list[k];
- if (!h->hv)
- {
- if (h->parent_type != route_not_in_tree)
- h->hv = newHV ();
- else
- {
- element_to_perl_hash (h);
- }
- }
- av_push (av2, newRV_inc ((SV*)h->hv));
- }
+ if (g)
+ array = build_perl_array (&g->contents);
+ else
+ array = newSV (0); /* undef */
+ av_push (av, array);
}
break;
}
Modified: trunk/parsetexi/commands.c
===================================================================
--- trunk/parsetexi/commands.c 2015-12-13 23:12:52 UTC (rev 6856)
+++ trunk/parsetexi/commands.c 2015-12-14 17:47:20 UTC (rev 6857)
@@ -84,7 +84,16 @@
return ((enum command_id) user_defined_number++) | USER_COMMAND_BIT;
}
+/* Remove CMD, for @unmacro. */
void
+remove_texinfo_command (enum command_id cmd)
+{
+ cmd &= ~USER_COMMAND_BIT;
+ free (user_defined_command_data[cmd].cmdname);
+ user_defined_command_data[cmd].cmdname = "";
+}
+
+void
wipe_user_commands (void)
{
user_defined_number = 0;
@@ -103,6 +112,8 @@
if (command_data(cmd_id).data == BLOCK_conditional
|| command_data(cmd_id).data == BLOCK_raw)
return 0;
+ if (command_data(cmd_id).flags & CF_format_raw)
+ return 0;
return 1;
}
@@ -130,8 +141,15 @@
|| cmd_id == CM_exdent)
return 1;
- /* def commands */
+ /* headings Common.pm:954 */
+ if ((command_data(cmd_id).flags & CF_sectioning)
+ && !(command_data(cmd_id).flags & CF_root))
+ return 1;
+ /* def commands 866 */
+ if ((command_data(cmd_id).flags & CF_def))
+ return 1;
+
return 0;
}
Modified: trunk/parsetexi/commands.h
===================================================================
--- trunk/parsetexi/commands.h 2015-12-13 23:12:52 UTC (rev 6856)
+++ trunk/parsetexi/commands.h 2015-12-14 17:47:20 UTC (rev 6857)
@@ -37,6 +37,7 @@
#define command_name(cmd) (command_data(cmd).cmdname)
enum command_id add_texinfo_command (char *name);
+void remove_texinfo_command (enum command_id cmd);
void wipe_user_commands (void);
/* In indices.c */
@@ -80,7 +81,10 @@
/* NOTE: We've run out of spaces for flags, but some of these may not
be used, or may not be necessary. For example, region could be done
- as BLOCK_region in data instead. */
+ as BLOCK_region in data instead.
+ Candidates for flags:
+ CF_close_paragraph
+ */
/* Types of misc command (has CF_misc flag). Values for COMMAND.data. */
/* See Common.pm:376 */
Modified: trunk/parsetexi/convert.c
===================================================================
--- trunk/parsetexi/convert.c 2015-12-13 23:12:52 UTC (rev 6856)
+++ trunk/parsetexi/convert.c 2015-12-14 17:47:20 UTC (rev 6857)
@@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
+#include <stdio.h>
#include <ctype.h>
#include <string.h>
Modified: trunk/parsetexi/macro.c
===================================================================
--- trunk/parsetexi/macro.c 2015-12-13 23:12:52 UTC (rev 6856)
+++ trunk/parsetexi/macro.c 2015-12-14 17:47:20 UTC (rev 6857)
@@ -389,6 +389,7 @@
m->cmd = 0;
m->macro_name = "";
m->element = 0;
+ remove_texinfo_command (cmd);
}
// 3898
Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c 2015-12-13 23:12:52 UTC (rev 6856)
+++ trunk/parsetexi/parser.c 2015-12-14 17:47:20 UTC (rev 6857)
@@ -205,12 +205,35 @@
if (begin_paragraph_p (current))
{
ELEMENT *e;
- int indent = 0;
+ enum command_id indent = 0;
/* Check if an @indent precedes the paragraph (to record it
in the 'extra' key). */
+ if (current->contents.number > 0)
+ {
+ int i = current->contents.number - 1;
+ while (i > 0)
+ {
+ ELEMENT *child = contents_child_by_index (current, i);
+ if (child->type == ET_empty_line
+ || child->type == ET_paragraph)
+ break;
+ if (close_paragraph_command(child->cmd))
+ break;
+ if (child->cmd == CM_indent
+ || child->cmd == CM_noindent)
+ {
+ indent = child->cmd;
+ break;
+ }
+ i--;
+ }
+ }
+
e = new_element (ET_paragraph);
+ if (indent)
+ add_extra_string (e, indent == CM_indent ? "indent" : "noindent", "1");
add_to_element_contents (current, e);
current = e;
@@ -866,8 +889,12 @@
may lead to changes in the line. */
if (cmd && (command_data(cmd).flags & CF_MACRO)) // 3894
{
+ static char *allocated_line;
line = line_after_command;
current = handle_macro (current, &line, cmd);
+ free (allocated_line);
+ allocated_line = next_text ();
+ line = allocated_line;
}
/* 3983 Cases that may "lead to command closing": brace commands that don't
Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2015-12-13 23:12:52 UTC (rev 6856)
+++ trunk/parsetexi/separator.c 2015-12-14 17:47:20 UTC (rev 6857)
@@ -44,7 +44,7 @@
if (new->contents.number == 0)
{
free (new);
- return;
+ new = 0;
}
/* FIXME: Could we add all the command args together, instead of one-by-one,
@@ -222,6 +222,7 @@
// || ignore_global_commands () - whatever that is
{
ELEMENT *b = new_element (ET_bracketed);
+ b->line_nr = line_nr;
add_to_element_contents (current, b);
current = b;
debug ("BRACKETED in math");
@@ -258,7 +259,8 @@
/* The Perl code here checks that the popped context and the
parent command match as strings. */
}
- else if (command_data(current->parent->cmd).data > 0)
+ else if (command_data(current->parent->cmd).data > 0 /* sic */
+ || command_data(current->parent->cmd).data == BRACE_inline)
{
// 5033
/* @inline* always have end spaces considered as normal text */
@@ -291,10 +293,44 @@
}
else if (command_data(closed_command).flags & CF_ref) // 5062
{
+ ELEMENT *ref = current->parent, *args;
+ KEY_PAIR *k;
+ if (ref->args.number > 0)
+ {
+ k = lookup_extra_key (ref, "brace_command_contents");
+ args = k->value;
+ if (0)
+ {
+ line_warn ("command @%s missing a node or external manual "
+ "argument", command_name(closed_command));
+ }
+ else
+ {
+ NODE_SPEC_EXTRA *nse;
+ nse = parse_node_manual (args_child_by_index (ref, 0));
+ if (nse)
+ add_extra_node_spec (ref, "node_argument", nse);
+ // TODO 5078 global internal_references array
+ }
+ // TODO 5085 check node name not empty after normalization
+ }
}
- else if (closed_command == CM_image)
+ else if (closed_command == CM_image) // 5109
{
- // check for filename argument
+ ELEMENT *image = current->parent;
+ KEY_PAIR *k;
+ if (image->args.number == 0)
+ goto image_no_args;
+ k = lookup_extra_key (image, "brace_command_contents");
+ if (!k)
+ goto image_no_args;
+ if (!contents_child_by_index (k->value, 0))
+ goto image_no_args;
+ if (0)
+ {
+ image_no_args:
+ line_error ("@image missing filename argument");
+ }
}
else if (closed_command == CM_dotless)
{
@@ -389,8 +425,8 @@
return;
while (k->value->contents.number > 0
- && last_contents_child(k->value)->contents.number == 0)
- destroy_element (pop_element_from_contents (k->value));
+ && !last_contents_child(k->value)) // ->contents.number == 0)
+ pop_element_from_contents (k->value);
if (k->value->contents.number == 0)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6857] parsetexi update,
Gavin D. Smith <=