Commit d1dfb56c authored by Eli Zaretskii's avatar Eli Zaretskii

Fix regex.c, syntax.c and friends for buffers > 2GB.

 src/syntax.h (struct gl_state_s): Declare character position members
 EMACS_INT.
 src/syntax.c (update_syntax_table): Declare 2nd argument EMACS_INT.
 src/textprop.c (verify_interval_modification, interval_of): Declare
 arguments EMACS_INT.
 src/intervals.c (adjust_intervals_for_insertion): Declare arguments
 EMACS_INT.
 src/intervals.h (CHECK_TOTAL_LENGTH): Cast to EMACS_INT, not `int'.
 src/indent.c (Fvertical_motion): Local variable it_start is now
 EMACS_INT.
 src/regex.c (re_match, re_match_2, re_match_2_internal)
 (bcmp_translate, regcomp, regexec, print_double_string)
 (group_in_compile_stack, re_search, re_search_2, regex_compile)
 (re_compile_pattern, re_exec): Declare arguments and local
 variables `size_t' and `ssize_t' and return values `regoff_t', as
 appropriate.
 (POP_FAILURE_REG_OR_COUNT) <pfreg>: Declare `long'.
 (CHECK_INFINITE_LOOP) <failure>: Declare `ssize_t'.
 <compile_stack_type>: `size' and `avail' are now `size_t'.
 src/regex.h <regoff_t>: Use ssize_t, not int.
 (re_search, re_search_2, re_match, re_match_2): Arguments that
 specify buffer/string position and length are now ssize_t and
 size_t.  Return type is regoff_t.
parent 10472dd0
2011-04-16 Eli Zaretskii <eliz@gnu.org>
Fix regex.c, syntax.c and friends for buffers > 2GB.
* syntax.h (struct gl_state_s): Declare character position members
EMACS_INT.
* syntax.c (update_syntax_table): Declare 2nd argument EMACS_INT.
* textprop.c (verify_interval_modification, interval_of): Declare
arguments EMACS_INT.
* intervals.c (adjust_intervals_for_insertion): Declare arguments
EMACS_INT.
* intervals.h (CHECK_TOTAL_LENGTH): Cast to EMACS_INT, not `int'.
* indent.c (Fvertical_motion): Local variable it_start is now
EMACS_INT.
* regex.c (re_match, re_match_2, re_match_2_internal)
(bcmp_translate, regcomp, regexec, print_double_string)
(group_in_compile_stack, re_search, re_search_2, regex_compile)
(re_compile_pattern, re_exec): Declare arguments and local
variables `size_t' and `ssize_t' and return values `regoff_t', as
appropriate.
(POP_FAILURE_REG_OR_COUNT) <pfreg>: Declare `long'.
(CHECK_INFINITE_LOOP) <failure>: Declare `ssize_t'.
<compile_stack_type>: `size' and `avail' are now `size_t'.
* regex.h <regoff_t>: Use ssize_t, not int.
(re_search, re_search_2, re_match, re_match_2): Arguments that
specify buffer/string position and length are now ssize_t and
size_t. Return type is regoff_t.
2011-04-16 Ben Key <bkey76@gmail.com>
* nsfont.m: Fixed bugs in ns_get_family and
......
......@@ -2026,7 +2026,8 @@ whether or not it is currently displayed in some window. */)
}
else
{
int it_start, first_x, it_overshoot_expected IF_LINT (= 0);
EMACS_INT it_start;
int first_x, it_overshoot_expected IF_LINT (= 0);
SET_TEXT_POS (pt, PT, PT_BYTE);
start_display (&it, w, pt);
......
......@@ -805,9 +805,9 @@ update_interval (register INTERVAL i, EMACS_INT pos)
static INTERVAL
adjust_intervals_for_insertion (tree, position, length)
INTERVAL tree;
int position, length;
EMACS_INT position, length;
{
register int relative_position;
register EMACS_INT relative_position;
register INTERVAL this;
if (TOTAL_LENGTH (tree) == 0) /* Paranoia */
......
......@@ -161,12 +161,12 @@ struct interval
(INTERVAL_HAS_PARENT (i) ? INTERVAL_PARENT (i) : 0)
/* Abort if interval I's size is negative. */
#define CHECK_TOTAL_LENGTH(i) \
do \
{ \
if ((int) (i)->total_length < 0) \
abort (); \
} \
#define CHECK_TOTAL_LENGTH(i) \
do \
{ \
if ((EMACS_INT) (i)->total_length < 0) \
abort (); \
} \
while (0)
/* Reset this interval to its vanilla, or no-property state. */
......@@ -269,7 +269,8 @@ extern INTERVAL merge_interval_left (INTERVAL);
extern void offset_intervals (struct buffer *, EMACS_INT, EMACS_INT);
extern void graft_intervals_into_buffer (INTERVAL, EMACS_INT, EMACS_INT,
struct buffer *, int);
extern void verify_interval_modification (struct buffer *, int, int);
extern void verify_interval_modification (struct buffer *,
EMACS_INT, EMACS_INT);
extern INTERVAL balance_intervals (INTERVAL);
extern void copy_intervals_to_string (Lisp_Object, struct buffer *,
EMACS_INT, EMACS_INT);
......@@ -285,7 +286,7 @@ extern INTERVAL update_interval (INTERVAL, EMACS_INT);
extern void set_intervals_multibyte (int);
extern INTERVAL validate_interval_range (Lisp_Object, Lisp_Object *,
Lisp_Object *, int);
extern INTERVAL interval_of (int, Lisp_Object);
extern INTERVAL interval_of (EMACS_INT, Lisp_Object);
/* Defined in xdisp.c */
extern int invisible_p (Lisp_Object, Lisp_Object);
......
This diff is collapsed.
......@@ -414,8 +414,12 @@ struct re_pattern_buffer
typedef struct re_pattern_buffer regex_t;
/* Type for byte offsets within the string. POSIX mandates this. */
typedef int regoff_t;
/* Type for byte offsets within the string. POSIX mandates this to be an int,
but the Open Group has signalled its intention to change the requirement to
be that regoff_t be at least as wide as ptrdiff_t and ssize_t. Current
gnulib sources also use ssize_t, and we need this for supporting buffers and
strings > 2GB on 64-bit hosts. */
typedef ssize_t regoff_t;
/* This is the structure we store register match data in. See
......@@ -486,31 +490,33 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
characters. Return the starting position of the match, -1 for no
match, or -2 for an internal error. Also return register
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
extern int re_search
extern regoff_t re_search
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
int length, int start, int range, struct re_registers *regs));
size_t length, ssize_t start, ssize_t range,
struct re_registers *regs));
/* Like `re_search', but search in the concatenation of STRING1 and
STRING2. Also, stop searching at index START + STOP. */
extern int re_search_2
extern regoff_t re_search_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, int range, struct re_registers *regs, int stop));
size_t length1, const char *string2, size_t length2,
ssize_t start, ssize_t range, struct re_registers *regs,
ssize_t stop));
/* Like `re_search', but return how many characters in STRING the regexp
in BUFFER matched, starting at position START. */
extern int re_match
extern regoff_t re_match
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
int length, int start, struct re_registers *regs));
size_t length, ssize_t start, struct re_registers *regs));
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
extern int re_match_2
extern regoff_t re_match_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, struct re_registers *regs, int stop));
size_t length1, const char *string2, size_t length2,
ssize_t start, struct re_registers *regs, ssize_t stop));
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
......@@ -556,14 +562,15 @@ extern int re_exec _RE_ARGS ((const char *));
#endif
/* POSIX compatibility. */
extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
const char *__restrict __pattern,
int __cflags));
extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
const char *__restrict __string, size_t __nmatch,
regmatch_t __pmatch[__restrict_arr],
int __eflags));
extern reg_errcode_t regcomp _RE_ARGS ((regex_t *__restrict __preg,
const char *__restrict __pattern,
int __cflags));
extern reg_errcode_t regexec _RE_ARGS ((const regex_t *__restrict __preg,
const char *__restrict __string,
size_t __nmatch,
regmatch_t __pmatch[__restrict_arr],
int __eflags));
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
char *__errbuf, size_t __errbuf_size));
......
......@@ -175,7 +175,7 @@ struct gl_state_s gl_state; /* Global state of syntax parser. */
start/end of OBJECT. */
void
update_syntax_table (EMACS_INT charpos, int count, int init,
update_syntax_table (EMACS_INT charpos, EMACS_INT count, int init,
Lisp_Object object)
{
Lisp_Object tmp_table;
......
......@@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
extern void update_syntax_table (EMACS_INT, int, int, Lisp_Object);
extern void update_syntax_table (EMACS_INT, EMACS_INT, int, Lisp_Object);
/* The standard syntax table is stored where it will automatically
be used in all new buffers. */
......@@ -276,15 +276,15 @@ while (0)
struct gl_state_s
{
Lisp_Object object; /* The object we are scanning. */
int start; /* Where to stop. */
int stop; /* Where to stop. */
EMACS_INT start; /* Where to stop. */
EMACS_INT stop; /* Where to stop. */
int use_global; /* Whether to use global_code
or c_s_t. */
Lisp_Object global_code; /* Syntax code of current char. */
Lisp_Object current_syntax_table; /* Syntax table for current pos. */
Lisp_Object old_prop; /* Syntax-table prop at prev pos. */
int b_property; /* First index where c_s_t is valid. */
int e_property; /* First index where c_s_t is
EMACS_INT b_property; /* First index where c_s_t is valid. */
EMACS_INT e_property; /* First index where c_s_t is
not valid. */
INTERVAL forward_i; /* Where to start lookup on forward */
INTERVAL backward_i; /* or backward movement. The
......@@ -294,7 +294,7 @@ struct gl_state_s
intervals too, depending
on: */
/* Offset for positions specified to UPDATE_SYNTAX_TABLE. */
int offset;
EMACS_INT offset;
};
extern struct gl_state_s gl_state;
......
......@@ -514,7 +514,7 @@ erase_properties (INTERVAL i)
POSITION is BEG-based. */
INTERVAL
interval_of (int position, Lisp_Object object)
interval_of (EMACS_INT position, Lisp_Object object)
{
register INTERVAL i;
EMACS_INT beg, end;
......@@ -2012,7 +2012,8 @@ call_mod_hooks (Lisp_Object list, Lisp_Object start, Lisp_Object end)
those hooks in order, with START and END - 1 as arguments. */
void
verify_interval_modification (struct buffer *buf, int start, int end)
verify_interval_modification (struct buffer *buf,
EMACS_INT start, EMACS_INT end)
{
register INTERVAL intervals = BUF_INTERVALS (buf);
register INTERVAL i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment