summaryrefslogtreecommitdiff
path: root/src/syntax.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-04-17 14:09:01 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-04-17 14:11:30 -0700
commit2cb7e8669c3cdd0f7f0687e01810a3160d6b5c5b (patch)
tree21fd3ca5914224a2478d7c528e68d0ca64ceddc1 /src/syntax.c
parentfadfde5fdf2fd8fc3b3b4ba430a954a89d0cd1fe (diff)
downloademacs-2cb7e8669c3cdd0f7f0687e01810a3160d6b5c5b.tar.gz
emacs-2cb7e8669c3cdd0f7f0687e01810a3160d6b5c5b.tar.bz2
emacs-2cb7e8669c3cdd0f7f0687e01810a3160d6b5c5b.zip
Port recent character.h changes to --with-wide-int
* src/fns.c (mapcar1): * src/keymap.c (Fkey_description): * src/syntax.c (scan_lists): Prefer ptrdiff_t to EMACS_INT where either will do; this fixes newly-introduced type errors on --with-wide-int platforms where ptrdiff_t is narrower than EMACS_INT. * src/keymap.c (Fkey_description): Rework for clarity; remove goto. * src/syntax.c (scan_words, Fforward_comment, scan_lists)): Fix unlikely integer overflow problems that can occur on --with-wide-int platforms, and that were caught by the recent character.h changes.
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/syntax.c b/src/syntax.c
index bcf4dc07997..c765cc9a17b 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1441,7 +1441,7 @@ scan_words (ptrdiff_t from, EMACS_INT count)
int ch0, ch1;
Lisp_Object func, pos;
- SETUP_SYNTAX_TABLE (from, count);
+ SETUP_SYNTAX_TABLE (from, clip_to_bounds (PTRDIFF_MIN, count, PTRDIFF_MAX));
while (count > 0)
{
@@ -2434,7 +2434,7 @@ between them, return t; otherwise return nil. */)
from = PT;
from_byte = PT_BYTE;
- SETUP_SYNTAX_TABLE (from, count1);
+ SETUP_SYNTAX_TABLE (from, clip_to_bounds (PTRDIFF_MIN, count1, PTRDIFF_MAX));
while (count1 > 0)
{
do
@@ -2624,7 +2624,7 @@ syntax_multibyte (int c, bool multibyte_symbol_p)
}
static Lisp_Object
-scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
+scan_lists (EMACS_INT from0, EMACS_INT count, EMACS_INT depth, bool sexpflag)
{
Lisp_Object val;
ptrdiff_t stop = count > 0 ? ZV : BEGV;
@@ -2637,7 +2637,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
int comstyle = 0; /* Style of comment encountered. */
bool comnested = 0; /* Whether the comment is nestable or not. */
ptrdiff_t temp_pos;
- EMACS_INT last_good = from;
+ EMACS_INT last_good = from0;
bool found;
ptrdiff_t from_byte;
ptrdiff_t out_bytepos, out_charpos;
@@ -2648,14 +2648,13 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
if (depth > 0) min_depth = 0;
- if (from > ZV) from = ZV;
- if (from < BEGV) from = BEGV;
+ ptrdiff_t from = clip_to_bounds (BEGV, from0, ZV);
from_byte = CHAR_TO_BYTE (from);
maybe_quit ();
- SETUP_SYNTAX_TABLE (from, count);
+ SETUP_SYNTAX_TABLE (from, clip_to_bounds (PTRDIFF_MIN, count, PTRDIFF_MAX));
while (count > 0)
{
while (from < stop)