-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 (EMACS_INT, unsigned char *, EMACS_INT,
- Lisp_Object, Lisp_Object, EMACS_INT,
- EMACS_INT, int);
-static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT,
- EMACS_INT, EMACS_INT, EMACS_INT, int,
+static EMACS_INT simple_search (EMACS_INT, unsigned char *, ptrdiff_t,
+ ptrdiff_t, Lisp_Object, ptrdiff_t, ptrdiff_t,
+ ptrdiff_t, ptrdiff_t);
+static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, ptrdiff_t,
+ Lisp_Object, Lisp_Object, ptrdiff_t,
+ ptrdiff_t, int);
+static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t,
+ ptrdiff_t, ptrdiff_t, EMACS_INT, int,
Lisp_Object, Lisp_Object, int);
static void matcher_overflow (void) NO_RETURN;
Lisp_Object, Lisp_Object, int);
static void matcher_overflow (void) NO_RETURN;
static Lisp_Object
string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix)
{
static Lisp_Object
string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix)
{
and return the index of the match, or negative on failure.
This does not clobber the match data. */
and return the index of the match, or negative on failure.
This does not clobber the match data. */
struct re_pattern_buffer *bufp;
bufp = compile_pattern (regexp, 0, Qnil,
struct re_pattern_buffer *bufp;
bufp = compile_pattern (regexp, 0, Qnil,
struct re_pattern_buffer *bufp;
bufp = compile_pattern (regexp, 0, Vascii_canon_table,
struct re_pattern_buffer *bufp;
bufp = compile_pattern (regexp, 0, Vascii_canon_table,
-EMACS_INT
-fast_looking_at (Lisp_Object regexp, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT limit, EMACS_INT limit_byte, Lisp_Object string)
+ptrdiff_t
+fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t limit, ptrdiff_t limit_byte, Lisp_Object string)
If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do
except when inside redisplay. */
If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do
except when inside redisplay. */
-EMACS_INT
-scan_buffer (register int target, EMACS_INT start, EMACS_INT end,
- EMACS_INT count, EMACS_INT *shortage, int allow_quit)
+ptrdiff_t
+scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
+ ptrdiff_t count, ptrdiff_t *shortage, int allow_quit)
the position of the last character before the next such
obstacle --- the last character the dumb search loop should
examine. */
the position of the last character before the next such
obstacle --- the last character the dumb search loop should
examine. */
/* If we're looking for a newline, consult the newline cache
to see where we can avoid some scanning. */
/* If we're looking for a newline, consult the newline cache
to see where we can avoid some scanning. */
/* Consult the newline cache, if appropriate. */
if (target == '\n' && newline_cache)
/* Consult the newline cache, if appropriate. */
if (target == '\n' && newline_cache)
-scan_newline (EMACS_INT start, EMACS_INT start_byte,
- EMACS_INT limit, EMACS_INT limit_byte,
+scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
+ ptrdiff_t limit, ptrdiff_t limit_byte,
register EMACS_INT count, int allow_quit)
{
int direction = ((count > 0) ? 1 : -1);
register EMACS_INT count, int allow_quit)
{
int direction = ((count > 0) ? 1 : -1);
- return scan_buffer ('\n', from, 0, cnt, (EMACS_INT *) 0, 0);
+ return scan_buffer ('\n', from, 0, cnt, (ptrdiff_t *) 0, 0);
}
/* Like find_next_newline, but returns position before the newline,
not after, and only search up to TO. This isn't just
find_next_newline (...)-1, because you might hit TO. */
}
/* Like find_next_newline, but returns position before the newline,
not after, and only search up to TO. This isn't just
find_next_newline (...)-1, because you might hit TO. */
- EMACS_INT shortage;
- EMACS_INT pos = scan_buffer ('\n', from, to, cnt, &shortage, 1);
+ ptrdiff_t shortage;
+ ptrdiff_t pos = scan_buffer ('\n', from, to, cnt, &shortage, 1);
Lisp_Object count, int direction, int RE, int posix)
{
register EMACS_INT np;
Lisp_Object count, int direction, int RE, int posix)
{
register EMACS_INT np;
-search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
- EMACS_INT lim, EMACS_INT lim_byte, EMACS_INT n,
+search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
+ ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n,
int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix)
{
int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix)
{
struct re_pattern_buffer *bufp;
bufp = compile_pattern (string,
struct re_pattern_buffer *bufp;
bufp = compile_pattern (string,
val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
pos_byte - BEGV_BYTE, lim_byte - pos_byte,
(NILP (Vinhibit_changing_match_data)
val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
pos_byte - BEGV_BYTE, lim_byte - pos_byte,
(NILP (Vinhibit_changing_match_data)
val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
pos_byte - BEGV_BYTE, lim_byte - pos_byte,
(NILP (Vinhibit_changing_match_data)
val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
pos_byte - BEGV_BYTE, lim_byte - pos_byte,
(NILP (Vinhibit_changing_match_data)
- EMACS_INT len, EMACS_INT len_byte, Lisp_Object trt,
- EMACS_INT pos, EMACS_INT pos_byte,
- EMACS_INT lim, EMACS_INT lim_byte)
+ ptrdiff_t len, ptrdiff_t len_byte, Lisp_Object trt,
+ ptrdiff_t pos, ptrdiff_t pos_byte,
+ ptrdiff_t lim, ptrdiff_t lim_byte)
{
int multibyte = ! NILP (BVAR (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 multibyte = ! NILP (BVAR (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. */
- EMACS_INT this_pos = pos;
- EMACS_INT this_pos_byte = pos_byte;
- EMACS_INT this_len = len;
+ ptrdiff_t this_pos = pos;
+ ptrdiff_t this_pos_byte = pos_byte;
+ ptrdiff_t this_len = len;
- EMACS_INT this_pos = pos;
- EMACS_INT this_pos_byte = pos_byte;
- EMACS_INT this_len = len;
+ ptrdiff_t this_pos = pos;
+ ptrdiff_t this_pos_byte = pos_byte;
+ ptrdiff_t this_len = len;
const unsigned char *p = pat + len_byte;
if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte)
const unsigned char *p = pat + len_byte;
if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte)
int stride_for_teases = 0;
int BM_tab[0400];
register unsigned char *cursor, *p_limit;
int stride_for_teases = 0;
int BM_tab[0400];
register unsigned char *cursor, *p_limit;
register int j;
unsigned char *pat, *pat_end;
int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
register int j;
unsigned char *pat, *pat_end;
int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
wordify (Lisp_Object string, int lax)
{
register unsigned char *o;
wordify (Lisp_Object string, int lax)
{
register unsigned char *o;
- register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0;
+ register ptrdiff_t i, i_byte, len, punct_count = 0, word_count = 0;
- adjust = - punct_count + 5 * (word_count - 1)
+ adjust = word_count - 1;
+ if (INT_MULTIPLY_OVERFLOW (5, adjust))
+ memory_full (SIZE_MAX);
+ adjust = - punct_count + 5 * adjust
- val = make_uninit_multibyte_string (len + adjust,
- SBYTES (string)
- + adjust);
+ {
+ if (INT_ADD_OVERFLOW (SBYTES (string), adjust))
+ memory_full (SIZE_MAX);
+ val = make_uninit_multibyte_string (len + adjust,
+ SBYTES (string) + adjust);
+ }
- val = make_uninit_string (len + adjust);
+ {
+ if (INT_ADD_OVERFLOW (len, adjust))
+ memory_full (SIZE_MAX);
+ val = make_uninit_string (len + adjust);
+ }
FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, 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;
(Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp)
{
enum { nochange, all_caps, cap_initial } case_action;
int delbackslash = 0;
FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
int delbackslash = 0;
FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
multibyte_chars_in_text (substed, substed_len);
newtext = make_multibyte_string ((char *) substed, nchars,
multibyte_chars_in_text (substed, substed_len);
newtext = make_multibyte_string ((char *) substed, nchars,
- EMACS_INT oldend = search_regs.end[sub];
- EMACS_INT oldstart = search_regs.start[sub];
- EMACS_INT change = newpoint - search_regs.end[sub];
- int i;
+ ptrdiff_t oldend = search_regs.end[sub];
+ ptrdiff_t oldstart = search_regs.start[sub];
+ ptrdiff_t change = newpoint - search_regs.end[sub];
+ ptrdiff_t i;
search_regs.start =
xpalloc (search_regs.start, &num_regs, length - num_regs,
min (PTRDIFF_MAX, UINT_MAX), sizeof (regoff_t));
search_regs.start =
xpalloc (search_regs.start, &num_regs, length - num_regs,
min (PTRDIFF_MAX, UINT_MAX), sizeof (regoff_t));
- search_regs.start[i] = from;
- search_regs.end[i] = XINT (marker);
+ if (TYPE_MINIMUM (regoff_t) <= XINT (from)
+ && XINT (from) <= TYPE_MAXIMUM (regoff_t)
+ && TYPE_MINIMUM (regoff_t) <= XINT (marker)
+ && XINT (marker) <= TYPE_MAXIMUM (regoff_t))
+ {
+ search_regs.start[i] = XINT (from);
+ search_regs.end[i] = XINT (marker);
+ }
+ else
+ {
+ search_regs.start[i] = -1;
+ }