aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/lread.c b/src/lread.c
index 11c4cf8c8f4..3a1b3f0c9c5 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -109,9 +109,9 @@ static FILE *instream;
109static int read_pure; 109static int read_pure;
110 110
111/* For use within read-from-string (this reader is non-reentrant!!) */ 111/* For use within read-from-string (this reader is non-reentrant!!) */
112static EMACS_INT read_from_string_index; 112static ptrdiff_t read_from_string_index;
113static EMACS_INT read_from_string_index_byte; 113static ptrdiff_t read_from_string_index_byte;
114static EMACS_INT read_from_string_limit; 114static ptrdiff_t read_from_string_limit;
115 115
116/* Number of characters read in the current call to Fread or 116/* Number of characters read in the current call to Fread or
117 Fread_from_string. */ 117 Fread_from_string. */
@@ -209,7 +209,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
209 { 209 {
210 register struct buffer *inbuffer = XBUFFER (readcharfun); 210 register struct buffer *inbuffer = XBUFFER (readcharfun);
211 211
212 EMACS_INT pt_byte = BUF_PT_BYTE (inbuffer); 212 ptrdiff_t pt_byte = BUF_PT_BYTE (inbuffer);
213 213
214 if (pt_byte >= BUF_ZV_BYTE (inbuffer)) 214 if (pt_byte >= BUF_ZV_BYTE (inbuffer))
215 return -1; 215 return -1;
@@ -238,7 +238,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
238 { 238 {
239 register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; 239 register struct buffer *inbuffer = XMARKER (readcharfun)->buffer;
240 240
241 EMACS_INT bytepos = marker_byte_position (readcharfun); 241 ptrdiff_t bytepos = marker_byte_position (readcharfun);
242 242
243 if (bytepos >= BUF_ZV_BYTE (inbuffer)) 243 if (bytepos >= BUF_ZV_BYTE (inbuffer))
244 return -1; 244 return -1;
@@ -372,8 +372,8 @@ unreadchar (Lisp_Object readcharfun, int c)
372 else if (BUFFERP (readcharfun)) 372 else if (BUFFERP (readcharfun))
373 { 373 {
374 struct buffer *b = XBUFFER (readcharfun); 374 struct buffer *b = XBUFFER (readcharfun);
375 EMACS_INT charpos = BUF_PT (b); 375 ptrdiff_t charpos = BUF_PT (b);
376 EMACS_INT bytepos = BUF_PT_BYTE (b); 376 ptrdiff_t bytepos = BUF_PT_BYTE (b);
377 377
378 if (! NILP (BVAR (b, enable_multibyte_characters))) 378 if (! NILP (BVAR (b, enable_multibyte_characters)))
379 BUF_DEC_POS (b, bytepos); 379 BUF_DEC_POS (b, bytepos);
@@ -385,7 +385,7 @@ unreadchar (Lisp_Object readcharfun, int c)
385 else if (MARKERP (readcharfun)) 385 else if (MARKERP (readcharfun))
386 { 386 {
387 struct buffer *b = XMARKER (readcharfun)->buffer; 387 struct buffer *b = XMARKER (readcharfun)->buffer;
388 EMACS_INT bytepos = XMARKER (readcharfun)->bytepos; 388 ptrdiff_t bytepos = XMARKER (readcharfun)->bytepos;
389 389
390 XMARKER (readcharfun)->charpos--; 390 XMARKER (readcharfun)->charpos--;
391 if (! NILP (BVAR (b, enable_multibyte_characters))) 391 if (! NILP (BVAR (b, enable_multibyte_characters)))
@@ -1023,7 +1023,7 @@ Return t if the file exists and loads successfully. */)
1023{ 1023{
1024 register FILE *stream; 1024 register FILE *stream;
1025 register int fd = -1; 1025 register int fd = -1;
1026 int count = SPECPDL_INDEX (); 1026 ptrdiff_t count = SPECPDL_INDEX ();
1027 struct gcpro gcpro1, gcpro2, gcpro3; 1027 struct gcpro gcpro1, gcpro2, gcpro3;
1028 Lisp_Object found, efound, hist_file_name; 1028 Lisp_Object found, efound, hist_file_name;
1029 /* 1 means we printed the ".el is newer" message. */ 1029 /* 1 means we printed the ".el is newer" message. */
@@ -1443,16 +1443,16 @@ int
1443openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) 1443openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate)
1444{ 1444{
1445 register int fd; 1445 register int fd;
1446 EMACS_INT fn_size = 100; 1446 ptrdiff_t fn_size = 100;
1447 char buf[100]; 1447 char buf[100];
1448 register char *fn = buf; 1448 register char *fn = buf;
1449 int absolute = 0; 1449 int absolute = 0;
1450 EMACS_INT want_length; 1450 ptrdiff_t want_length;
1451 Lisp_Object filename; 1451 Lisp_Object filename;
1452 struct stat st; 1452 struct stat st;
1453 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 1453 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
1454 Lisp_Object string, tail, encoded_fn; 1454 Lisp_Object string, tail, encoded_fn;
1455 EMACS_INT max_suffix_len = 0; 1455 ptrdiff_t max_suffix_len = 0;
1456 1456
1457 CHECK_STRING (str); 1457 CHECK_STRING (str);
1458 1458
@@ -1562,7 +1562,9 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1562 { 1562 {
1563 /* Check that we can access or open it. */ 1563 /* Check that we can access or open it. */
1564 if (NATNUMP (predicate)) 1564 if (NATNUMP (predicate))
1565 fd = (access (pfn, XFASTINT (predicate)) == 0) ? 1 : -1; 1565 fd = (((XFASTINT (predicate) & ~INT_MAX) == 0
1566 && access (pfn, XFASTINT (predicate)) == 0)
1567 ? 1 : -1);
1566 else 1568 else
1567 fd = emacs_open (pfn, O_RDONLY, 0); 1569 fd = emacs_open (pfn, O_RDONLY, 0);
1568 1570
@@ -1696,7 +1698,7 @@ readevalloop (Lisp_Object readcharfun,
1696{ 1698{
1697 register int c; 1699 register int c;
1698 register Lisp_Object val; 1700 register Lisp_Object val;
1699 int count = SPECPDL_INDEX (); 1701 ptrdiff_t count = SPECPDL_INDEX ();
1700 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1702 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1701 struct buffer *b = 0; 1703 struct buffer *b = 0;
1702 int continue_reading_p; 1704 int continue_reading_p;
@@ -1747,7 +1749,7 @@ readevalloop (Lisp_Object readcharfun,
1747 continue_reading_p = 1; 1749 continue_reading_p = 1;
1748 while (continue_reading_p) 1750 while (continue_reading_p)
1749 { 1751 {
1750 int count1 = SPECPDL_INDEX (); 1752 ptrdiff_t count1 = SPECPDL_INDEX ();
1751 1753
1752 if (b != 0 && NILP (BVAR (b, name))) 1754 if (b != 0 && NILP (BVAR (b, name)))
1753 error ("Reading from killed buffer"); 1755 error ("Reading from killed buffer");
@@ -1873,7 +1875,7 @@ DO-ALLOW-PRINT, if non-nil, specifies that `print' and related
1873This function preserves the position of point. */) 1875This function preserves the position of point. */)
1874 (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, Lisp_Object unibyte, Lisp_Object do_allow_print) 1876 (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, Lisp_Object unibyte, Lisp_Object do_allow_print)
1875{ 1877{
1876 int count = SPECPDL_INDEX (); 1878 ptrdiff_t count = SPECPDL_INDEX ();
1877 Lisp_Object tem, buf; 1879 Lisp_Object tem, buf;
1878 1880
1879 if (NILP (buffer)) 1881 if (NILP (buffer))
@@ -1918,7 +1920,7 @@ This function does not move point. */)
1918 (Lisp_Object start, Lisp_Object end, Lisp_Object printflag, Lisp_Object read_function) 1920 (Lisp_Object start, Lisp_Object end, Lisp_Object printflag, Lisp_Object read_function)
1919{ 1921{
1920 /* FIXME: Do the eval-sexp-add-defvars danse! */ 1922 /* FIXME: Do the eval-sexp-add-defvars danse! */
1921 int count = SPECPDL_INDEX (); 1923 ptrdiff_t count = SPECPDL_INDEX ();
1922 Lisp_Object tem, cbuf; 1924 Lisp_Object tem, cbuf;
1923 1925
1924 cbuf = Fcurrent_buffer (); 1926 cbuf = Fcurrent_buffer ();
@@ -1994,7 +1996,7 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end)
1994 if (STRINGP (stream) 1996 if (STRINGP (stream)
1995 || ((CONSP (stream) && STRINGP (XCAR (stream))))) 1997 || ((CONSP (stream) && STRINGP (XCAR (stream)))))
1996 { 1998 {
1997 EMACS_INT startval, endval; 1999 ptrdiff_t startval, endval;
1998 Lisp_Object string; 2000 Lisp_Object string;
1999 2001
2000 if (STRINGP (stream)) 2002 if (STRINGP (stream))
@@ -2007,9 +2009,9 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end)
2007 else 2009 else
2008 { 2010 {
2009 CHECK_NUMBER (end); 2011 CHECK_NUMBER (end);
2010 endval = XINT (end); 2012 if (! (0 <= XINT (end) && XINT (end) <= SCHARS (string)))
2011 if (endval < 0 || endval > SCHARS (string))
2012 args_out_of_range (string, end); 2013 args_out_of_range (string, end);
2014 endval = XINT (end);
2013 } 2015 }
2014 2016
2015 if (NILP (start)) 2017 if (NILP (start))
@@ -2017,9 +2019,9 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end)
2017 else 2019 else
2018 { 2020 {
2019 CHECK_NUMBER (start); 2021 CHECK_NUMBER (start);
2020 startval = XINT (start); 2022 if (! (0 <= XINT (start) && XINT (start) <= endval))
2021 if (startval < 0 || startval > endval)
2022 args_out_of_range (string, start); 2023 args_out_of_range (string, start);
2024 startval = XINT (start);
2023 } 2025 }
2024 read_from_string_index = startval; 2026 read_from_string_index = startval;
2025 read_from_string_index_byte = string_char_to_byte (string, startval); 2027 read_from_string_index_byte = string_char_to_byte (string, startval);
@@ -2495,14 +2497,13 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2495 if (c == '[') 2497 if (c == '[')
2496 { 2498 {
2497 Lisp_Object tmp; 2499 Lisp_Object tmp;
2498 EMACS_INT depth, size; 2500 int depth;
2501 ptrdiff_t size;
2499 2502
2500 tmp = read_vector (readcharfun, 0); 2503 tmp = read_vector (readcharfun, 0);
2501 if (!INTEGERP (AREF (tmp, 0))) 2504 if (! RANGED_INTEGERP (1, AREF (tmp, 0), 3))
2502 error ("Invalid depth in char-table"); 2505 error ("Invalid depth in char-table");
2503 depth = XINT (AREF (tmp, 0)); 2506 depth = XINT (AREF (tmp, 0));
2504 if (depth < 1 || depth > 3)
2505 error ("Invalid depth in char-table");
2506 size = ASIZE (tmp) - 2; 2507 size = ASIZE (tmp) - 2;
2507 if (chartab_size [depth] != size) 2508 if (chartab_size [depth] != size)
2508 error ("Invalid size char-table"); 2509 error ("Invalid size char-table");
@@ -3099,8 +3100,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
3099 } 3100 }
3100 { 3101 {
3101 Lisp_Object name, result; 3102 Lisp_Object name, result;
3102 EMACS_INT nbytes = p - read_buffer; 3103 ptrdiff_t nbytes = p - read_buffer;
3103 EMACS_INT nchars 3104 ptrdiff_t nchars
3104 = (multibyte 3105 = (multibyte
3105 ? multibyte_chars_in_text ((unsigned char *) read_buffer, 3106 ? multibyte_chars_in_text ((unsigned char *) read_buffer,
3106 nbytes) 3107 nbytes)
@@ -3885,7 +3886,7 @@ OBARRAY defaults to the value of the variable `obarray'. */)
3885 Also store the bucket number in oblookup_last_bucket_number. */ 3886 Also store the bucket number in oblookup_last_bucket_number. */
3886 3887
3887Lisp_Object 3888Lisp_Object
3888oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte) 3889oblookup (Lisp_Object obarray, register const char *ptr, ptrdiff_t size, ptrdiff_t size_byte)
3889{ 3890{
3890 size_t hash; 3891 size_t hash;
3891 size_t obsize; 3892 size_t obsize;