[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5919] better search for invocation nodes
From: |
Gavin D. Smith |
Subject: |
[5919] better search for invocation nodes |
Date: |
Sun, 09 Nov 2014 10:30:30 +0000 |
Revision: 5919
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5919
Author: gavin
Date: 2014-11-09 10:30:29 +0000 (Sun, 09 Nov 2014)
Log Message:
-----------
better search for invocation nodes
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/info.c
trunk/info/session.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-11-08 18:07:35 UTC (rev 5918)
+++ trunk/ChangeLog 2014-11-09 10:30:29 UTC (rev 5919)
@@ -1,3 +1,11 @@
+2014-11-09 Gavin Smith <address@hidden>
+
+ * info/session.c (find_invocation_node_by_nodename): New
+ function.
+ (info_intuit_options_node): If passed Top node, call it to get a
+ new node to start at. Return value to be freed by caller. All
+ callers updated.
+
2014-11-08 Gavin Smith <address@hidden>
* info/session.c (menu_digit): Unused argument removed.
Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c 2014-11-08 18:07:35 UTC (rev 5918)
+++ trunk/info/info.c 2014-11-09 10:30:29 UTC (rev 5919)
@@ -354,8 +354,7 @@
info_reference_free (ref_list[0]);
ref_index = 0;
- add_pointer_to_array (info_copy_reference (invoc_ref),
- ref_index, ref_list, ref_slots, 2);
+ add_pointer_to_array (invoc_ref, ref_index, ref_list, ref_slots, 2);
}
free (program);
}
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-11-08 18:07:35 UTC (rev 5918)
+++ trunk/info/session.c 2014-11-09 10:30:29 UTC (rev 5919)
@@ -3213,10 +3213,38 @@
free (line);
}
-/* Find the node in the file with Top node NODE that is the best candidate to
+static NODE *
+find_invocation_node_by_nodename (FILE_BUFFER *fb, char *program)
+{
+ NODE *node = 0;
+ NODE **n;
+ char *try1, *try2;
+ n = fb->tags;
+ if (!n)
+ return 0;
+
+ asprintf (&try1, "Invoking %s", program);
+ asprintf (&try2, "%s invocation", program);
+ for (; *n; n++)
+ {
+ if ((*n)->nodename
+ && (!strcasecmp ((*n)->nodename, try1)
+ || !strcasecmp ((*n)->nodename, try2)))
+ {
+ node = info_get_node_of_file_buffer (fb, (*n)->nodename);
+ break;
+ }
+ }
+ free (try1); free (try2);
+
+ return node;
+}
+
+/* Find the node in the file with name FILE that is the best candidate to
list the PROGRAM's invocation info and its command-line options, by looking
for menu items and chains of menu items with characteristic names. This
- function frees NODE. Return value should not be freed by caller. */
+ function frees NODE. Return value should be freed by caller with
+ info_reference_free. */
REFERENCE *
info_intuit_options_node (NODE *node, char *program)
{
@@ -3243,9 +3271,27 @@
"%s", /* last resort */
(const char *)0
};
- REFERENCE *entry = NULL;
- const char **try_node;
+ char *filename = node->fullpath;
+ if (!strcmp ("Top", node->nodename))
+ {
+ /* Look through the list of nodes (and anchors) in the file for a node
to
+ start at. There may be an invocation node that is not listed in the
+ top-level menu (this is the case for the Bash 4.2 manual), or it may
+ be referred to with an anchor ("Invoking makeinfo" in Texinfo
+ manual). */
+ FILE_BUFFER *fb;
+ NODE *n;
+ fb = info_find_file (filename);
+ if (!fb)
+ return 0;
+ n = find_invocation_node_by_nodename (fb, program);
+ if (n)
+ {
+ free_history_node (node);
+ node = n;
+ }
+ }
/* We keep looking deeper and deeper in the menu structure until
there are no more menus or no menu items from the above list.
@@ -3253,7 +3299,8 @@
in the menu hierarchy... */
while (1)
{
- REFERENCE *new_entry = NULL;
+ const char **try_node;
+ REFERENCE *entry = NULL;
/* If no menu in this node, stop here. Perhaps this node
is the one they need. */
@@ -3269,33 +3316,37 @@
sprintf (nodename, *try_node, program);
/* The last resort "%s" is dangerous, so we restrict it
to exact matches here. */
- new_entry = info_get_menu_entry_by_label
+ entry = info_get_menu_entry_by_label
(node, nodename, strcmp (*try_node, "%s"));
free (nodename);
- if (new_entry)
+ if (entry)
break;
}
- if (!new_entry)
+ if (!entry)
break;
- else
- entry = new_entry;
/* Go down into menu, and repeat. */
if (!entry->filename)
- entry->filename = xstrdup (node->fullpath);
+ entry->filename = xstrdup (filename);
- free_history_node (node);
-
- /* Try to find this node. */
- node = info_get_node (entry->filename, entry->nodename);
- if (!node)
- break;
+ {
+ NODE *node2;
+ node2 = info_get_node (entry->filename, entry->nodename);
+ free_history_node (node);
+ if (!node2)
+ break;
+ node = node2;
+ }
}
- free_history_node (node);
- return entry;
+ {
+ char *n = node->nodename;
+ node->nodename = 0;
+ free_history_node (node);
+ return info_new_reference (filename, n);
+ }
}
/* Given a name of an Info file, find the name of the package it describes by
@@ -3361,7 +3412,10 @@
/* We've got our best shot at the invocation node. Now select it. */
if (invocation_ref)
- info_select_reference (window, invocation_ref);
+ {
+ info_select_reference (window, invocation_ref);
+ info_reference_free (invocation_ref);
+ }
free (line);
free (default_program_name);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5919] better search for invocation nodes,
Gavin D. Smith <=