aboutsummaryrefslogtreecommitdiffstats
path: root/src/region-cache.c
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/region-cache.c
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/region-cache.c')
-rw-r--r--src/region-cache.c51
1 files changed, 29 insertions, 22 deletions
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",