[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7658] next_index_match
From: |
gavinsmith0123 |
Subject: |
[7658] next_index_match |
Date: |
Thu, 2 Feb 2017 15:58:04 -0500 (EST) |
Revision: 7658
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7658
Author: gavin
Date: 2017-02-02 15:58:04 -0500 (Thu, 02 Feb 2017)
Log Message:
-----------
next_index_match
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/indices.c
trunk/info/indices.h
trunk/info/info.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2017-02-02 20:42:00 UTC (rev 7657)
+++ trunk/ChangeLog 2017-02-02 20:58:04 UTC (rev 7658)
@@ -1,5 +1,12 @@
2017-02-02 Gavin Smith <address@hidden>
+ * info/indices.c (next_index_match): Return a value instead of
+ passing a pointer to a value to be set so that it is clear that
+ calling code does not depend on an uninitialized value. All
+ callers updated. (Report from Hans-Bernhard Br\xF6ker.)
+
+2017-02-02 Gavin Smith <address@hidden>
+
* info/display.c (display_update_one_window): Remove a useless
check of a null pointer. Report from Hans-Bernhard Br\xF6ker,
found using static code analysis with clang.
Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c 2017-02-02 20:42:00 UTC (rev 7657)
+++ trunk/info/indices.c 2017-02-02 20:58:04 UTC (rev 7658)
@@ -2,7 +2,7 @@
$Id$
Copyright 1993, 1997, 1998, 1999, 2002, 2003, 2004, 2007, 2008, 2011,
- 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
+ 2013, 2014, 2015, 2016, 2017 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
@@ -300,17 +300,18 @@
initial matches, then non-initial substrings, updating the values of
INDEX_INITIAL and INDEX_PARTIAL.
- If a match is found, set *RESULT to the matching index entry, and
- *FOUND_OFFSET to its offset in INDEX_INDEX. Otherwise set *RESULT to null.
+ If a match is found, return a pointer to the matching index entry, and
+ set *FOUND_OFFSET to its offset in INDEX_INDEX. Otherwise, return null.
If we found a partial match, set *MATCH_OFFSET to the end of the match
within the index entry text, else to 0. */
-void
+REFERENCE *
next_index_match (FILE_BUFFER *fb, char *string, int offset, int dir,
- REFERENCE **result, int *found_offset, int *match_offset)
+ int *found_offset, int *match_offset)
{
int i;
int partial_match;
size_t search_len;
+ REFERENCE *result;
partial_match = 0;
search_len = strlen (string);
@@ -319,7 +320,7 @@
if (!index_index)
{
info_error (_("No indices found."));
- return;
+ return 0;
}
if (index_search != string)
@@ -382,14 +383,15 @@
}
if (i < 0 || !index_index[i])
- *result = 0;
+ result = 0;
else
{
index_offset = i;
- *result = index_index[i];
+ result = index_index[i];
}
*found_offset = i;
+ return result;
}
/* Display a message saying where the index match was found. */
@@ -465,8 +467,8 @@
else
dir = 1;
- next_index_match (file_buffer_of_window (window), index_search, index_offset,
- dir, &result, &i, &match_offset);
+ result = next_index_match (file_buffer_of_window (window), index_search,
+ index_offset, dir, &i, &match_offset);
/* If that failed, print an error. */
if (!result)
@@ -832,8 +834,8 @@
REFERENCE *result;
int match_offset;
- next_index_match (file_buffer, index_search, index_offset, 1, &result,
- &i, &match_offset);
+ result = next_index_match (file_buffer, index_search, index_offset, 1,
+ &i, &match_offset);
if (!result)
break;
format_reference (index_index[i],
Modified: trunk/info/indices.h
===================================================================
--- trunk/info/indices.h 2017-02-02 20:42:00 UTC (rev 7657)
+++ trunk/info/indices.h 2017-02-02 20:58:04 UTC (rev 7658)
@@ -1,7 +1,7 @@
/* indices.h -- Functions defined in indices.c.
$Id$
- Copyright 1993, 1997, 2004, 2007, 2013, 2014, 2015, 2016
+ Copyright 1993, 1997, 2004, 2007, 2013, 2014, 2015, 2016, 2017
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -31,8 +31,9 @@
/* User visible functions declared in indices.c. */
void info_index_search (WINDOW *window, int count);
void info_index_apropos (WINDOW *window, int count);
-void next_index_match (FILE_BUFFER *fb, char *string, int offset, int dir,
- REFERENCE **result, int *found_offset, int *match_offset);
+REFERENCE *next_index_match (FILE_BUFFER *fb, char *string,
+ int offset, int dir,
+ int *found_offset, int *match_offset);
void report_index_match (int i, int match_offset);
REFERENCE *look_in_indices (FILE_BUFFER *fb, char *string, int sloppy);
NODE *create_virtual_index (FILE_BUFFER *file_buffer, char *index_search);
Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c 2017-02-02 20:42:00 UTC (rev 7657)
+++ trunk/info/info.c 2017-02-02 20:58:04 UTC (rev 7658)
@@ -2,8 +2,8 @@
$Id$
Copyright 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
- Free Software Foundation, Inc.
+ 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015,
+ 2016, 2017 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
@@ -1026,8 +1026,8 @@
REFERENCE *result;
int i, match_offset;
- next_index_match (initial_fb, index_search_string, 0, 1,
- &result, &i, &match_offset);
+ result = next_index_match (initial_fb, index_search_string, 0, 1,
+ &i, &match_offset);
if (result)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7658] next_index_match,
gavinsmith0123 <=