]> code.delx.au - gnu-emacs/blobdiff - src/lread.c
Merge changes from emacs-23 branch.
[gnu-emacs] / src / lread.c
index 42925f8ac096f0d33082dba8cae2d9bc8f94951d..66b1a8068c2e98f3402c9eab73eed9e7e1c62713 100644 (file)
@@ -54,12 +54,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <locale.h>
 #endif /* HAVE_SETLOCALE */
 
-#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
-#endif
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
 
 #ifdef HAVE_FSEEKO
 #define file_offset off_t
@@ -75,7 +70,6 @@ Lisp_Object Qtest, Qsize;
 Lisp_Object Qweakness;
 Lisp_Object Qrehash_size;
 Lisp_Object Qrehash_threshold;
-extern Lisp_Object QCtest, QCsize, QCrehash_size, QCrehash_threshold, QCweakness;
 
 Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
@@ -91,9 +85,6 @@ static Lisp_Object Qget_emacs_mule_file_char;
 
 static Lisp_Object Qload_force_doc_strings;
 
-extern Lisp_Object Qevent_symbol_element_mask;
-extern Lisp_Object Qfile_exists_p;
-
 /* non-zero if inside `load' */
 int load_in_progress;
 static Lisp_Object Qload_in_progress;
@@ -167,13 +158,13 @@ static FILE *instream;
 static int read_pure;
 
 /* For use within read-from-string (this reader is non-reentrant!!)  */
-static int read_from_string_index;
-static int read_from_string_index_byte;
-static int read_from_string_limit;
+static EMACS_INT read_from_string_index;
+static EMACS_INT read_from_string_index_byte;
+static EMACS_INT read_from_string_limit;
 
 /* Number of characters read in the current call to Fread or
    Fread_from_string. */
-static int readchar_count;
+static EMACS_INT readchar_count;
 
 /* This contains the last string skipped with #@.  */
 static char *saved_doc_string;
@@ -280,7 +271,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
     {
       register struct buffer *inbuffer = XBUFFER (readcharfun);
 
-      int pt_byte = BUF_PT_BYTE (inbuffer);
+      EMACS_INT pt_byte = BUF_PT_BYTE (inbuffer);
 
       if (pt_byte >= BUF_ZV_BYTE (inbuffer))
        return -1;
@@ -309,7 +300,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
     {
       register struct buffer *inbuffer = XMARKER (readcharfun)->buffer;
 
-      int bytepos = marker_byte_position (readcharfun);
+      EMACS_INT bytepos = marker_byte_position (readcharfun);
 
       if (bytepos >= BUF_ZV_BYTE (inbuffer))
        return -1;
@@ -443,7 +434,7 @@ unreadchar (Lisp_Object readcharfun, int c)
   else if (BUFFERP (readcharfun))
     {
       struct buffer *b = XBUFFER (readcharfun);
-      int bytepos = BUF_PT_BYTE (b);
+      EMACS_INT bytepos = BUF_PT_BYTE (b);
 
       BUF_PT (b)--;
       if (! NILP (b->enable_multibyte_characters))
@@ -456,7 +447,7 @@ unreadchar (Lisp_Object readcharfun, int c)
   else if (MARKERP (readcharfun))
     {
       struct buffer *b = XMARKER (readcharfun)->buffer;
-      int bytepos = XMARKER (readcharfun)->bytepos;
+      EMACS_INT bytepos = XMARKER (readcharfun)->bytepos;
 
       XMARKER (readcharfun)->charpos--;
       if (! NILP (b->enable_multibyte_characters))
@@ -661,10 +652,8 @@ static void substitute_in_interval (INTERVAL, Lisp_Object);
    return Qnil if no input arrives within that time.  */
 
 Lisp_Object
-read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
-                    input_method, seconds)
-     int no_switch_frame, ascii_required, error_nonascii, input_method;
-     Lisp_Object seconds;
+read_filtered_event (int no_switch_frame, int ascii_required,
+                    int error_nonascii, int input_method, Lisp_Object seconds)
 {
   Lisp_Object val, delayed_switch_frame;
   EMACS_TIME end_time;
@@ -990,7 +979,7 @@ Return t if the file exists and loads successfully.  */)
   int compiled = 0;
   Lisp_Object handler;
   int safe_p = 1;
-  char *fmode = "r";
+  const char *fmode = "r";
   Lisp_Object tmp[2];
   int version;
 
@@ -1278,7 +1267,6 @@ Return t if the file exists and loads successfully.  */)
 
 static Lisp_Object
 load_unwind (Lisp_Object arg)  /* used as unwind-protect function in load */
-                     
 {
   FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer;
   if (stream != NULL)
@@ -1569,9 +1557,8 @@ build_load_history (Lisp_Object filename, int entire)
                           Vload_history);
 }
 
-Lisp_Object
+static Lisp_Object
 unreadpure (Lisp_Object junk) /* Used as unwind-protect function in readevalloop */
-                      
 {
   read_pure = 0;
   return Qnil;
@@ -1901,7 +1888,7 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end)
   if (STRINGP (stream)
       || ((CONSP (stream) && STRINGP (XCAR (stream)))))
     {
-      int startval, endval;
+      EMACS_INT startval, endval;
       Lisp_Object string;
 
       if (STRINGP (stream))
@@ -2316,28 +2303,28 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
              /* This is repetitive but fast and simple. */
              params[param_count] = QCsize;
              params[param_count+1] = Fplist_get (tmp, Qsize);
-             if (!NILP (params[param_count+1]))
-               param_count+=2;
+             if (!NILP (params[param_count + 1]))
+               param_count += 2;
 
              params[param_count] = QCtest;
              params[param_count+1] = Fplist_get (tmp, Qtest);
-             if (!NILP (params[param_count+1]))
-               param_count+=2;
+             if (!NILP (params[param_count + 1]))
+               param_count += 2;
 
              params[param_count] = QCweakness;
              params[param_count+1] = Fplist_get (tmp, Qweakness);
-             if (!NILP (params[param_count+1]))
-               param_count+=2;
+             if (!NILP (params[param_count + 1]))
+               param_count += 2;
 
              params[param_count] = QCrehash_size;
              params[param_count+1] = Fplist_get (tmp, Qrehash_size);
-             if (!NILP (params[param_count+1]))
-               param_count+=2;
+             if (!NILP (params[param_count + 1]))
+               param_count += 2;
 
              params[param_count] = QCrehash_threshold;
              params[param_count+1] = Fplist_get (tmp, Qrehash_threshold);
-             if (!NILP (params[param_count+1]))
-               param_count+=2;
+             if (!NILP (params[param_count + 1]))
+               param_count += 2;
 
              /* This is the hashtable data. */
              data = Fplist_get (tmp, Qdata);
@@ -2358,6 +2345,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
 
              return ht;
            }
+         UNREAD (c);
+         invalid_syntax ("#", 1);
        }
       if (c == '^')
        {
@@ -2723,7 +2712,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
 
            ok = (next_next_char <= 040
                  || (next_next_char < 0200
-                     && (index ("\"';([#?", next_next_char)
+                     && (strchr ("\"';([#?", next_next_char)
                          || (!first_in_list && next_next_char == '`')
                          || (new_backquote_flag && next_next_char == ','))));
          }
@@ -2731,7 +2720,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
          {
            ok = (next_char <= 040
                  || (next_char < 0200
-                     && (index ("\"';()[]#?", next_char)
+                     && (strchr ("\"';()[]#?", next_char)
                          || (!first_in_list && next_char == '`')
                          || (new_backquote_flag && next_char == ','))));
          }
@@ -2876,7 +2865,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
 
        if (next_char <= 040
            || (next_char < 0200
-               && (index ("\"';([#?", next_char)
+               && (strchr ("\"';([#?", next_char)
                    || (!first_in_list && next_char == '`')
                    || (new_backquote_flag && next_char == ','))))
          {
@@ -2903,7 +2892,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
          while (c > 040
                 && c != 0x8a0 /* NBSP */
                 && (c >= 0200
-                    || (!index ("\"';()[]#", c)
+                    || (!strchr ("\"';()[]#", c)
                         && !(!first_in_list && c == '`')
                         && !(new_backquote_flag && c == ','))))
            {
@@ -3188,11 +3177,10 @@ substitute_in_interval (INTERVAL interval, Lisp_Object arg)
 #define EXP_INT 16
 
 int
-isfloat_string (register char *cp, int ignore_trailing)
+isfloat_string (const char *cp, int ignore_trailing)
 {
-  register int state;
-
-  char *start = cp;
+  int state;
+  const char *start = cp;
 
   state = 0;
   if (*cp == '+' || *cp == '-')
@@ -3243,7 +3231,8 @@ isfloat_string (register char *cp, int ignore_trailing)
     }
 
   return ((ignore_trailing
-           || (*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || (*cp == '\r') || (*cp == '\f'))
+          || *cp == 0 || *cp == ' ' || *cp == '\t' || *cp == '\n'
+          || *cp == '\r' || *cp == '\f')
          && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
              || state == (DOT_CHAR|TRAIL_INT)
              || state == (LEAD_INT|E_CHAR|EXP_INT)
@@ -3586,13 +3575,13 @@ intern_c_string (const char *str)
 /* Create an uninterned symbol with name STR.  */
 
 Lisp_Object
-make_symbol (char *str)
+make_symbol (const char *str)
 {
   int len = strlen (str);
 
-  return Fmake_symbol ((!NILP (Vpurify_flag)
-                       ? make_pure_string (str, len, len, 0)
-                       : make_string (str, len)));
+  return Fmake_symbol (!NILP (Vpurify_flag)
+                      ? make_pure_string (str, len, len, 0)
+                      : make_string (str, len));
 }
 \f
 DEFUN ("intern", Fintern, Sintern, 1, 2, 0,
@@ -3745,7 +3734,7 @@ OBARRAY defaults to the value of the variable `obarray'.  */)
    Also store the bucket number in oblookup_last_bucket_number.  */
 
 Lisp_Object
-oblookup (Lisp_Object obarray, register const char *ptr, int size, int size_byte)
+oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte)
 {
   int hash;
   int obsize;
@@ -3818,7 +3807,7 @@ map_obarray (Lisp_Object obarray, void (*fn) (Lisp_Object, Lisp_Object), Lisp_Ob
     }
 }
 
-void
+static void
 mapatoms_1 (Lisp_Object sym, Lisp_Object function)
 {
   call1 (function, sym);
@@ -3977,7 +3966,7 @@ static Lisp_Object dump_path;
 void
 init_lread (void)
 {
-  char *normal;
+  const char *normal;
   int turn_off_warning = 0;
 
   /* Compute the default load-path.  */
@@ -4168,7 +4157,7 @@ init_lread (void)
    does not exist.  Print it on stderr and put it in *Messages*.  */
 
 void
-dir_warning (char *format, Lisp_Object dirname)
+dir_warning (const char *format, Lisp_Object dirname)
 {
   char *buffer
     = (char *) alloca (SCHARS (dirname) + strlen (format) + 5);