]> code.delx.au - gnu-emacs/blobdiff - src/lread.c
(Fget_char_property): Update call to overlays_at.
[gnu-emacs] / src / lread.c
index 02d6bbd3c37108bc234cb4764218e8aad4f5ca6e..3a1bc00c03fa687b688668d2e0e154176057e0f3 100644 (file)
@@ -21,14 +21,6 @@ Boston, MA 02111-1307, USA.  */
 
 
 #include <config.h>
-/* The following feature selections should be in config.h, but that
-   causes at best a host of warnings on some systems.  */
-#undef _XOPEN_SOURCE           /* Avoid warnings about redefinition
-                                  in some cases.  */
-#define _XOPEN_SOURCE 500      /* for Unix 98 ftello on GNU */
-#undef __EXTENSIONS__
-#define __EXTENSIONS__         /* Keep Solaris 2.6 happy with the
-                                  above, else things we need are hidden.  */
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -296,12 +288,10 @@ readchar (readcharfun)
     {
       if (read_from_string_index >= read_from_string_limit)
        c = -1;
-      else if (STRING_MULTIBYTE (readcharfun))
+      else
        FETCH_STRING_CHAR_ADVANCE (c, readcharfun,
                                   read_from_string_index,
                                   read_from_string_index_byte);
-      else
-       c = XSTRING (readcharfun)->data[read_from_string_index++];
 
       return c;
     }
@@ -410,6 +400,11 @@ read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
 {
   register Lisp_Object val, delayed_switch_frame;
 
+#ifdef HAVE_WINDOW_SYSTEM
+  if (display_busy_cursor_p)
+    cancel_busy_cursor ();
+#endif
+  
   delayed_switch_frame = Qnil;
 
   /* Read until we get an acceptable event.  */
@@ -467,6 +462,10 @@ read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
   if (! NILP (delayed_switch_frame))
     unread_switch_frame = delayed_switch_frame;
 
+#ifdef HAVE_WINDOW_SYSTEM
+  if (display_busy_cursor_p)
+    start_busy_cursor ();
+#endif
   return val;
 }
 
@@ -611,11 +610,11 @@ Return t if file exists.")
   /* 1 means we are loading a compiled file.  */
   int compiled = 0;
   Lisp_Object handler;
+  int safe_p = 1;
   char *fmode = "r";
 #ifdef DOS_NT
   fmode = "rt";
 #endif /* DOS_NT */
-  int safe_p = 1;
 
   CHECK_STRING (file, 0);
 
@@ -670,6 +669,7 @@ Return t if file exists.")
        return Qnil;
     }
 
+  /* Tell startup.el whether or not we found the user's init file.  */
   if (EQ (Qt, Vuser_init_file))
     Vuser_init_file = found;
 
@@ -1102,6 +1102,22 @@ readevalloop_1 (old)
   return Qnil;
 }
 
+/* Signal an `end-of-file' error, if possible with file name
+   information.  */
+
+static void
+end_of_file_error ()
+{
+  Lisp_Object data;
+
+  if (STRINGP (Vload_file_name))
+    data = Fcons (Vload_file_name, Qnil);
+  else
+    data = Qnil;
+
+  Fsignal (Qend_of_file, data);
+}
+
 /* UNIBYTE specifies how to set load_convert_to_unibyte
    for this invocation.
    READFUN, if non-nil, is used instead of `read'.  */
@@ -1120,6 +1136,7 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, read
   int count = specpdl_ptr - specpdl;
   struct gcpro gcpro1;
   struct buffer *b = 0;
+  int continue_reading_p;
 
   if (BUFFERP (readcharfun))
     b = XBUFFER (readcharfun);
@@ -1137,7 +1154,8 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, read
 
   LOADHIST_ATTACH (sourcename);
 
-  while (1)
+  continue_reading_p = 1;
+  while (continue_reading_p)
     {
       if (b != 0 && NILP (b->name))
        error ("Reading from killed buffer");
@@ -1166,8 +1184,20 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, read
        {
          UNREAD (c);
          read_objects = Qnil;
-         if (! NILP (readfun))
-           val = call1 (readfun, readcharfun);
+         if (!NILP (readfun))
+           {
+             val = call1 (readfun, readcharfun);
+
+             /* If READCHARFUN has set point to ZV, we should
+                stop reading, even if the form read sets point
+                to a different value when evaluated.  */
+             if (BUFFERP (readcharfun))
+               {
+                 struct buffer *b = XBUFFER (readcharfun);
+                 if (BUF_PT (b) == BUF_ZV (b))
+                   continue_reading_p = 0;
+               }
+           }
          else if (! NILP (Vload_read_function))
            val = call1 (Vload_read_function, readcharfun);
          else
@@ -1175,6 +1205,7 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, read
        }
 
       val = (*evalfun) (val);
+
       if (printflag)
        {
          Vvalues = Fcons (val, Vvalues);
@@ -1682,7 +1713,8 @@ read1 (readcharfun, pch, first_in_list)
  retry:
 
   c = READCHAR;
-  if (c < 0) return Fsignal (Qend_of_file, Qnil);
+  if (c < 0)
+    end_of_file_error ();
 
   switch (c)
     {
@@ -2000,7 +2032,8 @@ read1 (readcharfun, pch, first_in_list)
     case '?':
       {
        c = READCHAR;
-       if (c < 0) return Fsignal (Qend_of_file, Qnil);
+       if (c < 0)
+         end_of_file_error ();
 
        if (c == '\\')
          c = read_escape (readcharfun, 0);
@@ -2088,7 +2121,7 @@ read1 (readcharfun, pch, first_in_list)
              }
          }
        if (c < 0)
-         return Fsignal (Qend_of_file, Qnil);
+         end_of_file_error ();
 
        /* If purifying, and string starts with \ newline,
           return zero instead.  This is for doc strings
@@ -2097,13 +2130,15 @@ read1 (readcharfun, pch, first_in_list)
          return make_number (0);
 
        if (force_multibyte)
-         nchars = multibyte_chars_in_text (read_buffer, p - read_buffer);
+         p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
+                                             p - read_buffer, &nchars);
        else if (force_singlebyte)
          nchars = p - read_buffer;
        else if (load_convert_to_unibyte)
          {
            Lisp_Object string;
-           nchars = multibyte_chars_in_text (read_buffer, p - read_buffer);
+           p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
+                                               p - read_buffer, &nchars);
            if (p - read_buffer != nchars)
              {
                string = make_multibyte_string (read_buffer, nchars,
@@ -2113,12 +2148,13 @@ read1 (readcharfun, pch, first_in_list)
          }
        else if (EQ (readcharfun, Qget_file_char)
                 || EQ (readcharfun, Qlambda))
-         /* Nowadays, reading directly from a file
-            is used only for compiled Emacs Lisp files,
-            and those always use the Emacs internal encoding.
-            Meanwhile, Qlambda is used for reading dynamic byte code
-            (compiled with byte-compile-dynamic = t).  */
-         nchars = multibyte_chars_in_text (read_buffer, p - read_buffer);
+         /* Nowadays, reading directly from a file is used only for
+            compiled Emacs Lisp files, and those always use the
+            Emacs internal encoding.  Meanwhile, Qlambda is used
+            for reading dynamic byte code (compiled with
+            byte-compile-dynamic = t).  */
+         p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
+                                             p - read_buffer, &nchars);
        else
          /* In all other cases, if we read these bytes as
             separate characters, treat them as separate characters now.  */
@@ -2135,13 +2171,11 @@ read1 (readcharfun, pch, first_in_list)
 
     case '.':
       {
-       /* If a period is followed by a number, then we should read it
-          as a floating point number.  Otherwise, it denotes a dotted
-          pair.  */
        int next_char = READCHAR;
        UNREAD (next_char);
 
-       if (! (next_char >= '0' && next_char <= '9'))
+       if (next_char <= 040
+           || index ("\"'`,(", next_char))
          {
            *pch = c;
            return Qnil;
@@ -2337,7 +2371,7 @@ substitute_object_recurse (object, placeholder, subtree)
     case Lisp_Vectorlike:
       {
        int i;
-       int length = Flength(subtree);
+       int length = XINT (Flength(subtree));
        for (i = 0; i < length; i++)
          {
            Lisp_Object idx = make_number (i);