aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2010-09-23 14:35:11 -0400
committerEli Zaretskii2010-09-23 14:35:11 -0400
commitc098fdb898c6837312c153b8bcca454500baa95b (patch)
tree878534f2504a1e0300c0596f2493922a7a368d7b /src
parent29cdc13ed61e5a64ba30df1030029898a26b7947 (diff)
downloademacs-c098fdb898c6837312c153b8bcca454500baa95b.tar.gz
emacs-c098fdb898c6837312c153b8bcca454500baa95b.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog24
-rw-r--r--src/indent.c2
-rw-r--r--src/lisp.h13
-rw-r--r--src/region-cache.c51
-rw-r--r--src/region-cache.h12
-rw-r--r--src/search.c107
6 files changed, 126 insertions, 83 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 39f7d3ab393..28fcb9eab67 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,28 @@
12010-09-23 Eli Zaretskii <eliz@gnu.org> 12010-09-23 Eli Zaretskii <eliz@gnu.org>
2 2
3 * indent.c (compute_motion): Use EMACS_INT for arguments to
4 region_cache_forward.
5
6 * region-cache.c (struct boundary, struct region_cache): Use
7 EMACS_INT for positions.
8 (find_cache_boundary, move_cache_gap, insert_cache_boundary)
9 (delete_cache_boundaries, set_cache_region)
10 (invalidate_region_cache, know_region_cache)
11 (region_cache_forward, region_cache_backward, pp_cache): Use
12 EMACS_INT for buffer positions.
13
14 * region-cache.h (know_region_cache, invalidate_region_cache)
15 (region_cache_forward, region_cache_backward): Adjust prototypes.
16
17 * search.c (string_match_1, fast_c_string_match_ignore_case)
18 (looking_at_1, scan_buffer, scan_newline)
19 (find_next_newline_no_quit, find_before_next_newline)
20 (search_command, trivial_regexp_p, search_buffer, simple_search)
21 (boyer_moore, wordify, Freplace_match): Use EMACS_INT for buffer
22 and string positions and length.
23
24 * lisp.h (scan_buffer, scan_newline, find_next_newline_no_quit, find_before_next_newline)
25
3 * editfns.c (transpose_markers, update_buffer_properties) 26 * editfns.c (transpose_markers, update_buffer_properties)
4 (buildmark, clip_to_bounds, Fgoto_char, overlays_around) 27 (buildmark, clip_to_bounds, Fgoto_char, overlays_around)
5 (get_pos_property, Fconstrain_to_field) 28 (get_pos_property, Fconstrain_to_field)
@@ -8,6 +31,7 @@
8 (Finsert_buffer_substring, Fcompare_buffer_substrings) 31 (Finsert_buffer_substring, Fcompare_buffer_substrings)
9 (Fsubst_char_in_region, Fformat, Ftranspose_regions): Use 32 (Fsubst_char_in_region, Fformat, Ftranspose_regions): Use
10 EMACS_INT for buffer and string position variables. 33 EMACS_INT for buffer and string position variables.
34 (Finsert_char): Protect against too large insertions.
11 35
12 * lisp.h (clip_to_bounds): Adjust prototype. 36 * lisp.h (clip_to_bounds): Adjust prototype.
13 37
diff --git a/src/indent.c b/src/indent.c
index 970904cba7b..76163e24905 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1448,7 +1448,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
1448 the text character-by-character. */ 1448 the text character-by-character. */
1449 if (current_buffer->width_run_cache && pos >= next_width_run) 1449 if (current_buffer->width_run_cache && pos >= next_width_run)
1450 { 1450 {
1451 int run_end; 1451 EMACS_INT run_end;
1452 int common_width 1452 int common_width
1453 = region_cache_forward (current_buffer, 1453 = region_cache_forward (current_buffer,
1454 current_buffer->width_run_cache, 1454 current_buffer->width_run_cache,
diff --git a/src/lisp.h b/src/lisp.h
index c53ea1221ed..ee510e8edc9 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3122,12 +3122,13 @@ extern int fast_c_string_match_ignore_case (Lisp_Object, const char *);
3122extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object); 3122extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object);
3123extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT, 3123extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT,
3124 EMACS_INT, EMACS_INT, Lisp_Object); 3124 EMACS_INT, EMACS_INT, Lisp_Object);
3125extern int scan_buffer (int, EMACS_INT, EMACS_INT, int, int *, int); 3125extern EMACS_INT scan_buffer (int, EMACS_INT, EMACS_INT, EMACS_INT,
3126extern int scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, 3126 int *, int);
3127 int, int); 3127extern EMACS_INT scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT,
3128extern int find_next_newline (EMACS_INT, int); 3128 EMACS_INT, int);
3129extern int find_next_newline_no_quit (EMACS_INT, int); 3129extern EMACS_INT find_next_newline (EMACS_INT, int);
3130extern int find_before_next_newline (EMACS_INT, EMACS_INT, int); 3130extern EMACS_INT find_next_newline_no_quit (EMACS_INT, EMACS_INT);
3131extern EMACS_INT find_before_next_newline (EMACS_INT, EMACS_INT, EMACS_INT);
3131extern void syms_of_search (void); 3132extern void syms_of_search (void);
3132extern void clear_regexp_cache (void); 3133extern void clear_regexp_cache (void);
3133 3134
diff --git a/src/region-cache.c b/src/region-cache.c
index 45eb723c885..b3eb4beac02 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -62,7 +62,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
62 revalidate_region_cache to see how this helps. */ 62 revalidate_region_cache to see how this helps. */
63 63
64struct boundary { 64struct boundary {
65 int pos; 65 EMACS_INT pos;
66 int value; 66 int value;
67}; 67};
68 68
@@ -72,7 +72,7 @@ struct region_cache {
72 struct boundary *boundaries; 72 struct boundary *boundaries;
73 73
74 /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap. */ 74 /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap. */
75 int gap_start, gap_len; 75 EMACS_INT gap_start, gap_len;
76 76
77 /* The number of elements allocated to boundaries, not including the 77 /* The number of elements allocated to boundaries, not including the
78 gap. */ 78 gap. */
@@ -81,7 +81,7 @@ struct region_cache {
81 /* The areas that haven't changed since the last time we cleaned out 81 /* The areas that haven't changed since the last time we cleaned out
82 invalid entries from the cache. These overlap when the buffer is 82 invalid entries from the cache. These overlap when the buffer is
83 entirely unchanged. */ 83 entirely unchanged. */
84 int beg_unchanged, end_unchanged; 84 EMACS_INT beg_unchanged, end_unchanged;
85 85
86 /* The first and last positions in the buffer. Because boundaries 86 /* The first and last positions in the buffer. Because boundaries
87 store their positions relative to the start (BEG) and end (Z) of 87 store their positions relative to the start (BEG) and end (Z) of
@@ -91,7 +91,7 @@ struct region_cache {
91 91
92 Yes, buffer_beg is always 1. It's there for symmetry with 92 Yes, buffer_beg is always 1. It's there for symmetry with
93 buffer_end and the BEG and BUF_BEG macros. */ 93 buffer_end and the BEG and BUF_BEG macros. */
94 int buffer_beg, buffer_end; 94 EMACS_INT buffer_beg, buffer_end;
95}; 95};
96 96
97/* Return the position of boundary i in cache c. */ 97/* Return the position of boundary i in cache c. */
@@ -173,7 +173,7 @@ free_region_cache (struct region_cache *c)
173 entries. It would be nice if it took advantage of locality of 173 entries. It would be nice if it took advantage of locality of
174 reference, too, by searching entries near the last entry found. */ 174 reference, too, by searching entries near the last entry found. */
175static int 175static int
176find_cache_boundary (struct region_cache *c, int pos) 176find_cache_boundary (struct region_cache *c, EMACS_INT pos)
177{ 177{
178 int low = 0, high = c->cache_len; 178 int low = 0, high = c->cache_len;
179 179
@@ -182,7 +182,7 @@ find_cache_boundary (struct region_cache *c, int pos)
182 /* mid is always a valid index, because low < high and ">> 1" 182 /* mid is always a valid index, because low < high and ">> 1"
183 rounds down. */ 183 rounds down. */
184 int mid = (low + high) >> 1; 184 int mid = (low + high) >> 1;
185 int boundary = BOUNDARY_POS (c, mid); 185 EMACS_INT boundary = BOUNDARY_POS (c, mid);
186 186
187 if (pos < boundary) 187 if (pos < boundary)
188 high = mid; 188 high = mid;
@@ -207,13 +207,13 @@ find_cache_boundary (struct region_cache *c, int pos)
207/* Move the gap of cache C to index POS, and make sure it has space 207/* Move the gap of cache C to index POS, and make sure it has space
208 for at least MIN_SIZE boundaries. */ 208 for at least MIN_SIZE boundaries. */
209static void 209static void
210move_cache_gap (struct region_cache *c, int pos, int min_size) 210move_cache_gap (struct region_cache *c, EMACS_INT pos, int min_size)
211{ 211{
212 /* Copy these out of the cache and into registers. */ 212 /* Copy these out of the cache and into registers. */
213 int gap_start = c->gap_start; 213 EMACS_INT gap_start = c->gap_start;
214 int gap_len = c->gap_len; 214 EMACS_INT gap_len = c->gap_len;
215 int buffer_beg = c->buffer_beg; 215 EMACS_INT buffer_beg = c->buffer_beg;
216 int buffer_end = c->buffer_end; 216 EMACS_INT buffer_end = c->buffer_end;
217 217
218 if (pos < 0 218 if (pos < 0
219 || pos > c->cache_len) 219 || pos > c->cache_len)
@@ -245,7 +245,7 @@ move_cache_gap (struct region_cache *c, int pos, int min_size)
245 when the portion after the gap is smallest. */ 245 when the portion after the gap is smallest. */
246 if (gap_len < min_size) 246 if (gap_len < min_size)
247 { 247 {
248 int i; 248 EMACS_INT i;
249 249
250 /* Always make at least NEW_CACHE_GAP elements, as long as we're 250 /* Always make at least NEW_CACHE_GAP elements, as long as we're
251 expanding anyway. */ 251 expanding anyway. */
@@ -292,7 +292,8 @@ move_cache_gap (struct region_cache *c, int pos, int min_size)
292/* Insert a new boundary in cache C; it will have cache index INDEX, 292/* Insert a new boundary in cache C; it will have cache index INDEX,
293 and have the specified POS and VALUE. */ 293 and have the specified POS and VALUE. */
294static void 294static void
295insert_cache_boundary (struct region_cache *c, int index, int pos, int value) 295insert_cache_boundary (struct region_cache *c, int index, EMACS_INT pos,
296 int value)
296{ 297{
297 /* index must be a valid cache index. */ 298 /* index must be a valid cache index. */
298 if (index < 0 || index > c->cache_len) 299 if (index < 0 || index > c->cache_len)
@@ -328,9 +329,10 @@ insert_cache_boundary (struct region_cache *c, int index, int pos, int value)
328/* Delete the i'th entry from cache C if START <= i < END. */ 329/* Delete the i'th entry from cache C if START <= i < END. */
329 330
330static void 331static void
331delete_cache_boundaries (struct region_cache *c, int start, int end) 332delete_cache_boundaries (struct region_cache *c,
333 EMACS_INT start, EMACS_INT end)
332{ 334{
333 int len = end - start; 335 EMACS_INT len = end - start;
334 336
335 /* Gotta be in range. */ 337 /* Gotta be in range. */
336 if (start < 0 338 if (start < 0
@@ -380,7 +382,8 @@ delete_cache_boundaries (struct region_cache *c, int start, int end)
380 382
381/* Set the value in cache C for the region START..END to VALUE. */ 383/* Set the value in cache C for the region START..END to VALUE. */
382static void 384static void
383set_cache_region (struct region_cache *c, int start, int end, int value) 385set_cache_region (struct region_cache *c,
386 EMACS_INT start, EMACS_INT end, int value)
384{ 387{
385 if (start > end) 388 if (start > end)
386 abort (); 389 abort ();
@@ -481,7 +484,8 @@ set_cache_region (struct region_cache *c, int start, int end, int value)
481 buffer positions in the presence of insertions and deletions; the 484 buffer positions in the presence of insertions and deletions; the
482 args to pass are the same before and after such an operation.) */ 485 args to pass are the same before and after such an operation.) */
483void 486void
484invalidate_region_cache (struct buffer *buf, struct region_cache *c, int head, int tail) 487invalidate_region_cache (struct buffer *buf, struct region_cache *c,
488 EMACS_INT head, EMACS_INT tail)
485{ 489{
486 /* Let chead = c->beg_unchanged, and 490 /* Let chead = c->beg_unchanged, and
487 ctail = c->end_unchanged. 491 ctail = c->end_unchanged.
@@ -687,7 +691,8 @@ revalidate_region_cache (struct buffer *buf, struct region_cache *c)
687 buffer positions) is "known," for the purposes of CACHE (e.g. "has 691 buffer positions) is "known," for the purposes of CACHE (e.g. "has
688 no newlines", in the case of the line cache). */ 692 no newlines", in the case of the line cache). */
689void 693void
690know_region_cache (struct buffer *buf, struct region_cache *c, int start, int end) 694know_region_cache (struct buffer *buf, struct region_cache *c,
695 EMACS_INT start, EMACS_INT end)
691{ 696{
692 revalidate_region_cache (buf, c); 697 revalidate_region_cache (buf, c);
693 698
@@ -701,7 +706,8 @@ know_region_cache (struct buffer *buf, struct region_cache *c, int start, int en
701 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest 706 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
702 position after POS where the knownness changes. */ 707 position after POS where the knownness changes. */
703int 708int
704region_cache_forward (struct buffer *buf, struct region_cache *c, int pos, int *next) 709region_cache_forward (struct buffer *buf, struct region_cache *c,
710 EMACS_INT pos, EMACS_INT *next)
705{ 711{
706 revalidate_region_cache (buf, c); 712 revalidate_region_cache (buf, c);
707 713
@@ -736,7 +742,8 @@ region_cache_forward (struct buffer *buf, struct region_cache *c, int pos, int *
736/* Return true if the text immediately before POS in BUF is known, for 742/* Return true if the text immediately before POS in BUF is known, for
737 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest 743 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
738 position before POS where the knownness changes. */ 744 position before POS where the knownness changes. */
739int region_cache_backward (struct buffer *buf, struct region_cache *c, int pos, int *next) 745int region_cache_backward (struct buffer *buf, struct region_cache *c,
746 EMACS_INT pos, EMACS_INT *next)
740{ 747{
741 revalidate_region_cache (buf, c); 748 revalidate_region_cache (buf, c);
742 749
@@ -777,8 +784,8 @@ void
777pp_cache (struct region_cache *c) 784pp_cache (struct region_cache *c)
778{ 785{
779 int i; 786 int i;
780 int beg_u = c->buffer_beg + c->beg_unchanged; 787 EMACS_INT beg_u = c->buffer_beg + c->beg_unchanged;
781 int end_u = c->buffer_end - c->end_unchanged; 788 EMACS_INT end_u = c->buffer_end - c->end_unchanged;
782 789
783 fprintf (stderr, 790 fprintf (stderr,
784 "basis: %d..%d modified: %d..%d\n", 791 "basis: %d..%d modified: %d..%d\n",
diff --git a/src/region-cache.h b/src/region-cache.h
index e2972f2ea0a..e99eac90c85 100644
--- a/src/region-cache.h
+++ b/src/region-cache.h
@@ -71,7 +71,7 @@ void free_region_cache (struct region_cache *);
71 no newlines", in the case of the line cache). */ 71 no newlines", in the case of the line cache). */
72extern void know_region_cache (struct buffer *BUF, 72extern void know_region_cache (struct buffer *BUF,
73 struct region_cache *CACHE, 73 struct region_cache *CACHE,
74 int START, int END); 74 EMACS_INT START, EMACS_INT END);
75 75
76/* Indicate that a section of BUF has changed, to invalidate CACHE. 76/* Indicate that a section of BUF has changed, to invalidate CACHE.
77 HEAD is the number of chars unchanged at the beginning of the buffer. 77 HEAD is the number of chars unchanged at the beginning of the buffer.
@@ -83,7 +83,7 @@ extern void know_region_cache (struct buffer *BUF,
83 args to pass are the same before and after such an operation.) */ 83 args to pass are the same before and after such an operation.) */
84extern void invalidate_region_cache (struct buffer *BUF, 84extern void invalidate_region_cache (struct buffer *BUF,
85 struct region_cache *CACHE, 85 struct region_cache *CACHE,
86 int HEAD, int TAIL); 86 EMACS_INT HEAD, EMACS_INT TAIL);
87 87
88/* The scanning functions. 88/* The scanning functions.
89 89
@@ -99,16 +99,16 @@ extern void invalidate_region_cache (struct buffer *BUF,
99 position after POS where the knownness changes. */ 99 position after POS where the knownness changes. */
100extern int region_cache_forward (struct buffer *BUF, 100extern int region_cache_forward (struct buffer *BUF,
101 struct region_cache *CACHE, 101 struct region_cache *CACHE,
102 int POS, 102 EMACS_INT POS,
103 int *NEXT); 103 EMACS_INT *NEXT);
104 104
105/* Return true if the text immediately before POS in BUF is known, for 105/* Return true if the text immediately before POS in BUF is known, for
106 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest 106 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
107 position before POS where the knownness changes. */ 107 position before POS where the knownness changes. */
108extern int region_cache_backward (struct buffer *BUF, 108extern int region_cache_backward (struct buffer *BUF,
109 struct region_cache *CACHE, 109 struct region_cache *CACHE,
110 int POS, 110 EMACS_INT POS,
111 int *NEXT); 111 EMACS_INT *NEXT);
112 112
113/* arch-tag: 70f79125-ef22-4f58-9aec-a48ca2791435 113/* arch-tag: 70f79125-ef22-4f58-9aec-a48ca2791435
114 (do not change this comment) */ 114 (do not change this comment) */
diff --git a/src/search.c b/src/search.c
index 0e9840b2e5f..f2957c335a2 100644
--- a/src/search.c
+++ b/src/search.c
@@ -100,15 +100,15 @@ Lisp_Object Vinhibit_changing_match_data;
100 100
101static void set_search_regs (EMACS_INT, EMACS_INT); 101static void set_search_regs (EMACS_INT, EMACS_INT);
102static void save_search_regs (void); 102static void save_search_regs (void);
103static EMACS_INT simple_search (int, unsigned char *, int, int, 103static EMACS_INT simple_search (EMACS_INT, unsigned char *, EMACS_INT,
104 Lisp_Object, EMACS_INT, EMACS_INT, 104 EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT,
105 EMACS_INT, EMACS_INT); 105 EMACS_INT, EMACS_INT);
106static EMACS_INT boyer_moore (int, unsigned char *, int, int, 106static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, EMACS_INT, EMACS_INT,
107 Lisp_Object, Lisp_Object, 107 Lisp_Object, Lisp_Object,
108 EMACS_INT, EMACS_INT, 108 EMACS_INT, EMACS_INT,
109 EMACS_INT, EMACS_INT, int); 109 EMACS_INT, EMACS_INT, int);
110static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT, 110static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT,
111 EMACS_INT, EMACS_INT, int, int, 111 EMACS_INT, EMACS_INT, EMACS_INT, int,
112 Lisp_Object, Lisp_Object, int); 112 Lisp_Object, Lisp_Object, int);
113static void matcher_overflow (void) NO_RETURN; 113static void matcher_overflow (void) NO_RETURN;
114 114
@@ -286,7 +286,7 @@ looking_at_1 (Lisp_Object string, int posix)
286 Lisp_Object val; 286 Lisp_Object val;
287 unsigned char *p1, *p2; 287 unsigned char *p1, *p2;
288 EMACS_INT s1, s2; 288 EMACS_INT s1, s2;
289 register int i; 289 register EMACS_INT i;
290 struct re_pattern_buffer *bufp; 290 struct re_pattern_buffer *bufp;
291 291
292 if (running_asynch_code) 292 if (running_asynch_code)
@@ -396,7 +396,7 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int p
396 pos = 0, pos_byte = 0; 396 pos = 0, pos_byte = 0;
397 else 397 else
398 { 398 {
399 int len = SCHARS (string); 399 EMACS_INT len = SCHARS (string);
400 400
401 CHECK_NUMBER (start); 401 CHECK_NUMBER (start);
402 pos = XINT (start); 402 pos = XINT (start);
@@ -509,7 +509,7 @@ fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string)
509{ 509{
510 int val; 510 int val;
511 struct re_pattern_buffer *bufp; 511 struct re_pattern_buffer *bufp;
512 int len = strlen (string); 512 size_t len = strlen (string);
513 513
514 regexp = string_make_unibyte (regexp); 514 regexp = string_make_unibyte (regexp);
515 re_match_object = Qt; 515 re_match_object = Qt;
@@ -654,8 +654,9 @@ newline_cache_on_off (struct buffer *buf)
654 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do 654 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do
655 except when inside redisplay. */ 655 except when inside redisplay. */
656 656
657int 657EMACS_INT
658scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int *shortage, int allow_quit) 658scan_buffer (register int target, EMACS_INT start, EMACS_INT end,
659 EMACS_INT count, int *shortage, int allow_quit)
659{ 660{
660 struct region_cache *newline_cache; 661 struct region_cache *newline_cache;
661 int direction; 662 int direction;
@@ -695,7 +696,7 @@ scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int
695 to see where we can avoid some scanning. */ 696 to see where we can avoid some scanning. */
696 if (target == '\n' && newline_cache) 697 if (target == '\n' && newline_cache)
697 { 698 {
698 int next_change; 699 EMACS_INT next_change;
699 immediate_quit = 0; 700 immediate_quit = 0;
700 while (region_cache_forward 701 while (region_cache_forward
701 (current_buffer, newline_cache, start_byte, &next_change)) 702 (current_buffer, newline_cache, start_byte, &next_change))
@@ -767,7 +768,7 @@ scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int
767 /* Consult the newline cache, if appropriate. */ 768 /* Consult the newline cache, if appropriate. */
768 if (target == '\n' && newline_cache) 769 if (target == '\n' && newline_cache)
769 { 770 {
770 int next_change; 771 EMACS_INT next_change;
771 immediate_quit = 0; 772 immediate_quit = 0;
772 while (region_cache_backward 773 while (region_cache_backward
773 (current_buffer, newline_cache, start_byte, &next_change)) 774 (current_buffer, newline_cache, start_byte, &next_change))
@@ -846,8 +847,10 @@ scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int
846 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do 847 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do
847 except in special cases. */ 848 except in special cases. */
848 849
849int 850EMACS_INT
850scan_newline (EMACS_INT start, EMACS_INT start_byte, EMACS_INT limit, EMACS_INT limit_byte, register int count, int allow_quit) 851scan_newline (EMACS_INT start, EMACS_INT start_byte,
852 EMACS_INT limit, EMACS_INT limit_byte,
853 register EMACS_INT count, int allow_quit)
851{ 854{
852 int direction = ((count > 0) ? 1 : -1); 855 int direction = ((count > 0) ? 1 : -1);
853 856
@@ -940,8 +943,8 @@ scan_newline (EMACS_INT start, EMACS_INT start_byte, EMACS_INT limit, EMACS_INT
940 return count * direction; 943 return count * direction;
941} 944}
942 945
943int 946EMACS_INT
944find_next_newline_no_quit (EMACS_INT from, int cnt) 947find_next_newline_no_quit (EMACS_INT from, EMACS_INT cnt)
945{ 948{
946 return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0); 949 return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0);
947} 950}
@@ -950,11 +953,11 @@ find_next_newline_no_quit (EMACS_INT from, int cnt)
950 not after, and only search up to TO. This isn't just 953 not after, and only search up to TO. This isn't just
951 find_next_newline (...)-1, because you might hit TO. */ 954 find_next_newline (...)-1, because you might hit TO. */
952 955
953int 956EMACS_INT
954find_before_next_newline (EMACS_INT from, EMACS_INT to, int cnt) 957find_before_next_newline (EMACS_INT from, EMACS_INT to, EMACS_INT cnt)
955{ 958{
956 int shortage; 959 int shortage;
957 int pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); 960 EMACS_INT pos = scan_buffer ('\n', from, to, cnt, &shortage, 1);
958 961
959 if (shortage == 0) 962 if (shortage == 0)
960 pos--; 963 pos--;
@@ -965,10 +968,11 @@ find_before_next_newline (EMACS_INT from, EMACS_INT to, int cnt)
965/* Subroutines of Lisp buffer search functions. */ 968/* Subroutines of Lisp buffer search functions. */
966 969
967static Lisp_Object 970static Lisp_Object
968search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count, int direction, int RE, int posix) 971search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
972 Lisp_Object count, int direction, int RE, int posix)
969{ 973{
970 register int np; 974 register int np;
971 int lim, lim_byte; 975 EMACS_INT lim, lim_byte;
972 int n = direction; 976 int n = direction;
973 977
974 if (!NILP (count)) 978 if (!NILP (count))
@@ -1044,7 +1048,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp
1044static int 1048static int
1045trivial_regexp_p (Lisp_Object regexp) 1049trivial_regexp_p (Lisp_Object regexp)
1046{ 1050{
1047 int len = SBYTES (regexp); 1051 EMACS_INT len = SBYTES (regexp);
1048 unsigned char *s = SDATA (regexp); 1052 unsigned char *s = SDATA (regexp);
1049 while (--len >= 0) 1053 while (--len >= 0)
1050 { 1054 {
@@ -1109,11 +1113,11 @@ static struct re_registers search_regs_1;
1109 1113
1110static EMACS_INT 1114static EMACS_INT
1111search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte, 1115search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1112 EMACS_INT lim, EMACS_INT lim_byte, int n, 1116 EMACS_INT lim, EMACS_INT lim_byte, EMACS_INT n,
1113 int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix) 1117 int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix)
1114{ 1118{
1115 int len = SCHARS (string); 1119 EMACS_INT len = SCHARS (string);
1116 int len_byte = SBYTES (string); 1120 EMACS_INT len_byte = SBYTES (string);
1117 register int i; 1121 register int i;
1118 1122
1119 if (running_asynch_code) 1123 if (running_asynch_code)
@@ -1130,7 +1134,7 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1130 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp))) 1134 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp)))
1131 { 1135 {
1132 unsigned char *p1, *p2; 1136 unsigned char *p1, *p2;
1133 int s1, s2; 1137 EMACS_INT s1, s2;
1134 struct re_pattern_buffer *bufp; 1138 struct re_pattern_buffer *bufp;
1135 1139
1136 bufp = compile_pattern (string, 1140 bufp = compile_pattern (string,
@@ -1166,7 +1170,7 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1166 1170
1167 while (n < 0) 1171 while (n < 0)
1168 { 1172 {
1169 int val; 1173 EMACS_INT val;
1170 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, 1174 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
1171 pos_byte - BEGV_BYTE, lim_byte - pos_byte, 1175 pos_byte - BEGV_BYTE, lim_byte - pos_byte,
1172 (NILP (Vinhibit_changing_match_data) 1176 (NILP (Vinhibit_changing_match_data)
@@ -1210,7 +1214,7 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1210 } 1214 }
1211 while (n > 0) 1215 while (n > 0)
1212 { 1216 {
1213 int val; 1217 EMACS_INT val;
1214 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, 1218 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
1215 pos_byte - BEGV_BYTE, lim_byte - pos_byte, 1219 pos_byte - BEGV_BYTE, lim_byte - pos_byte,
1216 (NILP (Vinhibit_changing_match_data) 1220 (NILP (Vinhibit_changing_match_data)
@@ -1255,8 +1259,8 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1255 else /* non-RE case */ 1259 else /* non-RE case */
1256 { 1260 {
1257 unsigned char *raw_pattern, *pat; 1261 unsigned char *raw_pattern, *pat;
1258 int raw_pattern_size; 1262 EMACS_INT raw_pattern_size;
1259 int raw_pattern_size_byte; 1263 EMACS_INT raw_pattern_size_byte;
1260 unsigned char *patbuf; 1264 unsigned char *patbuf;
1261 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 1265 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
1262 unsigned char *base_pat; 1266 unsigned char *base_pat;
@@ -1450,13 +1454,16 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1450 boyer_moore cannot work. */ 1454 boyer_moore cannot work. */
1451 1455
1452static EMACS_INT 1456static EMACS_INT
1453simple_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) 1457simple_search (EMACS_INT n, unsigned char *pat,
1458 EMACS_INT len, EMACS_INT len_byte, Lisp_Object trt,
1459 EMACS_INT pos, EMACS_INT pos_byte,
1460 EMACS_INT lim, EMACS_INT lim_byte)
1454{ 1461{
1455 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); 1462 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
1456 int forward = n > 0; 1463 int forward = n > 0;
1457 /* Number of buffer bytes matched. Note that this may be different 1464 /* Number of buffer bytes matched. Note that this may be different
1458 from len_byte in a multibyte buffer. */ 1465 from len_byte in a multibyte buffer. */
1459 int match_byte; 1466 EMACS_INT match_byte;
1460 1467
1461 if (lim > pos && multibyte) 1468 if (lim > pos && multibyte)
1462 while (n > 0) 1469 while (n > 0)
@@ -1466,7 +1473,7 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1466 /* Try matching at position POS. */ 1473 /* Try matching at position POS. */
1467 EMACS_INT this_pos = pos; 1474 EMACS_INT this_pos = pos;
1468 EMACS_INT this_pos_byte = pos_byte; 1475 EMACS_INT this_pos_byte = pos_byte;
1469 int this_len = len; 1476 EMACS_INT this_len = len;
1470 unsigned char *p = pat; 1477 unsigned char *p = pat;
1471 if (pos + len > lim || pos_byte + len_byte > lim_byte) 1478 if (pos + len > lim || pos_byte + len_byte > lim_byte)
1472 goto stop; 1479 goto stop;
@@ -1511,7 +1518,7 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1511 { 1518 {
1512 /* Try matching at position POS. */ 1519 /* Try matching at position POS. */
1513 EMACS_INT this_pos = pos; 1520 EMACS_INT this_pos = pos;
1514 int this_len = len; 1521 EMACS_INT this_len = len;
1515 unsigned char *p = pat; 1522 unsigned char *p = pat;
1516 1523
1517 if (pos + len > lim) 1524 if (pos + len > lim)
@@ -1551,7 +1558,7 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1551 /* Try matching at position POS. */ 1558 /* Try matching at position POS. */
1552 EMACS_INT this_pos = pos; 1559 EMACS_INT this_pos = pos;
1553 EMACS_INT this_pos_byte = pos_byte; 1560 EMACS_INT this_pos_byte = pos_byte;
1554 int this_len = len; 1561 EMACS_INT this_len = len;
1555 const unsigned char *p = pat + len_byte; 1562 const unsigned char *p = pat + len_byte;
1556 1563
1557 if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte) 1564 if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte)
@@ -1594,7 +1601,7 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1594 { 1601 {
1595 /* Try matching at position POS. */ 1602 /* Try matching at position POS. */
1596 EMACS_INT this_pos = pos - len; 1603 EMACS_INT this_pos = pos - len;
1597 int this_len = len; 1604 EMACS_INT this_len = len;
1598 unsigned char *p = pat; 1605 unsigned char *p = pat;
1599 1606
1600 if (this_pos < lim) 1607 if (this_pos < lim)
@@ -1657,18 +1664,20 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1657 If that criterion is not satisfied, do not call this function. */ 1664 If that criterion is not satisfied, do not call this function. */
1658 1665
1659static EMACS_INT 1666static EMACS_INT
1660boyer_moore (int n, unsigned char *base_pat, int len, int len_byte, 1667boyer_moore (EMACS_INT n, unsigned char *base_pat,
1668 EMACS_INT len, EMACS_INT len_byte,
1661 Lisp_Object trt, Lisp_Object inverse_trt, 1669 Lisp_Object trt, Lisp_Object inverse_trt,
1662 EMACS_INT pos, EMACS_INT pos_byte, 1670 EMACS_INT pos, EMACS_INT pos_byte,
1663 EMACS_INT lim, EMACS_INT lim_byte, int char_base) 1671 EMACS_INT lim, EMACS_INT lim_byte, int char_base)
1664{ 1672{
1665 int direction = ((n > 0) ? 1 : -1); 1673 int direction = ((n > 0) ? 1 : -1);
1666 register int dirlen; 1674 register EMACS_INT dirlen;
1667 EMACS_INT limit; 1675 EMACS_INT limit;
1668 int stride_for_teases = 0; 1676 int stride_for_teases = 0;
1669 int BM_tab[0400]; 1677 int BM_tab[0400];
1670 register unsigned char *cursor, *p_limit; 1678 register unsigned char *cursor, *p_limit;
1671 register int i, j; 1679 register EMACS_INT i;
1680 register int j;
1672 unsigned char *pat, *pat_end; 1681 unsigned char *pat, *pat_end;
1673 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); 1682 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
1674 1683
@@ -2098,10 +2107,11 @@ static Lisp_Object
2098wordify (Lisp_Object string, int lax) 2107wordify (Lisp_Object string, int lax)
2099{ 2108{
2100 register unsigned char *p, *o; 2109 register unsigned char *p, *o;
2101 register int i, i_byte, len, punct_count = 0, word_count = 0; 2110 register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0;
2102 Lisp_Object val; 2111 Lisp_Object val;
2103 int prev_c = 0; 2112 int prev_c = 0;
2104 int adjust, whitespace_at_end; 2113 EMACS_INT adjust;
2114 int whitespace_at_end;
2105 2115
2106 CHECK_STRING (string); 2116 CHECK_STRING (string);
2107 p = SDATA (string); 2117 p = SDATA (string);
@@ -2151,7 +2161,7 @@ wordify (Lisp_Object string, int lax)
2151 for (i = 0, i_byte = 0; i < len; ) 2161 for (i = 0, i_byte = 0; i < len; )
2152 { 2162 {
2153 int c; 2163 int c;
2154 int i_byte_orig = i_byte; 2164 EMACS_INT i_byte_orig = i_byte;
2155 2165
2156 FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte); 2166 FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte);
2157 2167
@@ -2392,7 +2402,7 @@ since only regular expressions have distinguished subexpressions. */)
2392 (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp) 2402 (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp)
2393{ 2403{
2394 enum { nochange, all_caps, cap_initial } case_action; 2404 enum { nochange, all_caps, cap_initial } case_action;
2395 register int pos, pos_byte; 2405 register EMACS_INT pos, pos_byte;
2396 int some_multiletter_word; 2406 int some_multiletter_word;
2397 int some_lowercase; 2407 int some_lowercase;
2398 int some_uppercase; 2408 int some_uppercase;
@@ -2540,8 +2550,8 @@ since only regular expressions have distinguished subexpressions. */)
2540 2550
2541 for (pos_byte = 0, pos = 0; pos_byte < length;) 2551 for (pos_byte = 0, pos = 0; pos_byte < length;)
2542 { 2552 {
2543 int substart = -1; 2553 EMACS_INT substart = -1;
2544 int subend = 0; 2554 EMACS_INT subend = 0;
2545 int delbackslash = 0; 2555 int delbackslash = 0;
2546 2556
2547 FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte); 2557 FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
@@ -2634,9 +2644,9 @@ since only regular expressions have distinguished subexpressions. */)
2634 perform substitution on the replacement string. */ 2644 perform substitution on the replacement string. */
2635 if (NILP (literal)) 2645 if (NILP (literal))
2636 { 2646 {
2637 int length = SBYTES (newtext); 2647 EMACS_INT length = SBYTES (newtext);
2638 unsigned char *substed; 2648 unsigned char *substed;
2639 int substed_alloc_size, substed_len; 2649 EMACS_INT substed_alloc_size, substed_len;
2640 int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters); 2650 int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters);
2641 int str_multibyte = STRING_MULTIBYTE (newtext); 2651 int str_multibyte = STRING_MULTIBYTE (newtext);
2642 Lisp_Object rev_tbl; 2652 Lisp_Object rev_tbl;
@@ -2656,7 +2666,7 @@ since only regular expressions have distinguished subexpressions. */)
2656 { 2666 {
2657 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2667 unsigned char str[MAX_MULTIBYTE_LENGTH];
2658 const unsigned char *add_stuff = NULL; 2668 const unsigned char *add_stuff = NULL;
2659 int add_len = 0; 2669 EMACS_INT add_len = 0;
2660 int idx = -1; 2670 int idx = -1;
2661 2671
2662 if (str_multibyte) 2672 if (str_multibyte)
@@ -2750,7 +2760,8 @@ since only regular expressions have distinguished subexpressions. */)
2750 { 2760 {
2751 if (buf_multibyte) 2761 if (buf_multibyte)
2752 { 2762 {
2753 int nchars = multibyte_chars_in_text (substed, substed_len); 2763 EMACS_INT nchars =
2764 multibyte_chars_in_text (substed, substed_len);
2754 2765
2755 newtext = make_multibyte_string (substed, nchars, substed_len); 2766 newtext = make_multibyte_string (substed, nchars, substed_len);
2756 } 2767 }