[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * info/scan.c (match_in_match_list): add an indic
From: |
Patrice Dumas |
Subject: |
branch master updated: * info/scan.c (match_in_match_list): add an indicatric variable such that index can be used solely as an index. |
Date: |
Sun, 06 Oct 2024 19:31:56 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 2b127be8fc * info/scan.c (match_in_match_list): add an indicatric
variable such that index can be used solely as an index.
2b127be8fc is described below
commit 2b127be8fc45132809211d99123fcaa3c8121ebb
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Oct 7 01:32:03 2024 +0200
* info/scan.c (match_in_match_list): add an indicatric variable such
that index can be used solely as an index.
* info/scan.c (read_bracketed_filename, read_quoted_string),
info/search.c (skip_whitespace, skip_whitespace_and_newlines)
(skip_non_whitespace, skip_node_separator), info/window.c
(window_point_to_column): return size_t as it is a length.
* info/window.c (window_get_cursor_column): return long as it is the
type of the variable assigned to.
* info/scan.c (read_quoted_string, skip_input), info/search.c
(match_in_match_list, match_by_index, at_end_of_matches): use size_t
in argument for an index in array, a length or a number.
* info/echo-area.c (ea_possible_completions)
(remove_completion_duplicates), info/info.c
(info_find_matching_files), info/infopath.c (infopath_add_dir),
info/nodemenu.c (get_visited_nodes), info/scan.c (read_quoted_string)
(parse_top_node_line, scan_reference_label, scan_reference_target),
info/search.c (match_in_match_list, find_file_section), info/session.c
(forget_window_and_nodes, point_forward_char, point_forward_word)
(gc_file_buffers_and_nodes, info_search_in_node_internal)
(wipe_seen_flags, info_tree_search, pop_isearch, show_isearch_prompt)
(initialize_byte_map), info/terminal.c (initialize_byte_map): use
size_t for variables representing length, numbers or indices in
arrays.
* info/echo-area.c (input_line_node, LCD_reference): complete with 0
for code clarity.
* info/session.c (info_handle_pointer): add const.
---
ChangeLog | 35 +++++++++++++++++++++++++++++++++++
info/echo-area.c | 15 ++++++++-------
info/info.c | 2 +-
info/infopath.c | 2 +-
info/nodemenu.c | 4 ++--
info/scan.c | 38 +++++++++++++++++++-------------------
info/scan.h | 4 ++--
info/search.c | 32 +++++++++++++++++---------------
info/search.h | 14 +++++++-------
info/session.c | 22 +++++++++++-----------
info/terminal.c | 11 ++++++-----
info/window.c | 6 +++---
info/window.h | 4 ++--
13 files changed, 114 insertions(+), 75 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b00bfe3c29..0b444750c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2024-10-06 Patrice Dumas <pertusus@free.fr>
+
+ * info/scan.c (match_in_match_list): add an indicatric variable such
+ that index can be used solely as an index.
+
+ * info/scan.c (read_bracketed_filename, read_quoted_string),
+ info/search.c (skip_whitespace, skip_whitespace_and_newlines)
+ (skip_non_whitespace, skip_node_separator), info/window.c
+ (window_point_to_column): return size_t as it is a length.
+
+ * info/window.c (window_get_cursor_column): return long as it is the
+ type of the variable assigned to.
+
+ * info/scan.c (read_quoted_string, skip_input), info/search.c
+ (match_in_match_list, match_by_index, at_end_of_matches): use size_t
+ in argument for an index in array, a length or a number.
+
+ * info/echo-area.c (ea_possible_completions)
+ (remove_completion_duplicates), info/info.c
+ (info_find_matching_files), info/infopath.c (infopath_add_dir),
+ info/nodemenu.c (get_visited_nodes), info/scan.c (read_quoted_string)
+ (parse_top_node_line, scan_reference_label, scan_reference_target),
+ info/search.c (match_in_match_list, find_file_section), info/session.c
+ (forget_window_and_nodes, point_forward_char, point_forward_word)
+ (gc_file_buffers_and_nodes, info_search_in_node_internal)
+ (wipe_seen_flags, info_tree_search, pop_isearch, show_isearch_prompt)
+ (initialize_byte_map), info/terminal.c (initialize_byte_map): use
+ size_t for variables representing length, numbers or indices in
+ arrays.
+
+ * info/echo-area.c (input_line_node, LCD_reference): complete with 0
+ for code clarity.
+
+ * info/session.c (info_handle_pointer): add const.
+
2024-10-06 Patrice Dumas <pertusus@free.fr>
* info/infomap.c (locate_init_file): initialize filename such that it
diff --git a/info/echo-area.c b/info/echo-area.c
index 61d7b5acbe..60ee79bb25 100644
--- a/info/echo-area.c
+++ b/info/echo-area.c
@@ -45,8 +45,8 @@ static int input_line_beg; /* End of prompt, and start
of user input. */
static int input_line_end; /* End of user input. */
static NODE input_line_node = {
- NULL, NULL, NULL, input_line,
- EA_MAX_INPUT, 0, N_IsInternal
+ NULL, NULL, NULL, input_line, EA_MAX_INPUT, 0,
+ N_IsInternal, 0, 0, 0, 0, 0, 0
};
static void echo_area_initialize_node (void);
@@ -1055,7 +1055,7 @@ DECLARE_INFO_COMMAND (ea_possible_completions, _("List
possible completions"))
/* Find the maximum length of a label. */
for (i = 0; i < completions_found_index; i++)
{
- int len = strlen (completions_found[i]->label);
+ size_t len = strlen (completions_found[i]->label);
if (len > max_label)
max_label = len;
}
@@ -1083,7 +1083,7 @@ DECLARE_INFO_COMMAND (ea_possible_completions, _("List
possible completions"))
/* Print the sorted items, up-and-down alphabetically. */
for (i = 0; i < iterations; i++)
{
- register int j;
+ register size_t j;
for (j = 0, l = i; j < limit; j++)
{
@@ -1092,7 +1092,8 @@ DECLARE_INFO_COMMAND (ea_possible_completions, _("List
possible completions"))
else
{
char *label;
- int printed_length, k;
+ size_t printed_length;
+ int k;
label = completions_found[l]->label;
printed_length = strlen (label);
@@ -1190,7 +1191,7 @@ DECLARE_INFO_COMMAND (ea_complete, _("Insert completion"))
/* Utility REFERENCE used to store possible LCD. */
static REFERENCE LCD_reference = {
- NULL, NULL, NULL, 0, 0, 0
+ NULL, NULL, NULL, 0, 0, 0, 0
};
static void remove_completion_duplicates (void);
@@ -1349,7 +1350,7 @@ remove_completion_duplicates (void)
{
size_t i, j;
REFERENCE **temp;
- int newlen;
+ size_t newlen;
if (!completions_found_index)
return;
diff --git a/info/info.c b/info/info.c
index 9970ebe70a..2a78ab5bf9 100644
--- a/info/info.c
+++ b/info/info.c
@@ -603,7 +603,7 @@ info_find_matching_files (char *filename)
while (1)
{
char *p;
- int j;
+ size_t j;
p = info_file_find_next_in_path (filename, &i, 0);
if (!p)
diff --git a/info/infopath.c b/info/infopath.c
index d18e4c78d0..d695de7bb6 100644
--- a/info/infopath.c
+++ b/info/infopath.c
@@ -158,7 +158,7 @@ infopath_add_dir (char *path)
{
struct stat dirinfo;
INFO_DIR *entry;
- int i;
+ size_t i;
if (stat (path, &dirinfo) == -1)
{
diff --git a/info/nodemenu.c b/info/nodemenu.c
index d988b88056..6eacbbd90b 100644
--- a/info/nodemenu.c
+++ b/info/nodemenu.c
@@ -117,7 +117,7 @@ static char *nodemenu_nodename = "*Node Menu*";
static NODE *
get_visited_nodes (void)
{
- register int i;
+ register size_t i;
WINDOW *info_win;
NODE *node;
char **lines = NULL;
@@ -147,7 +147,7 @@ get_visited_nodes (void)
/* Sort the array of information lines, if there are any. */
if (lines)
{
- register int j, newlen;
+ register size_t j, newlen;
char **temp;
qsort (lines, lines_index, sizeof (char *), compare_strings);
diff --git a/info/scan.c b/info/scan.c
index 007498dabc..93a130ba19 100644
--- a/info/scan.c
+++ b/info/scan.c
@@ -53,10 +53,10 @@ char *info_parsed_nodename = NULL;
/* Read a filename surrounded by "(" and ")", accounting for matching
characters, and place it in *FILENAME if FILENAME is not null. Return
length of read filename. On error, set *FILENAME to null and return 0. */
-int
+size_t
read_bracketed_filename (char *string, char **filename)
{
- register int i = 0;
+ register size_t i = 0;
int count = 0; /* Level of nesting. */
int first_close = -1; /* First ")" encountered. */
@@ -141,15 +141,15 @@ info_parse_node (char *string)
the number of lines that the string can span. If LINES is zero, there is no
limit. Return length of string including any quoting characters. Return
0 if input was invalid. */
-long
-read_quoted_string (char *start, char *terminator, int lines, char **output)
+size_t
+read_quoted_string (char *start, char *terminator, size_t lines, char **output)
{
- long len;
+ size_t len;
char *nl = 0, saved_char;
if (lines)
{
- int i;
+ size_t i;
nl = start;
for (i = 0; i < lines; i++)
{
@@ -645,7 +645,7 @@ degrade_utf8 (char **from, size_t *from_left)
for (erp = er; erp->from_string != 0; erp++)
{
/* Avoid reading past end of input. */
- int width = strlen (erp->from_string);
+ size_t width = strlen (erp->from_string);
if (width > *from_left)
continue;
@@ -896,7 +896,7 @@ copy_input_to_output (long n)
}
static void
-skip_input (long n)
+skip_input (size_t n)
{
if (preprocess_nodes_p)
{
@@ -954,7 +954,7 @@ parse_top_node_line (NODE *node)
char **store_in = 0;
char *nodename;
char *ptr;
- int value_length;
+ size_t value_length;
/* If the first line is empty, leave it in. This is the case
in the index-apropos window. */
@@ -1117,8 +1117,8 @@ scan_reference_marker (REFERENCE *entry, int
in_parentheses)
static int
scan_reference_label (REFERENCE *entry, int in_index)
{
- int max_lines;
- int len, label_len = 0;
+ size_t max_lines;
+ size_t len, label_len = 0;
/* Handle case of cross-reference like (FILE)NODE::. */
if (inptr[0] == '(' && !in_index)
@@ -1147,7 +1147,7 @@ scan_reference_label (REFERENCE *entry, int in_index)
as long as the node name does not contain a colon as well. */
char *p;
- int n, m = 0;
+ size_t n, m = 0;
p = inptr + label_len;
while (1)
@@ -1231,17 +1231,17 @@ scan_reference_label (REFERENCE *entry, int in_index)
static int
scan_reference_target (REFERENCE *entry, NODE *node, int in_parentheses)
{
- int i;
+ size_t i;
/* This entry continues with a specific target. Parse the
file name and node name from the specification. */
if (entry->type == REFERENCE_XREF)
{
- int length = 0; /* Length of specification */
+ size_t length = 0; /* Length of specification */
char *target_start = inptr;
char *nl_off = 0;
- int space_at_start_of_line = 0;
+ size_t space_at_start_of_line = 0;
length += skip_whitespace_and_newlines (inptr);
@@ -1274,7 +1274,7 @@ scan_reference_target (REFERENCE *entry, NODE *node, int
in_parentheses)
if (nl_off
&& nl_off < target_start + (length - space_at_start_of_line) / 2)
{
- int i;
+ size_t i;
write_extra_bytes_to_output ("\n", 1);
for (i = 0; i < space_at_start_of_line; i++)
@@ -1307,7 +1307,7 @@ scan_reference_target (REFERENCE *entry, NODE *node, int
in_parentheses)
a paragraph. */
if (nl_off && *inptr != '\n')
{
- int i;
+ size_t i;
write_extra_bytes_to_output ("\n", 1);
for (i = 0; i < space_at_start_of_line; i++)
@@ -1317,8 +1317,8 @@ scan_reference_target (REFERENCE *entry, NODE *node, int
in_parentheses)
}
else /* entry->type == REFERENCE_MENU_ITEM */
{
- int line_len;
- int length = 0; /* Length of specification */
+ size_t line_len;
+ size_t length = 0; /* Length of specification */
length = skip_whitespace (inptr);
length += read_bracketed_filename (inptr + length, &entry->filename);
diff --git a/info/scan.h b/info/scan.h
index 33eda61d00..60832c2ef3 100644
--- a/info/scan.h
+++ b/info/scan.h
@@ -35,8 +35,8 @@ extern char *info_parsed_nodename;
/* Parse the filename and nodename out of STRING. */
void info_parse_node (char *string);
-long read_quoted_string (char *start, char *terminator, int lines,
- char **output);
+size_t read_quoted_string (char *start, char *terminator, size_t lines,
+ char **output);
void scan_node_contents (NODE *node, FILE_BUFFER *fb, TAG **tag_ptr);
diff --git a/info/search.c b/info/search.c
index 6dbae26401..898f363a82 100644
--- a/info/search.c
+++ b/info/search.c
@@ -421,13 +421,14 @@ looking_at_line (char *string, char *pointer)
enum search_result
match_in_match_list (MATCH_STATE *match_state,
long start, long end, int dir,
- int *match_index)
+ size_t *match_index)
{
regmatch_t *matches = match_state->matches;
size_t match_count = match_state->match_count;
- int i;
- int index = -1;
+ size_t i;
+ size_t index;
+ int found = 0;
for (i = 0; i < match_count || !match_state->finished; i++)
{
@@ -448,6 +449,7 @@ match_in_match_list (MATCH_STATE *match_state,
if (matches[i].rm_so >= start)
{
index = i;
+ found = 1;
if (dir > 0)
{
*match_index = index;
@@ -456,7 +458,7 @@ match_in_match_list (MATCH_STATE *match_state,
}
}
- if (index != -1)
+ if (found)
{
*match_index = index;
return search_success;
@@ -468,7 +470,7 @@ match_in_match_list (MATCH_STATE *match_state,
/* Return match INDEX in STATE. INDEX must be a valid index. */
regmatch_t
-match_by_index (MATCH_STATE *state, int index)
+match_by_index (MATCH_STATE *state, size_t index)
{
while (state->match_alloc <= index)
extend_matches (state);
@@ -522,7 +524,7 @@ decide_if_in_match (long off, int *in_match,
/* Used for iterating through a match list. */
int
-at_end_of_matches (MATCH_STATE *state, int index)
+at_end_of_matches (MATCH_STATE *state, size_t index)
{
if (index < state->match_count)
return 0;
@@ -553,10 +555,10 @@ at_end_of_matches (MATCH_STATE *state, int index)
of -1 if the item being looked for couldn't be found. */
/* Return the index of the first non-whitespace character in STRING. */
-int
+size_t
skip_whitespace (char *string)
{
- register int i;
+ register size_t i;
for (i = 0; string && whitespace (string[i]); i++);
return i;
@@ -564,20 +566,20 @@ skip_whitespace (char *string)
/* Return the index of the first non-whitespace or newline character in
STRING. */
-int
+size_t
skip_whitespace_and_newlines (char *string)
{
- register int i;
+ register size_t i;
for (i = 0; string && whitespace_or_newline (string[i]); i++);
return i;
}
/* Return the index of the first whitespace character in STRING. */
-int
+size_t
skip_non_whitespace (char *string)
{
- register int i;
+ register size_t i;
for (i = 0; string && string[i] && !whitespace (string[i]); i++);
return i;
@@ -635,10 +637,10 @@ find_node_separator (SEARCH_BINDING *binding)
/* Return the length of the node separator characters that BODY is currently
pointing at. If it's not pointing at a node separator, return 0. */
-int
+size_t
skip_node_separator (char *body)
{
- register int i;
+ register size_t i;
i = 0;
@@ -677,7 +679,7 @@ find_file_section (SEARCH_BINDING *binding, char *label)
while ((position = find_node_separator (&s)) != -1 )
{
- long offset = position;
+ size_t offset = position;
offset += skip_node_separator (s.buffer + offset);
if (looking_at_line (label, s.buffer + offset))
return position;
diff --git a/info/search.h b/info/search.h
index c00e1ffbac..79f8d0bd42 100644
--- a/info/search.h
+++ b/info/search.h
@@ -72,22 +72,22 @@ int string_in_line (char *string, char *line);
with "find" are passed a SEARCH_BINDING, and return an absolute position
marker of the item being searched for. "Find" functions return a value
of -1 if the item being looked for couldn't be found. */
-int skip_whitespace (char *string);
-int skip_non_whitespace (char *string);
-int skip_whitespace_and_newlines (char *string);
-int skip_node_separator (char *body);
+size_t skip_whitespace (char *string);
+size_t skip_non_whitespace (char *string);
+size_t skip_whitespace_and_newlines (char *string);
+size_t skip_node_separator (char *body);
long find_node_separator (SEARCH_BINDING *binding);
long find_file_section (SEARCH_BINDING *binding, char *label);
long find_node_in_binding (char *nodename, SEARCH_BINDING *binding);
-regmatch_t match_by_index (MATCH_STATE *state, int index);
+regmatch_t match_by_index (MATCH_STATE *state, size_t index);
enum search_result match_in_match_list (MATCH_STATE *state,
- long start, long end, int dir, int *match_index);
+ long start, long end, int dir, size_t *match_index);
void free_matches (MATCH_STATE *state);
int matches_ready (MATCH_STATE *state);
-int at_end_of_matches (MATCH_STATE *state, int index);
+int at_end_of_matches (MATCH_STATE *state, size_t index);
void decide_if_in_match (long off, int *in_match, MATCH_STATE *matches,
size_t *match_index);
diff --git a/info/session.c b/info/session.c
index 107a22d9c3..92109afcb0 100644
--- a/info/session.c
+++ b/info/session.c
@@ -947,7 +947,7 @@ forget_node (WINDOW *win)
void
forget_window_and_nodes (WINDOW *win)
{
- int i;
+ size_t i;
for (i = 0; i < win->hist_index; i++)
{
free_history_node (win->hist[i]->node);
@@ -1142,7 +1142,7 @@ static void
point_forward_char (WINDOW *win)
{
long point = win->point;
- int col;
+ size_t col;
/* Find column in the line map after the current one that advances the
point. (This may not be the very next character if we are at a
@@ -1184,7 +1184,7 @@ point_backward_char (WINDOW *win)
static void
point_forward_word (WINDOW *win)
{
- int col;
+ size_t col;
col = window_point_to_column (win, win->point, &win->point);
@@ -1714,8 +1714,8 @@ gc_file_buffers_and_nodes (void)
/* Array to record whether each file buffer was referenced or not. */
int *fb_referenced = xcalloc (info_loaded_files_index, sizeof (int));
WINDOW *win;
- int i;
- int fb_index;
+ size_t i;
+ size_t fb_index;
/* Loop over nodes in the history of displayed windows recording
which file buffers were referenced. */
@@ -2940,7 +2940,7 @@ DECLARE_INFO_COMMAND (info_menu_sequence,
/* Get the node pointed to by the LABEL pointer of WINDOW->node into WINDOW.
Display error message if there is no such pointer, and return zero. */
static int
-info_handle_pointer (char *label, WINDOW *window)
+info_handle_pointer (const char *label, WINDOW *window)
{
char *description;
NODE *node;
@@ -3994,7 +3994,7 @@ info_search_in_node_internal (WINDOW *window, NODE *node,
enum search_result result = search_not_found;
long start1, end1;
- int match_index;
+ size_t match_index;
long new_point;
MATCH_STATE matches;
@@ -4629,7 +4629,7 @@ funexit:
void
wipe_seen_flags (void)
{
- int fb_index;
+ size_t fb_index;
TAG **t;
for (fb_index = 0; fb_index < info_loaded_files_index; fb_index++)
@@ -4648,7 +4648,7 @@ DECLARE_INFO_COMMAND (info_tree_search,
_("Search this node and subnodes for a string"))
{
char *prompt, *line;
- int i;
+ size_t i;
/* TODO: Display manual name */
/* TRANSLATORS: %s is the title of a node. */
@@ -4936,7 +4936,7 @@ pop_isearch (WINDOW *window, int *search_index, int
*direction,
static void
free_isearch_states (void)
{
- register int i;
+ register size_t i;
for (i = 0; i < isearch_states_index; i++)
{
@@ -4951,7 +4951,7 @@ static void
show_isearch_prompt (int dir, unsigned char *string,
enum search_result failing)
{
- register int i;
+ register size_t i;
const char *prefix;
char *prompt, *p_rep;
unsigned int prompt_len, p_rep_index, p_rep_size;
diff --git a/info/terminal.c b/info/terminal.c
index 69d1f0ed23..7ee10a167c 100644
--- a/info/terminal.c
+++ b/info/terminal.c
@@ -799,6 +799,7 @@ static void
initialize_byte_map (void)
{
int i;
+ size_t j;
static struct special_keys {
int key_id;
@@ -862,18 +863,18 @@ initialize_byte_map (void)
byte_seq_to_key['\177'].next = 0;
/* For each special key, record its byte sequence. */
- for (i = 0; i < sizeof (keys) / sizeof (*keys); i++)
+ for (j = 0; j < sizeof (keys) / sizeof (*keys); j++)
{
- if (!*keys[i].byte_seq)
+ if (!*keys[j].byte_seq)
continue; /* No byte sequence known for this key. */
- add_seq_to_byte_map (keys[i].key_id, *keys[i].byte_seq);
+ add_seq_to_byte_map (keys[j].key_id, *keys[j].byte_seq);
}
/* Hard-coded byte sequences. */
- for (i = 0; i < sizeof (keys2) / sizeof (*keys2); i++)
+ for (j = 0; j < sizeof (keys2) / sizeof (*keys2); j++)
{
- add_seq_to_byte_map (keys2[i].key_id, keys2[i].byte_seq);
+ add_seq_to_byte_map (keys2[j].key_id, keys2[j].byte_seq);
}
/* In case "normal tracking mode" is on. */
diff --git a/info/window.c b/info/window.c
index 70bfdc7fed..4ba4b7b60d 100644
--- a/info/window.c
+++ b/info/window.c
@@ -843,7 +843,7 @@ window_line_of_point (WINDOW *window)
}
/* Get and return the printed column offset of the cursor in this window. */
-int
+long
window_get_cursor_column (WINDOW *window)
{
return window_point_to_column (window, window->point, &window->point);
@@ -1323,10 +1323,10 @@ window_compute_line_map (WINDOW *win)
store there the value of point corresponding to the beginning of a
multibyte character in this column. If the character at POINT spans
multiple columns (e.g. a tab), return the leftmost column it occupies. */
-int
+size_t
window_point_to_column (WINDOW *win, long point, long *np)
{
- int i;
+ size_t i;
window_compute_line_map (win);
if (!win->line_map.map || point < win->line_map.map[0])
diff --git a/info/window.h b/info/window.h
index 4a4adba1a8..1ed7a69a02 100644
--- a/info/window.h
+++ b/info/window.h
@@ -220,11 +220,11 @@ void window_clear_echo_area (void);
int window_line_of_point (WINDOW *window);
/* Get and return the printed column offset of the cursor in this window. */
-int window_get_cursor_column (WINDOW *window);
+long window_get_cursor_column (WINDOW *window);
void window_compute_line_map (WINDOW *win);
-int window_point_to_column (WINDOW *win, long point, long *np);
+size_t window_point_to_column (WINDOW *win, long point, long *np);
void window_line_map_init (WINDOW *win);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * info/scan.c (match_in_match_list): add an indicatric variable such that index can be used solely as an index.,
Patrice Dumas <=