[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5444] consolidate node specification defaults
From: |
Gavin D. Smith |
Subject: |
[5444] consolidate node specification defaults |
Date: |
Sun, 13 Apr 2014 15:54:58 +0000 |
Revision: 5444
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5444
Author: gavin
Date: 2014-04-13 15:54:57 +0000 (Sun, 13 Apr 2014)
Log Message:
-----------
consolidate node specification defaults
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/nodes.c
trunk/info/nodes.h
trunk/info/session.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-04-13 15:44:21 UTC (rev 5443)
+++ trunk/ChangeLog 2014-04-13 15:54:57 UTC (rev 5444)
@@ -1,5 +1,18 @@
2014-04-13 Gavin Smith <address@hidden>
+ * nodes.c (get_filename_and_nodename): New static function setting
+ defaults for node specifications.
+ (info_get_node, info_get_node_with_defaults): New argument 'window'
+ for info_get_node. Function renamed, with wrapper with old arguments.
+ Call get_filename_and_nodename.
+ (info_get_node_of_file_buffer): Remove unnecessary check for null
+ nodename - done by calling code.
+
+ * session.c (info_select_reference): Call info_get_node_with_defaults.
+ (info_parse_and_select): Do not call info_parse_node.
+
+2014-04-13 Gavin Smith <address@hidden>
+
* info/nodes.c: Reorder file into sections. No functional changes.
2014-04-13 Gavin Smith <address@hidden>
Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c 2014-04-13 15:44:21 UTC (rev 5443)
+++ trunk/info/nodes.c 2014-04-13 15:54:57 UTC (rev 5444)
@@ -869,6 +869,9 @@
be off by. I feel that it should be much smaller, like 4. */
#define DEFAULT_INFO_FUDGE 1000
+static int get_filename_and_nodename (int flag, WINDOW *window,
+ char **filename, char **nodename,
+ char *filename_in, char *nodename_in);
static char *adjust_nodestart (NODE *node, int min, int max);
static void node_set_body_start (NODE *node);
static NODE *find_node_of_anchor (FILE_BUFFER *file_buffer, TAG *tag);
@@ -876,36 +879,30 @@
static NODE *info_node_of_file_buffer_tags (FILE_BUFFER *file_buffer,
char *nodename);
-/* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME.
- If FILENAME is NULL, `dir' is used.
- If NODENAME is NULL, `Top' is used.
+/* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME,
+ using WINDOW for defaults. If WINDOW is null, the defaults are:
+ - If FILENAME is NULL, `dir' is used.
+ - If NODENAME is NULL, `Top' is used.
The FLAG argument (one of the PARSE_NODE_* constants) instructs how to
parse NODENAME.
If the node cannot be found, return NULL. */
NODE *
-info_get_node (char *filename, char *nodename, int flag)
+info_get_node_with_defaults (char *filename_in, char *nodename_in,
+ int flag, WINDOW *window)
{
NODE *node;
FILE_BUFFER *file_buffer = NULL;
+ char *filename = 0, *nodename = 0;
/* Used to build `dir' menu from `localdir' files found in INFOPATH. */
extern void maybe_build_dir_node (char *dirname);
info_recent_file_error = NULL;
- info_parse_node (nodename, flag);
- nodename = NULL;
- if (info_parsed_filename)
- filename = info_parsed_filename;
+ get_filename_and_nodename (flag, window,
+ &filename, &nodename, filename_in, nodename_in);
- if (info_parsed_nodename)
- nodename = info_parsed_nodename;
-
- /* If FILENAME is not specified, it defaults to "dir". */
- if (!filename)
- filename = "dir";
-
/* If the file to be looked up is "dir", build the contents from all of
the "dir"s and "localdir"s found in INFOPATH. */
if (is_dir_name (filename))
@@ -941,9 +938,51 @@
node = info_get_node_of_file_buffer ("TOP", file_buffer);
}
+ free (filename); free (nodename);
return node;
}
+NODE *
+info_get_node (char *filename_in, char *nodename_in, int flag)
+{
+ return info_get_node_with_defaults (filename_in, nodename_in, flag, 0);
+}
+
+/* Set default values. Output values should be freed by caller. */
+static int
+get_filename_and_nodename (int flag, WINDOW *window,
+ char **filename, char **nodename,
+ char *filename_in, char *nodename_in)
+{
+ /* Get file name, nodename */
+ info_parse_node (nodename_in, flag);
+
+ if (info_parsed_filename)
+ *filename = info_parsed_filename;
+ else if (filename_in)
+ *filename = filename_in;
+
+ /* If FILENAME is not specified, it defaults to "dir". */
+ if (!*filename)
+ {
+ if (window)
+ {
+ *filename = window->node->parent;
+ if (!*filename)
+ *filename = window->node->filename;
+ }
+ else
+ *filename = "dir";
+ }
+ *filename = xstrdup (*filename);
+
+ if (info_parsed_nodename)
+ *nodename = xstrdup (info_parsed_nodename);
+ /* If NODENAME is not specified, it defaults to "Top". */
+ else
+ *nodename = xstrdup ("Top");
+}
+
static void
node_set_body_start (NODE *node)
{
@@ -973,13 +1012,6 @@
if (!file_buffer->contents)
info_reload_file_buffer_contents (file_buffer);
- /* If NODENAME is not specified, it defaults to "Top". */
- if (!nodename)
- {
- nodename = "Top";
- implicit_nodename = 1; /* don't return man page for top */
- }
-
/* If the name of the node that we wish to find is exactly "*", then the
node body is the contents of the entire file. Create and return such
a node. */
@@ -998,7 +1030,7 @@
#if defined (HANDLE_MAN_PAGES)
/* If the file buffer is the magic one associated with manpages, call
the manpage node finding function instead. */
- else if (!implicit_nodename && file_buffer->flags & N_IsManPage)
+ else if (file_buffer->flags & N_IsManPage)
{
node = get_manpage_node (file_buffer, nodename);
}
Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h 2014-04-13 15:44:21 UTC (rev 5443)
+++ trunk/info/nodes.h 2014-04-13 15:54:57 UTC (rev 5444)
@@ -144,6 +144,13 @@
If the node cannot be found, return a NULL pointer. */
extern NODE *info_get_node (char *filename, char *nodename, int flag);
+/* Forward declaration to avoid node.h and window.h having to
+ include each other. */
+typedef struct window_struct WINDOW;
+
+extern NODE *info_get_node_with_defaults (char *filename, char *nodename,
+ int flag, WINDOW *window);
+
/* Return a pointer to a NODE structure for the Info node NODENAME in
FILE_BUFFER. NODENAME can be passed as NULL, in which case the
nodename of "Top" is used. If the node cannot be found, return a
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-04-13 15:44:21 UTC (rev 5443)
+++ trunk/info/session.c 2014-04-13 15:54:57 UTC (rev 5444)
@@ -2044,26 +2044,13 @@
info_select_reference (WINDOW *window, REFERENCE *entry)
{
NODE *node;
- char *filename, *nodename, *file_system_error;
+ char *file_system_error;
file_system_error = NULL;
- filename = entry->filename;
- if (!filename)
- filename = window->node->parent;
- if (!filename)
- filename = window->node->filename;
+ node = info_get_node_with_defaults (entry->filename, entry->nodename,
+ PARSE_NODE_VERBATIM, window);
- if (filename)
- filename = xstrdup (filename);
-
- if (entry->nodename)
- nodename = xstrdup (entry->nodename);
- else
- nodename = xstrdup ("Top");
-
- node = info_get_node (filename, nodename, PARSE_NODE_VERBATIM);
-
/* Try something a little weird. If the node couldn't be found, and the
reference was of the form "foo::", see if the entry->label can be found
as a file, with a node of "Top". */
@@ -2088,12 +2075,10 @@
if (file_system_error)
info_error ("%s", file_system_error);
else
- info_error (msg_cant_find_node, nodename);
+ info_error (msg_cant_find_node, entry->nodename);
}
free (file_system_error);
- free (filename);
- free (nodename);
if (node)
info_set_node_of_window (1, window, node);
@@ -2107,10 +2092,9 @@
{
REFERENCE entry;
- info_parse_node (line, PARSE_NODE_DFLT);
-
- entry.nodename = info_parsed_nodename;
- entry.filename = info_parsed_filename;
+ /* info_parse_node will be called on 'line' in subsequent functions. */
+ entry.nodename = line;
+ entry.filename = 0;
entry.label = "*info-parse-and-select*";
info_select_reference (window, &entry);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5444] consolidate node specification defaults,
Gavin D. Smith <=