[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5615] info_new_reference added
From: |
Gavin D. Smith |
Subject: |
[5615] info_new_reference added |
Date: |
Thu, 29 May 2014 20:59:28 +0000 |
Revision: 5615
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5615
Author: gavin
Date: 2014-05-29 20:59:27 +0000 (Thu, 29 May 2014)
Log Message:
-----------
info_new_reference added
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/info-utils.c
trunk/info/info-utils.h
trunk/info/info.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-05-29 20:15:50 UTC (rev 5614)
+++ trunk/ChangeLog 2014-05-29 20:59:27 UTC (rev 5615)
@@ -8,6 +8,10 @@
* info/session.c (dump_nodes_to_file): Checks for DUMP_APPEND removed.
* info/session.h (DUMP_APPEND): Remove unused.
+ * info/info-utils.c (info_new_reference): New function.
+ * info/info.c (get_initial_file, add_initial_nodes)
+ (info_find_matching_files): Call info_new_reference.
+
2014-05-28 Gavin Smith <address@hidden>
* info/session.c (point_next_line, point_prev_line): Check for
Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c 2014-05-29 20:15:50 UTC (rev 5614)
+++ trunk/info/info-utils.c 2014-05-29 20:59:27 UTC (rev 5615)
@@ -398,6 +398,21 @@
}
}
+/* Return new REFERENCE with filename and nodename fields set. References
+ to FILENAME and NODENAME are retained in the return value. */
+REFERENCE *
+info_new_reference (char *filename, char *nodename)
+{
+ REFERENCE *r = xmalloc (sizeof (REFERENCE));
+ r->label = 0;
+ r->filename = filename;
+ r->nodename = nodename;
+ r->start = 0;
+ r->end = 0;
+ r->line_number = 0;
+ r->type = 0;
+}
+
/* Search for sequences of whitespace or newlines in STRING, replacing
all such sequences with just a single space. Remove whitespace from
Modified: trunk/info/info-utils.h
===================================================================
--- trunk/info/info-utils.h 2014-05-29 20:15:50 UTC (rev 5614)
+++ trunk/info/info-utils.h 2014-05-29 20:59:27 UTC (rev 5615)
@@ -87,6 +87,9 @@
/* Free the data associated with REFERENCES. */
extern void info_free_references (REFERENCE **references);
+/* Create new REFERENCE structure. */
+extern REFERENCE *info_new_reference (char *filename, char *nodename);
+
/* Search for sequences of whitespace or newlines in STRING, replacing
all such sequences with just a single space. Remove whitespace from
start and end of string. */
Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c 2014-05-29 20:15:50 UTC (rev 5614)
+++ trunk/info/info.c 2014-05-29 20:59:27 UTC (rev 5615)
@@ -238,15 +238,11 @@
man_node = get_manpage_node (filename ? filename : (*argv)[0]);
if (man_node)
{
- REFERENCE *new_ref;
+ add_pointer_to_array
+ (info_new_reference (MANPAGE_FILE_BUFFER_NAME,
+ filename ? filename : (*argv)[0]),
+ ref_index, ref_list, ref_slots, 2);
- free (man_node);
-
- new_ref = xzalloc (sizeof (REFERENCE));
- new_ref->filename = MANPAGE_FILE_BUFFER_NAME;
- new_ref->nodename = filename ? filename : (*argv)[0];
- add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
-
initial_file = MANPAGE_FILE_BUFFER_NAME;
return initial_file;
}
@@ -278,14 +274,11 @@
add_initial_nodes (FILE_BUFFER *initial_file, int argc, char **argv,
char **error)
{
- char *node_via_menus;
- int i;
-
- REFERENCE *new_ref;
-
/* Add nodes specified with --node. */
if (user_nodenames)
{
+ int i;
+
if (ref_index > 0)
{
/* Discard a dir entry that was found. */
@@ -295,18 +288,20 @@
for (i = 0; user_nodenames[i]; i++)
{
- new_ref = xzalloc (sizeof (REFERENCE));
+ char *node_filename;
/* Parse node spec to support invoking
like info --node "(emacs)Buffers". */
info_parse_node (user_nodenames[i], PARSE_NODE_VERBATIM);
if (info_parsed_filename)
- new_ref->filename = xstrdup (info_parsed_filename);
+ node_filename = xstrdup (info_parsed_filename);
else
- new_ref->filename = initial_file->fullpath;
- new_ref->nodename = xstrdup (info_parsed_nodename);
+ node_filename = initial_file->fullpath;
- add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
+ add_pointer_to_array
+ (info_new_reference (node_filename,
+ xstrdup (info_parsed_nodename)),
+ ref_index, ref_list, ref_slots, 2);
}
}
@@ -351,8 +346,8 @@
invoc_ref = info_intuit_options_node (top_node, program);
if (invoc_ref)
{
- new_ref = info_copy_reference (invoc_ref);
- add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
+ add_pointer_to_array (info_copy_reference (invoc_ref),
+ ref_index, ref_list, ref_slots, 2);
}
}
@@ -361,16 +356,13 @@
else if (*argv)
{
NODE *initial_node; /* Node to start following menus from. */
+ char *node_via_menus;
if (ref_index == 0)
- {
- new_ref = xzalloc (sizeof (REFERENCE));
- new_ref->filename = initial_file->fullpath;
- new_ref->nodename = "Top";
+ add_pointer_to_array
+ (info_new_reference (initial_file->fullpath, "Top"),
+ ref_index, ref_list, ref_slots, 2);
- 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);
@@ -383,10 +375,8 @@
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;
- ref_list[0] = new_ref;
+ ref_list[0] = info_new_reference (initial_file->fullpath,
+ node_via_menus);
}
/* If no nodes found, and there is exactly one argument remaining,
@@ -437,10 +427,8 @@
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;
- ref_list[0] = new_ref;
+ ref_list[0] = info_new_reference (initial_file->fullpath,
+ node_via_menus);
}
}
}
@@ -448,11 +436,8 @@
/* Default is "Top" if there were no other nodes. */
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);
+ add_pointer_to_array (info_new_reference (initial_file->fullpath, "Top"),
+ ref_index, ref_list, ref_slots, 2);
}
return;
@@ -504,7 +489,6 @@
int i;
char *searchdir;
- REFERENCE *new_ref;
NODE *man_node;
/* Check for dir entries first. */
@@ -512,7 +496,7 @@
for (searchdir = infopath_first (&i); searchdir;
searchdir = infopath_next (&i))
{
- new_ref = dir_entry_of_infodir (filename, searchdir);
+ REFERENCE *new_ref = dir_entry_of_infodir (filename, searchdir);
if (new_ref)
add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
@@ -540,9 +524,8 @@
if (j == ref_index)
{
- new_ref = xzalloc (sizeof (REFERENCE));
- new_ref->filename = p;
- add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
+ add_pointer_to_array (info_new_reference (p, 0),
+ ref_index, ref_list, ref_slots, 2);
}
}
@@ -551,11 +534,9 @@
if (man_node)
{
free (man_node);
-
- new_ref = xzalloc (sizeof (REFERENCE));
- new_ref->filename = MANPAGE_FILE_BUFFER_NAME;
- new_ref->nodename = filename;
- add_pointer_to_array (new_ref, ref_index, ref_list, ref_slots, 2);
+ add_pointer_to_array
+ (info_new_reference (MANPAGE_FILE_BUFFER_NAME, filename),
+ ref_index, ref_list, ref_slots, 2);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5615] info_new_reference added,
Gavin D. Smith <=