[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5842] info_indices_of_file_buffer declared static
From: |
Gavin D. Smith |
Subject: |
[5842] info_indices_of_file_buffer declared static |
Date: |
Sun, 28 Sep 2014 18:47:29 +0000 |
Revision: 5842
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5842
Author: gavin
Date: 2014-09-28 18:47:27 +0000 (Sun, 28 Sep 2014)
Log Message:
-----------
info_indices_of_file_buffer declared static
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/indices.c
trunk/info/indices.h
trunk/info/info.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-09-28 17:06:14 UTC (rev 5841)
+++ trunk/ChangeLog 2014-09-28 18:47:27 UTC (rev 5842)
@@ -6,6 +6,13 @@
with character encodings. Introductory text changed to be more
descriptive.
+ * info/indices.c (look_in_indices): New function, split from:
+ * info/info.c (add_initial_nodes) <index search>
+ * info/indices.c (info_indices_of_file_buffer): Declared static.
+ Return type is void. Clear 'index_index' variable if no file
+ buffer.
+ (index_nodenames): Comment changed.
+
2014-09-24 Gavin Smith <address@hidden>
* info/doc.h (InfoCommand): Removed. All uses updated.
Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c 2014-09-28 17:06:14 UTC (rev 5841)
+++ trunk/info/indices.c 2014-09-28 18:47:27 UTC (rev 5842)
@@ -52,7 +52,9 @@
int last; /* The index in our list of the last entry. */
} INDEX_NAME_ASSOC;
-/* An array associating index nodenames with index offset ranges. */
+/* An array associating index nodenames with index offset ranges. Used
+ for reporting to the user which index node an index entry was found
+ in. */
static INDEX_NAME_ASSOC **index_nodenames = NULL;
static size_t index_nodenames_index = 0;
static size_t index_nodenames_slots = 0;
@@ -85,20 +87,25 @@
index_nodenames_slots, 10);
}
-/* Find and concatenate the indices of FILE_BUFFER. The indices are defined
- as the first node in the file containing the word "Index" and any
- immediately following nodes whose names also contain "Index". All such
- indices are concatenated and the result returned. Neither the returned
- array nor its elements should be freed by the caller. */
-REFERENCE **
+/* Find and concatenate the indices of FILE_BUFFER, saving the result in
+ INDEX_INDEX. The indices are defined as the first node in the file
+ containing the word "Index" and any immediately following nodes whose names
+ also contain "Index". All such indices are concatenated and the result
+ returned. */
+static void
info_indices_of_file_buffer (FILE_BUFFER *file_buffer)
{
register int i;
REFERENCE **result = NULL;
+ free (index_index);
+
/* No file buffer, no indices. */
if (!file_buffer)
- return NULL;
+ {
+ index_index = 0;
+ return;
+ }
/* Reset globals describing where the index was found. */
free (initial_index_filename);
@@ -168,11 +175,7 @@
if (!result[i]->filename)
result[i]->filename = xstrdup (file_buffer->filename);
- /* Store result so that if we call do_info_index_search later, it
- will be set. */
- free (index_index);
index_index = result;
- return result;
}
DECLARE_INFO_COMMAND (info_index_search,
@@ -297,8 +300,7 @@
!fb ||
(FILENAME_CMP (initial_index_filename, fb->filename) != 0))
{
- free (index_index);
- index_index = info_indices_of_file_buffer (fb);
+ info_indices_of_file_buffer (fb);
}
/* If there is no index, that is an error. */
@@ -478,6 +480,34 @@
info_select_reference (window, index_index[i]);
}
+
+/* Look for the best match of STRING in the indices of FB. Return null if no
+ match is found. Return value should not be freed or modified. */
+REFERENCE *
+look_in_indices (FILE_BUFFER *fb, char *string)
+{
+ REFERENCE **index_ptr;
+ REFERENCE *nearest = 0;
+
+ info_indices_of_file_buffer (fb); /* Sets index_index. */
+ if (!index_index)
+ return 0;
+
+ for (index_ptr = index_index; *index_ptr; index_ptr++)
+ {
+ if (!strcmp (string, (*index_ptr)->label))
+ {
+ nearest = *index_ptr;
+ break;
+ }
+ /* Case-insensitive initial substring. */
+ if (!nearest && !mbsncasecmp (string, (*index_ptr)->label,
+ mbslen (string)))
+ {
+ nearest = *index_ptr;
+ }
+ }
+}
/* **************************************************************** */
/* */
@@ -536,7 +566,8 @@
if (this_fb && inform)
message_in_echo_area (_("Scanning indices of '%s'..."),
this_item->filename);
- this_index = info_indices_of_file_buffer (this_fb);
+ info_indices_of_file_buffer (this_fb);
+ this_index = index_index;
if (this_fb && inform)
unmessage_in_echo_area ();
@@ -745,9 +776,8 @@
!fb ||
(FILENAME_CMP (initial_index_filename, fb->filename) != 0))
{
- free (index_index);
window_message_in_echo_area (_("Finding index entries..."));
- index_index = info_indices_of_file_buffer (fb);
+ info_indices_of_file_buffer (fb);
}
if (!index_index)
Modified: trunk/info/indices.h
===================================================================
--- trunk/info/indices.h 2014-09-28 17:06:14 UTC (rev 5841)
+++ trunk/info/indices.h 2014-09-28 18:47:27 UTC (rev 5842)
@@ -25,8 +25,6 @@
/* User-visible variable controls the output of info-index-next. */
extern int show_index_match;
-extern REFERENCE **info_indices_of_file_buffer (FILE_BUFFER *file_buffer);
-
/* For every menu item in DIR, search the indices of that file for STRING. */
REFERENCE **apropos_in_all_indices (char *search_string, int inform);
@@ -36,6 +34,7 @@
extern void info_index_apropos (WINDOW *window, int count, int key);
extern void do_info_index_search (WINDOW *window, FILE_BUFFER *fb, int count,
char *search_string);
extern int index_entry_exists (FILE_BUFFER *fb, char *string);
+REFERENCE *look_in_indices (FILE_BUFFER *fb, char *string);
#define APROPOS_NONE \
N_("No available info files have '%s' in their indices.")
Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c 2014-09-28 17:06:14 UTC (rev 5841)
+++ trunk/info/info.c 2014-09-28 18:47:27 UTC (rev 5842)
@@ -409,27 +409,10 @@
check for it as an index entry. */
else if (argc == 1 && argv[0])
{
- REFERENCE **index;
- REFERENCE **index_ptr;
+ REFERENCE *nearest;
- REFERENCE *nearest = 0;
-
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))
- {
- nearest = *index_ptr;
- break;
- }
- /* Case-insensitive initial substring. */
- if (!nearest && !mbsncasecmp (argv[0], (*index_ptr)->label,
- mbslen (argv[0])))
- nearest = *index_ptr;
- }
-
+ nearest = look_in_indices (initial_file, argv[0]);
if (nearest)
{
argv += argc; argc = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5842] info_indices_of_file_buffer declared static,
Gavin D. Smith <=