Mercurial > emacs
changeset 110507:875202ac5b45
Fix use of int instead of EMACS_INT in search.c and region-cache.c.
indent.c (compute_motion): Use EMACS_INT for arguments to
region_cache_forward.
region-cache.c (struct boundary, struct region_cache): Use
EMACS_INT for positions.
(find_cache_boundary, move_cache_gap, insert_cache_boundary)
(delete_cache_boundaries, set_cache_region)
(invalidate_region_cache, know_region_cache)
(region_cache_forward, region_cache_backward, pp_cache): Use
EMACS_INT for buffer positions.
region-cache.h (know_region_cache, invalidate_region_cache)
(region_cache_forward, region_cache_backward): Adjust prototypes.
search.c (string_match_1, fast_c_string_match_ignore_case)
(looking_at_1, scan_buffer, scan_newline)
(find_next_newline_no_quit, find_before_next_newline)
(search_command, trivial_regexp_p, search_buffer, simple_search)
(boyer_moore, wordify, Freplace_match): Use EMACS_INT for buffer
and string positions and length.
lisp.h (scan_buffer, scan_newline, find_next_newline_no_quit)
(find_before_next_newline): Adjust prototypes.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Thu, 23 Sep 2010 14:35:11 -0400 |
parents | 2cac83f5f8bc |
children | 2a5932eef2ba |
files | src/ChangeLog src/indent.c src/lisp.h src/region-cache.c src/region-cache.h src/search.c |
diffstat | 6 files changed, 126 insertions(+), 83 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Thu Sep 23 13:10:21 2010 -0400 +++ b/src/ChangeLog Thu Sep 23 14:35:11 2010 -0400 @@ -1,5 +1,28 @@ 2010-09-23 Eli Zaretskii <eliz@gnu.org> + * indent.c (compute_motion): Use EMACS_INT for arguments to + region_cache_forward. + + * region-cache.c (struct boundary, struct region_cache): Use + EMACS_INT for positions. + (find_cache_boundary, move_cache_gap, insert_cache_boundary) + (delete_cache_boundaries, set_cache_region) + (invalidate_region_cache, know_region_cache) + (region_cache_forward, region_cache_backward, pp_cache): Use + EMACS_INT for buffer positions. + + * region-cache.h (know_region_cache, invalidate_region_cache) + (region_cache_forward, region_cache_backward): Adjust prototypes. + + * search.c (string_match_1, fast_c_string_match_ignore_case) + (looking_at_1, scan_buffer, scan_newline) + (find_next_newline_no_quit, find_before_next_newline) + (search_command, trivial_regexp_p, search_buffer, simple_search) + (boyer_moore, wordify, Freplace_match): Use EMACS_INT for buffer + and string positions and length. + + * lisp.h (scan_buffer, scan_newline, find_next_newline_no_quit, find_before_next_newline) + * editfns.c (transpose_markers, update_buffer_properties) (buildmark, clip_to_bounds, Fgoto_char, overlays_around) (get_pos_property, Fconstrain_to_field) @@ -8,6 +31,7 @@ (Finsert_buffer_substring, Fcompare_buffer_substrings) (Fsubst_char_in_region, Fformat, Ftranspose_regions): Use EMACS_INT for buffer and string position variables. + (Finsert_char): Protect against too large insertions. * lisp.h (clip_to_bounds): Adjust prototype.
--- a/src/indent.c Thu Sep 23 13:10:21 2010 -0400 +++ b/src/indent.c Thu Sep 23 14:35:11 2010 -0400 @@ -1448,7 +1448,7 @@ the text character-by-character. */ if (current_buffer->width_run_cache && pos >= next_width_run) { - int run_end; + EMACS_INT run_end; int common_width = region_cache_forward (current_buffer, current_buffer->width_run_cache,
--- a/src/lisp.h Thu Sep 23 13:10:21 2010 -0400 +++ b/src/lisp.h Thu Sep 23 14:35:11 2010 -0400 @@ -3122,12 +3122,13 @@ extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object); extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, Lisp_Object); -extern int scan_buffer (int, EMACS_INT, EMACS_INT, int, int *, int); -extern int scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, - int, int); -extern int find_next_newline (EMACS_INT, int); -extern int find_next_newline_no_quit (EMACS_INT, int); -extern int find_before_next_newline (EMACS_INT, EMACS_INT, int); +extern EMACS_INT scan_buffer (int, EMACS_INT, EMACS_INT, EMACS_INT, + int *, int); +extern EMACS_INT scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, + EMACS_INT, int); +extern EMACS_INT find_next_newline (EMACS_INT, int); +extern EMACS_INT find_next_newline_no_quit (EMACS_INT, EMACS_INT); +extern EMACS_INT find_before_next_newline (EMACS_INT, EMACS_INT, EMACS_INT); extern void syms_of_search (void); extern void clear_regexp_cache (void);
--- a/src/region-cache.c Thu Sep 23 13:10:21 2010 -0400 +++ b/src/region-cache.c Thu Sep 23 14:35:11 2010 -0400 @@ -62,7 +62,7 @@ revalidate_region_cache to see how this helps. */ struct boundary { - int pos; + EMACS_INT pos; int value; }; @@ -72,7 +72,7 @@ struct boundary *boundaries; /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap. */ - int gap_start, gap_len; + EMACS_INT gap_start, gap_len; /* The number of elements allocated to boundaries, not including the gap. */ @@ -81,7 +81,7 @@ /* The areas that haven't changed since the last time we cleaned out invalid entries from the cache. These overlap when the buffer is entirely unchanged. */ - int beg_unchanged, end_unchanged; + EMACS_INT beg_unchanged, end_unchanged; /* The first and last positions in the buffer. Because boundaries store their positions relative to the start (BEG) and end (Z) of @@ -91,7 +91,7 @@ Yes, buffer_beg is always 1. It's there for symmetry with buffer_end and the BEG and BUF_BEG macros. */ - int buffer_beg, buffer_end; + EMACS_INT buffer_beg, buffer_end; }; /* Return the position of boundary i in cache c. */ @@ -173,7 +173,7 @@ entries. It would be nice if it took advantage of locality of reference, too, by searching entries near the last entry found. */ static int -find_cache_boundary (struct region_cache *c, int pos) +find_cache_boundary (struct region_cache *c, EMACS_INT pos) { int low = 0, high = c->cache_len; @@ -182,7 +182,7 @@ /* mid is always a valid index, because low < high and ">> 1" rounds down. */ int mid = (low + high) >> 1; - int boundary = BOUNDARY_POS (c, mid); + EMACS_INT boundary = BOUNDARY_POS (c, mid); if (pos < boundary) high = mid; @@ -207,13 +207,13 @@ /* Move the gap of cache C to index POS, and make sure it has space for at least MIN_SIZE boundaries. */ static void -move_cache_gap (struct region_cache *c, int pos, int min_size) +move_cache_gap (struct region_cache *c, EMACS_INT pos, int min_size) { /* Copy these out of the cache and into registers. */ - int gap_start = c->gap_start; - int gap_len = c->gap_len; - int buffer_beg = c->buffer_beg; - int buffer_end = c->buffer_end; + EMACS_INT gap_start = c->gap_start; + EMACS_INT gap_len = c->gap_len; + EMACS_INT buffer_beg = c->buffer_beg; + EMACS_INT buffer_end = c->buffer_end; if (pos < 0 || pos > c->cache_len) @@ -245,7 +245,7 @@ when the portion after the gap is smallest. */ if (gap_len < min_size) { - int i; + EMACS_INT i; /* Always make at least NEW_CACHE_GAP elements, as long as we're expanding anyway. */ @@ -292,7 +292,8 @@ /* Insert a new boundary in cache C; it will have cache index INDEX, and have the specified POS and VALUE. */ static void -insert_cache_boundary (struct region_cache *c, int index, int pos, int value) +insert_cache_boundary (struct region_cache *c, int index, EMACS_INT pos, + int value) { /* index must be a valid cache index. */ if (index < 0 || index > c->cache_len) @@ -328,9 +329,10 @@ /* Delete the i'th entry from cache C if START <= i < END. */ static void -delete_cache_boundaries (struct region_cache *c, int start, int end) +delete_cache_boundaries (struct region_cache *c, + EMACS_INT start, EMACS_INT end) { - int len = end - start; + EMACS_INT len = end - start; /* Gotta be in range. */ if (start < 0 @@ -380,7 +382,8 @@ /* Set the value in cache C for the region START..END to VALUE. */ static void -set_cache_region (struct region_cache *c, int start, int end, int value) +set_cache_region (struct region_cache *c, + EMACS_INT start, EMACS_INT end, int value) { if (start > end) abort (); @@ -481,7 +484,8 @@ buffer positions in the presence of insertions and deletions; the args to pass are the same before and after such an operation.) */ void -invalidate_region_cache (struct buffer *buf, struct region_cache *c, int head, int tail) +invalidate_region_cache (struct buffer *buf, struct region_cache *c, + EMACS_INT head, EMACS_INT tail) { /* Let chead = c->beg_unchanged, and ctail = c->end_unchanged. @@ -687,7 +691,8 @@ buffer positions) is "known," for the purposes of CACHE (e.g. "has no newlines", in the case of the line cache). */ void -know_region_cache (struct buffer *buf, struct region_cache *c, int start, int end) +know_region_cache (struct buffer *buf, struct region_cache *c, + EMACS_INT start, EMACS_INT end) { revalidate_region_cache (buf, c); @@ -701,7 +706,8 @@ the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest position after POS where the knownness changes. */ int -region_cache_forward (struct buffer *buf, struct region_cache *c, int pos, int *next) +region_cache_forward (struct buffer *buf, struct region_cache *c, + EMACS_INT pos, EMACS_INT *next) { revalidate_region_cache (buf, c); @@ -736,7 +742,8 @@ /* Return true if the text immediately before POS in BUF is known, for the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest position before POS where the knownness changes. */ -int region_cache_backward (struct buffer *buf, struct region_cache *c, int pos, int *next) +int region_cache_backward (struct buffer *buf, struct region_cache *c, + EMACS_INT pos, EMACS_INT *next) { revalidate_region_cache (buf, c); @@ -777,8 +784,8 @@ pp_cache (struct region_cache *c) { int i; - int beg_u = c->buffer_beg + c->beg_unchanged; - int end_u = c->buffer_end - c->end_unchanged; + EMACS_INT beg_u = c->buffer_beg + c->beg_unchanged; + EMACS_INT end_u = c->buffer_end - c->end_unchanged; fprintf (stderr, "basis: %d..%d modified: %d..%d\n",
--- a/src/region-cache.h Thu Sep 23 13:10:21 2010 -0400 +++ b/src/region-cache.h Thu Sep 23 14:35:11 2010 -0400 @@ -71,7 +71,7 @@ no newlines", in the case of the line cache). */ extern void know_region_cache (struct buffer *BUF, struct region_cache *CACHE, - int START, int END); + EMACS_INT START, EMACS_INT END); /* Indicate that a section of BUF has changed, to invalidate CACHE. HEAD is the number of chars unchanged at the beginning of the buffer. @@ -83,7 +83,7 @@ args to pass are the same before and after such an operation.) */ extern void invalidate_region_cache (struct buffer *BUF, struct region_cache *CACHE, - int HEAD, int TAIL); + EMACS_INT HEAD, EMACS_INT TAIL); /* The scanning functions. @@ -99,16 +99,16 @@ position after POS where the knownness changes. */ extern int region_cache_forward (struct buffer *BUF, struct region_cache *CACHE, - int POS, - int *NEXT); + EMACS_INT POS, + EMACS_INT *NEXT); /* Return true if the text immediately before POS in BUF is known, for the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest position before POS where the knownness changes. */ extern int region_cache_backward (struct buffer *BUF, struct region_cache *CACHE, - int POS, - int *NEXT); + EMACS_INT POS, + EMACS_INT *NEXT); /* arch-tag: 70f79125-ef22-4f58-9aec-a48ca2791435 (do not change this comment) */
--- a/src/search.c Thu Sep 23 13:10:21 2010 -0400 +++ b/src/search.c Thu Sep 23 14:35:11 2010 -0400 @@ -100,15 +100,15 @@ static void set_search_regs (EMACS_INT, EMACS_INT); static void save_search_regs (void); -static EMACS_INT simple_search (int, unsigned char *, int, int, - Lisp_Object, EMACS_INT, EMACS_INT, +static EMACS_INT simple_search (EMACS_INT, unsigned char *, EMACS_INT, + EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT); -static EMACS_INT boyer_moore (int, unsigned char *, int, int, +static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, EMACS_INT, EMACS_INT, Lisp_Object, Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, int); static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT, - EMACS_INT, EMACS_INT, int, int, + EMACS_INT, EMACS_INT, EMACS_INT, int, Lisp_Object, Lisp_Object, int); static void matcher_overflow (void) NO_RETURN; @@ -286,7 +286,7 @@ Lisp_Object val; unsigned char *p1, *p2; EMACS_INT s1, s2; - register int i; + register EMACS_INT i; struct re_pattern_buffer *bufp; if (running_asynch_code) @@ -396,7 +396,7 @@ pos = 0, pos_byte = 0; else { - int len = SCHARS (string); + EMACS_INT len = SCHARS (string); CHECK_NUMBER (start); pos = XINT (start); @@ -509,7 +509,7 @@ { int val; struct re_pattern_buffer *bufp; - int len = strlen (string); + size_t len = strlen (string); regexp = string_make_unibyte (regexp); re_match_object = Qt; @@ -654,8 +654,9 @@ If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do except when inside redisplay. */ -int -scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int *shortage, int allow_quit) +EMACS_INT +scan_buffer (register int target, EMACS_INT start, EMACS_INT end, + EMACS_INT count, int *shortage, int allow_quit) { struct region_cache *newline_cache; int direction; @@ -695,7 +696,7 @@ to see where we can avoid some scanning. */ if (target == '\n' && newline_cache) { - int next_change; + EMACS_INT next_change; immediate_quit = 0; while (region_cache_forward (current_buffer, newline_cache, start_byte, &next_change)) @@ -767,7 +768,7 @@ /* Consult the newline cache, if appropriate. */ if (target == '\n' && newline_cache) { - int next_change; + EMACS_INT next_change; immediate_quit = 0; while (region_cache_backward (current_buffer, newline_cache, start_byte, &next_change)) @@ -846,8 +847,10 @@ If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do except in special cases. */ -int -scan_newline (EMACS_INT start, EMACS_INT start_byte, EMACS_INT limit, EMACS_INT limit_byte, register int count, int allow_quit) +EMACS_INT +scan_newline (EMACS_INT start, EMACS_INT start_byte, + EMACS_INT limit, EMACS_INT limit_byte, + register EMACS_INT count, int allow_quit) { int direction = ((count > 0) ? 1 : -1); @@ -940,8 +943,8 @@ return count * direction; } -int -find_next_newline_no_quit (EMACS_INT from, int cnt) +EMACS_INT +find_next_newline_no_quit (EMACS_INT from, EMACS_INT cnt) { return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0); } @@ -950,11 +953,11 @@ not after, and only search up to TO. This isn't just find_next_newline (...)-1, because you might hit TO. */ -int -find_before_next_newline (EMACS_INT from, EMACS_INT to, int cnt) +EMACS_INT +find_before_next_newline (EMACS_INT from, EMACS_INT to, EMACS_INT cnt) { int shortage; - int pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); + EMACS_INT pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); if (shortage == 0) pos--; @@ -965,10 +968,11 @@ /* Subroutines of Lisp buffer search functions. */ static Lisp_Object -search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count, int direction, int RE, int posix) +search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, + Lisp_Object count, int direction, int RE, int posix) { register int np; - int lim, lim_byte; + EMACS_INT lim, lim_byte; int n = direction; if (!NILP (count)) @@ -1044,7 +1048,7 @@ static int trivial_regexp_p (Lisp_Object regexp) { - int len = SBYTES (regexp); + EMACS_INT len = SBYTES (regexp); unsigned char *s = SDATA (regexp); while (--len >= 0) { @@ -1109,11 +1113,11 @@ static EMACS_INT search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte, - EMACS_INT lim, EMACS_INT lim_byte, int n, + EMACS_INT lim, EMACS_INT lim_byte, EMACS_INT n, int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix) { - int len = SCHARS (string); - int len_byte = SBYTES (string); + EMACS_INT len = SCHARS (string); + EMACS_INT len_byte = SBYTES (string); register int i; if (running_asynch_code) @@ -1130,7 +1134,7 @@ if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp))) { unsigned char *p1, *p2; - int s1, s2; + EMACS_INT s1, s2; struct re_pattern_buffer *bufp; bufp = compile_pattern (string, @@ -1166,7 +1170,7 @@ while (n < 0) { - int val; + EMACS_INT val; val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, pos_byte - BEGV_BYTE, lim_byte - pos_byte, (NILP (Vinhibit_changing_match_data) @@ -1210,7 +1214,7 @@ } while (n > 0) { - int val; + EMACS_INT val; val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, pos_byte - BEGV_BYTE, lim_byte - pos_byte, (NILP (Vinhibit_changing_match_data) @@ -1255,8 +1259,8 @@ else /* non-RE case */ { unsigned char *raw_pattern, *pat; - int raw_pattern_size; - int raw_pattern_size_byte; + EMACS_INT raw_pattern_size; + EMACS_INT raw_pattern_size_byte; unsigned char *patbuf; int multibyte = !NILP (current_buffer->enable_multibyte_characters); unsigned char *base_pat; @@ -1450,13 +1454,16 @@ boyer_moore cannot work. */ static EMACS_INT -simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT lim, EMACS_INT lim_byte) +simple_search (EMACS_INT n, unsigned char *pat, + EMACS_INT len, EMACS_INT len_byte, Lisp_Object trt, + EMACS_INT pos, EMACS_INT pos_byte, + EMACS_INT lim, EMACS_INT lim_byte) { int multibyte = ! NILP (current_buffer->enable_multibyte_characters); int forward = n > 0; /* Number of buffer bytes matched. Note that this may be different from len_byte in a multibyte buffer. */ - int match_byte; + EMACS_INT match_byte; if (lim > pos && multibyte) while (n > 0) @@ -1466,7 +1473,7 @@ /* Try matching at position POS. */ EMACS_INT this_pos = pos; EMACS_INT this_pos_byte = pos_byte; - int this_len = len; + EMACS_INT this_len = len; unsigned char *p = pat; if (pos + len > lim || pos_byte + len_byte > lim_byte) goto stop; @@ -1511,7 +1518,7 @@ { /* Try matching at position POS. */ EMACS_INT this_pos = pos; - int this_len = len; + EMACS_INT this_len = len; unsigned char *p = pat; if (pos + len > lim) @@ -1551,7 +1558,7 @@ /* Try matching at position POS. */ EMACS_INT this_pos = pos; EMACS_INT this_pos_byte = pos_byte; - int this_len = len; + EMACS_INT this_len = len; const unsigned char *p = pat + len_byte; if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte) @@ -1594,7 +1601,7 @@ { /* Try matching at position POS. */ EMACS_INT this_pos = pos - len; - int this_len = len; + EMACS_INT this_len = len; unsigned char *p = pat; if (this_pos < lim) @@ -1657,18 +1664,20 @@ If that criterion is not satisfied, do not call this function. */ static EMACS_INT -boyer_moore (int n, unsigned char *base_pat, int len, int len_byte, +boyer_moore (EMACS_INT n, unsigned char *base_pat, + EMACS_INT len, EMACS_INT len_byte, Lisp_Object trt, Lisp_Object inverse_trt, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT lim, EMACS_INT lim_byte, int char_base) { int direction = ((n > 0) ? 1 : -1); - register int dirlen; + register EMACS_INT dirlen; EMACS_INT limit; int stride_for_teases = 0; int BM_tab[0400]; register unsigned char *cursor, *p_limit; - register int i, j; + register EMACS_INT i; + register int j; unsigned char *pat, *pat_end; int multibyte = ! NILP (current_buffer->enable_multibyte_characters); @@ -2098,10 +2107,11 @@ wordify (Lisp_Object string, int lax) { register unsigned char *p, *o; - register int i, i_byte, len, punct_count = 0, word_count = 0; + register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0; Lisp_Object val; int prev_c = 0; - int adjust, whitespace_at_end; + EMACS_INT adjust; + int whitespace_at_end; CHECK_STRING (string); p = SDATA (string); @@ -2151,7 +2161,7 @@ for (i = 0, i_byte = 0; i < len; ) { int c; - int i_byte_orig = i_byte; + EMACS_INT i_byte_orig = i_byte; FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte); @@ -2392,7 +2402,7 @@ (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp) { enum { nochange, all_caps, cap_initial } case_action; - register int pos, pos_byte; + register EMACS_INT pos, pos_byte; int some_multiletter_word; int some_lowercase; int some_uppercase; @@ -2540,8 +2550,8 @@ for (pos_byte = 0, pos = 0; pos_byte < length;) { - int substart = -1; - int subend = 0; + EMACS_INT substart = -1; + EMACS_INT subend = 0; int delbackslash = 0; FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte); @@ -2634,9 +2644,9 @@ perform substitution on the replacement string. */ if (NILP (literal)) { - int length = SBYTES (newtext); + EMACS_INT length = SBYTES (newtext); unsigned char *substed; - int substed_alloc_size, substed_len; + EMACS_INT substed_alloc_size, substed_len; int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters); int str_multibyte = STRING_MULTIBYTE (newtext); Lisp_Object rev_tbl; @@ -2656,7 +2666,7 @@ { unsigned char str[MAX_MULTIBYTE_LENGTH]; const unsigned char *add_stuff = NULL; - int add_len = 0; + EMACS_INT add_len = 0; int idx = -1; if (str_multibyte) @@ -2750,7 +2760,8 @@ { if (buf_multibyte) { - int nchars = multibyte_chars_in_text (substed, substed_len); + EMACS_INT nchars = + multibyte_chars_in_text (substed, substed_len); newtext = make_multibyte_string (substed, nchars, substed_len); }