[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5553] fix index lookup from invocation
From: |
Gavin D. Smith |
Subject: |
[5553] fix index lookup from invocation |
Date: |
Sun, 11 May 2014 18:33:49 +0000 |
Revision: 5553
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5553
Author: gavin
Date: 2014-05-11 18:33:48 +0000 (Sun, 11 May 2014)
Log Message:
-----------
fix index lookup from invocation
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/Makefile.am
trunk/info/info.c
trunk/info/session.c
Added Paths:
-----------
trunk/info/t/dir-file-index.sh
trunk/info/t/dir-menus-sloppily.sh
trunk/info/t/file-index.sh
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-05-11 16:14:41 UTC (rev 5552)
+++ trunk/ChangeLog 2014-05-11 18:33:48 UTC (rev 5553)
@@ -1,5 +1,13 @@
2014-05-11 Gavin Smith <address@hidden>
+ * info/info.c (add_initial_nodes): When following menus, start at
+ node in ref_list if there is one already.
+ * info/session.c (info_folllow_menus): Comment about allocation added.
+
+ * info/t/dir-file-index.sh, info/t/file-index.sh: New tests.
+
+2014-05-11 Gavin Smith <address@hidden>
+
* info/dir.c (dir_node, get_dir_node): Function renamed.
(lookup_dir_entry): New function. Case insensitive lookup
based on that in info_follow_menus.
Modified: trunk/info/Makefile.am
===================================================================
--- trunk/info/Makefile.am 2014-05-11 16:14:41 UTC (rev 5552)
+++ trunk/info/Makefile.am 2014-05-11 18:33:48 UTC (rev 5553)
@@ -93,6 +93,7 @@
t/file.sh \
t/file-node.sh \
t/file-nodes.sh \
+ t/file-index.sh \
t/no-file.sh \
t/split.sh \
t/relative-path.sh \
@@ -105,7 +106,9 @@
t/dir-file-menu.sh \
t/dir-file-no-menu.sh \
t/dir-file-node.sh \
+ t/dir-file-index.sh \
t/dir-3-menus.sh \
+ t/dir-menus-sloppily.sh \
t/where-dir-file.sh \
t/tab.sh \
t/index.sh \
Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c 2014-05-11 16:14:41 UTC (rev 5552)
+++ trunk/info/info.c 2014-05-11 18:33:48 UTC (rev 5553)
@@ -263,7 +263,7 @@
}
/* Expand list of nodes to be loaded. */
-static REFERENCE **
+static void
add_initial_nodes (FILE_BUFFER *initial_file, int argc, char **argv,
char **error)
{
@@ -325,58 +325,77 @@
this to the list of nodes specified with --node. */
else if (*argv)
{
- NODE *initial_node;
+ NODE *initial_node; /* Node to start following menus from. */
- initial_node = info_get_node_of_file_buffer (initial_file, "Top");
+ if (ref_index == 0)
+ {
+ new_ref = xzalloc (sizeof (REFERENCE));
+ new_ref->filename = initial_file->fullpath;
+ new_ref->nodename = "Top";
+
+ add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
+ }
+
+ initial_node = info_get_node_with_defaults (ref_list[0]->filename,
+ ref_list[0]->nodename,
+ PARSE_NODE_DFLT, 0);
+ if (!initial_node)
+ return;
+
node_via_menus = info_follow_menus (initial_node, argv, error, 1);
if (node_via_menus)
{
+ argv += argc; argc = 0;
+
+ free (ref_list[0]);
new_ref = xzalloc (sizeof (REFERENCE));
new_ref->filename = initial_file->fullpath;
new_ref->nodename = node_via_menus;
-
- add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
+ ref_list[0] = new_ref;
}
- }
- /* If no nodes found, and there is exactly one argument, check for
- it as an index entry. */
- if (ref_index == 0 && argc == 1 && argv[0])
- {
- REFERENCE **index;
- REFERENCE **index_ptr;
+ /* If no nodes found, and there is exactly one argument remaining,
+ check for it as an index entry. */
+ else if (argc == 1 && argv[0])
+ {
+ REFERENCE **index;
+ REFERENCE **index_ptr;
- debug (3, ("looking in indices"));
- index = info_indices_of_file_buffer (initial_file);
+ debug (3, ("looking in indices"));
+ index = info_indices_of_file_buffer (initial_file);
- for (index_ptr = index; index && *index_ptr; index_ptr++)
- {
- if (!strcmp (argv[0], (*index_ptr)->label))
+ for (index_ptr = index; index && *index_ptr; index_ptr++)
{
- free (*error); *error = 0;
+ if (!strcmp (argv[0], (*index_ptr)->label))
+ {
+ argv += argc; argc = 0;
+ free (*error); *error = 0;
- add_pointer_to_array (info_copy_reference (*index_ptr),
- ref_index, ref_list, ref_slots, 2);
- break;
+ free (ref_list[0]);
+ ref_list[0] = info_copy_reference (*index_ptr);
+ break;
+ }
}
}
- }
- /* If still no nodes and there are arguments remaining, follow menus
- inexactly. */
- if (ref_index == 0 && *argv)
- {
- NODE *initial_node;
-
- initial_node = info_get_node_of_file_buffer (initial_file, "Top");
- node_via_menus = info_follow_menus (initial_node, argv, error, 0);
- if (node_via_menus)
+ /* If there are arguments remaining, follow menus
+ inexactly. */
+ if (argc != 0)
{
- new_ref = xzalloc (sizeof (REFERENCE));
- new_ref->filename = initial_file->fullpath;
- new_ref->nodename = node_via_menus;
+ initial_node = info_get_node_with_defaults (ref_list[0]->filename,
+ ref_list[0]->nodename,
+ PARSE_NODE_DFLT, 0);
+ node_via_menus = info_follow_menus (initial_node, argv, error, 0);
+ if (node_via_menus)
+ {
+ argv += argc; argc = 0;
- add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
+ free (ref_list[0]);
+ new_ref = xzalloc (sizeof (REFERENCE));
+ new_ref->filename = initial_file->fullpath;
+ new_ref->nodename = node_via_menus;
+ ref_list[0] = new_ref;
+ }
}
}
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-05-11 16:14:41 UTC (rev 5552)
+++ trunk/info/session.c 2014-05-11 18:33:48 UTC (rev 5553)
@@ -2788,7 +2788,7 @@
in ERROR. STRICT says whether to accept incomplete strings as
menu entries, and whether to return the node so far if we can't
continue at any point (that might be INITIAL_NODE itself), or to
- return null. */
+ return null. This function frees INITIAL_NODE. */
char *
info_follow_menus (NODE *initial_node, char **menus, char **error,
int strict)
Added: trunk/info/t/dir-file-index.sh
===================================================================
--- trunk/info/t/dir-file-index.sh (rev 0)
+++ trunk/info/t/dir-file-index.sh 2014-05-11 18:33:48 UTC (rev 5553)
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Copyright (C) 2014 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. t/Init-test.inc
+
+# Follow an index entry in a file found through dir
+$GINFO --output - split 'entry text' \
+ | grep 'Node: Target node'
Property changes on: trunk/info/t/dir-file-index.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/info/t/dir-menus-sloppily.sh
===================================================================
--- trunk/info/t/dir-menus-sloppily.sh (rev 0)
+++ trunk/info/t/dir-menus-sloppily.sh 2014-05-11 18:33:48 UTC (rev 5553)
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Copyright (C) 2014 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. t/Init-test.inc
+
+# Follow several menus in a file inexactly to get to desired node
+$GINFO --output - file-menu first nod nod 3 \
+ | grep 'Arrived at Node 3.'
+
Property changes on: trunk/info/t/dir-menus-sloppily.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/info/t/file-index.sh
===================================================================
--- trunk/info/t/file-index.sh (rev 0)
+++ trunk/info/t/file-index.sh 2014-05-11 18:33:48 UTC (rev 5553)
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Copyright (C) 2014 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. t/Init-test.inc
+
+# Follow an index entry in a file specified with --file
+$GINFO --output - --file split 'entry text' \
+ | grep 'Node: Target node'
Property changes on: trunk/info/t/file-index.sh
___________________________________________________________________
Added: svn:executable
+ *
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5553] fix index lookup from invocation,
Gavin D. Smith <=