revalidate_region_cache to see how this helps. */
struct boundary {
- int pos;
+ EMACS_INT pos;
int value;
};
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. */
/* 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
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. */
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;
/* 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;
/* 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)
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. */
/* 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)
/* 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
/* 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 ();
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.
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);
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);
/* 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);
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",
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;
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)
pos = 0, pos_byte = 0;
else
{
- int len = SCHARS (string);
+ EMACS_INT len = SCHARS (string);
CHECK_NUMBER (start);
pos = XINT (start);
{
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;
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;
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))
/* 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))
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);
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);
}
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--;
/* 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))
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)
{
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)
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,
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)
}
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)
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;
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)
/* 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;
{
/* 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)
/* 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)
{
/* 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)
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);
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);
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);
(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;
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);
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;
{
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)
{
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);
}