[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6828] parsetexi update
From: |
Gavin D. Smith |
Subject: |
[6828] parsetexi update |
Date: |
Wed, 02 Dec 2015 23:11:30 +0000 |
Revision: 6828
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6828
Author: gavin
Date: 2015-12-02 23:11:29 +0000 (Wed, 02 Dec 2015)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/parsetexi/Parsetexi/Parsetexi.xs
trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
trunk/parsetexi/api.c
trunk/parsetexi/api.h
trunk/parsetexi/dump_perl.c
Modified: trunk/parsetexi/Parsetexi/Parsetexi.xs
===================================================================
--- trunk/parsetexi/Parsetexi/Parsetexi.xs 2015-12-02 17:03:31 UTC (rev
6827)
+++ trunk/parsetexi/Parsetexi/Parsetexi.xs 2015-12-02 23:11:29 UTC (rev
6828)
@@ -66,6 +66,9 @@
void
wipe_values ()
+void
+init_index_commands ()
+
ELEMENT *
get_root()
Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm 2015-12-02 17:03:31 UTC (rev
6827)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm 2015-12-02 23:11:29 UTC (rev
6828)
@@ -118,21 +118,25 @@
);
- my %parser_hash = %parser_blanks;
- @parser_hash {keys %default_customization_values} =
- values %default_customization_values;
+ # my %parser_hash = %parser_blanks;
+ # @parser_hash {keys %default_customization_values} =
+ # values %default_customization_values;
- my $parser = \%parser_hash;
+ # my $parser = \%parser_hash;
+ my $parser = _deep_copy(\%parser_default_configuration);
+
$parser->{'gettext'} = $parser_default_configuration{'gettext'};
$parser->{'pgettext'} = $parser_default_configuration{'pgettext'};
wipe_values ();
+ init_index_commands ();
if (defined($conf)) {
foreach my $key (keys (%$conf)) {
if (ref($conf->{$key}) ne 'CODE' and $key ne 'values') {
$parser->{$key} = _deep_copy($conf->{$key});
} else {
+ warn "key is $key";
#$parser->{$key} = $conf->{$key};
}
@@ -180,7 +184,9 @@
my $self = shift;
my $root = shift;
- return Texinfo::Parser::_parse_texi ($self, $root);
+ my $self2 = Texinfo::Parser::parser();
+ $self2->{'input'} = $self->{'input'};
+ return Texinfo::Parser::_parse_texi ($self2, $root);
}
use Data::Dumper;
@@ -245,6 +251,9 @@
my $self = shift;
my $root = shift;
+ if (!defined $self->{'nodes'}) {
+ $self->{'nodes'} = [];
+ }
foreach my $child (@{$root->{'contents'}}) {
if ($child->{'cmdname'} and $child->{'cmdname'} eq 'node') {
push $self->{'nodes'}, $child;
@@ -329,7 +338,7 @@
print "Adjusted tree.\n";
$self->{'info'} = $GLOBAL_INFO;
- print "!!! ENCODING IS ", $self->{'info'}->{'input_encoding_name'} , "\n";
+ #print "!!! ENCODING IS ", $self->{'info'}->{'input_encoding_name'} , "\n";
if (defined($self->{'info'}->{'input_encoding_name'})) {
my ($texinfo_encoding, $perl_encoding, $input_encoding)
@@ -343,7 +352,7 @@
$self->{'labels'} = $LABELS;
- $self->{'index_names'} = $INDEX_NAMES;
+ #$self->{'index_names'} = $INDEX_NAMES;
#for my $index (keys %$INDEX_NAMES) {
# if ($INDEX_NAMES->{$index}->{'merged_in'}) {
# $self->{'merged_indices'}-> {$index}
@@ -351,9 +360,6 @@
# }
#}
- # Copy the errors into the error list in Texinfo::Report.
- # TODO: Could we just access the error list directly instead of going
- # through Texinfo::Report line_error?
_get_errors ($self);
@@ -365,6 +371,9 @@
return $TREE;
}
+# Copy the errors into the error list in Texinfo::Report.
+# TODO: Could we just access the error list directly instead of going
+# through Texinfo::Report line_error?
sub _get_errors($)
{
my $self = shift;
@@ -398,9 +407,17 @@
wipe_errors ();
parse_text($text);
my $tree = build_texinfo_tree ();
- $self->{'index_names'} = build_index_data ();
+ my $INDEX_NAMES = build_index_data ();
+ $self->{'index_names'} = $INDEX_NAMES;
+ for my $index (keys %$INDEX_NAMES) {
+ if ($INDEX_NAMES->{$index}->{'merged_in'}) {
+ $self->{'merged_indices'}-> {$index}
+ = $INDEX_NAMES->{$index}->{'merged_in'};
+ }
+ }
_get_errors ($self);
_add_parents ($tree);
+ _complete_node_list ($self, $tree);
return $tree;
}
@@ -427,6 +444,14 @@
sub indices_information($)
{
my $self = shift;
+ my $INDEX_NAMES = build_index_data ();
+ $self->{'index_names'} = $INDEX_NAMES;
+ #for my $index (keys %$INDEX_NAMES) {
+ # if ($INDEX_NAMES->{$index}->{'merged_in'}) {
+ # $self->{'merged_indices'}-> {$index}
+ # = $INDEX_NAMES->{$index}->{'merged_in'};
+ # }
+ #}
return ($self->{'index_names'}, $self->{'merged_indices'});
}
Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c 2015-12-02 17:03:31 UTC (rev 6827)
+++ trunk/parsetexi/api.c 2015-12-02 23:11:29 UTC (rev 6828)
@@ -58,7 +58,7 @@
parse_string (char *string)
{
ELEMENT *root;
- init_index_commands (); /* FIXME - probably not necessary */
+ //init_index_commands (); /* FIXME - probably not necessary */
wipe_errors ();
root = new_element (ET_root_line);
input_push_text (strdup (string));
@@ -70,7 +70,7 @@
parse_text (char *string)
{
ELEMENT *root;
- init_index_commands (); /* FIXME - probably not necessary */
+ //init_index_commands (); /* FIXME - probably not necessary */
wipe_errors ();
root = new_element (ET_text_root);
input_push_text_with_line_nos (strdup (string));
@@ -545,7 +545,7 @@
}
STORE("name", newSVpv (i->name, 0));
- STORE("in_code", newSVpv (i->in_code ? "1" : "0", 1));
+ STORE("in_code", i->in_code ? newSViv(1) : newSViv(0));
/* e.g. 'prefix' => ['k', 'ky'] */
prefix_array = newAV ();
@@ -587,10 +587,14 @@
/* Record that this index "contains itself". */
hv_store (i->contained_hv, i->name, strlen (i->name), newSViv(1), 0);
- entries = newAV ();
- STORE("index_entries", newRV_inc ((SV *) entries));
+ if (i->index_number > 0)
+ {
+ entries = newAV ();
+ STORE("index_entries", newRV_inc ((SV *) entries));
+ }
#undef STORE
+ if (i->index_number > 0)
for (j = 0; j < i->index_number; j++)
{
#define STORE2(key, value) hv_store (entry, key, strlen (key), value, 0)
@@ -622,12 +626,22 @@
contents_array = hv_fetch (e->content->hv,
"contents", strlen ("contents"), 0);
- /* Copy the reference to the array. */
- STORE2("content", newRV_inc ((SV *)(AV *)SvRV(*contents_array)));
+ if (!contents_array)
+ {
+ element_to_perl_hash (e->content);
+ contents_array = hv_fetch (e->content->hv,
+ "contents", strlen ("contents"), 0);
+ }
- /* FIXME: Allow to be different. */
- STORE2("content_normalized",
- newRV_inc ((SV *)(AV *)SvRV(*contents_array)));
+ if (contents_array)
+ {
+ /* Copy the reference to the array. */
+ STORE2("content", newRV_inc ((SV *)(AV *)SvRV(*contents_array)));
+
+ /* FIXME: Allow to be different. */
+ STORE2("content_normalized",
+ newRV_inc ((SV *)(AV *)SvRV(*contents_array)));
+ }
}
if (e->node)
STORE2("node", newRV_inc ((SV *)e->node->hv));
Modified: trunk/parsetexi/api.h
===================================================================
--- trunk/parsetexi/api.h 2015-12-02 17:03:31 UTC (rev 6827)
+++ trunk/parsetexi/api.h 2015-12-02 23:11:29 UTC (rev 6828)
@@ -19,3 +19,6 @@
/* In input.c */
void add_include_directory (char *filename);
+
+/* In indices.c */
+void init_index_commands (void);
Modified: trunk/parsetexi/dump_perl.c
===================================================================
--- trunk/parsetexi/dump_perl.c 2015-12-02 17:03:31 UTC (rev 6827)
+++ trunk/parsetexi/dump_perl.c 2015-12-02 23:11:29 UTC (rev 6828)
@@ -545,6 +545,8 @@
int i;
INDEX_ENTRY *e;
+ if (idx->index_number == 0)
+ return;
text_printf (&indices_dump, "\n'index_entries' => [");
for (i = 0; i < idx->index_number; i++)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6828] parsetexi update,
Gavin D. Smith <=