]> code.delx.au - gnu-emacs/blobdiff - src/lread.c
Backport revisions 2011-04-24T05:30:24Z!eggert@cs.ucla.edu..2011-04-25T19:40:22Z...
[gnu-emacs] / src / lread.c
index 0649c638d9895fc1c0977bbce5cb04ee1b84e993..3d954ac282be72e87d7c1f2b82ed89f8559f22fb 100644 (file)
@@ -1,7 +1,7 @@
 /* Lisp parsing and input streams.
    Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995,
                  1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+                 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -458,15 +458,15 @@ unreadchar (readcharfun, c)
   else if (BUFFERP (readcharfun))
     {
       struct buffer *b = XBUFFER (readcharfun);
-      int bytepos = BUF_PT_BYTE (b);
+      EMACS_INT charpos = BUF_PT (b);
+      EMACS_INT bytepos = BUF_PT_BYTE (b);
 
-      BUF_PT (b)--;
       if (! NILP (b->enable_multibyte_characters))
        BUF_DEC_POS (b, bytepos);
       else
        bytepos--;
 
-      BUF_PT_BYTE (b) = bytepos;
+      SET_BUF_PT_BOTH (b, charpos - 1, bytepos);
     }
   else if (MARKERP (readcharfun))
     {
@@ -616,7 +616,7 @@ read_emacs_mule_char (c, readbyte, readcharfun)
 
   if (len == 2)
     {
-      charset = emacs_mule_charset[buf[0]];
+      charset = CHARSET_FROM_ID (emacs_mule_charset[buf[0]]);
       code = buf[1] & 0x7F;
     }
   else if (len == 3)
@@ -624,18 +624,18 @@ read_emacs_mule_char (c, readbyte, readcharfun)
       if (buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_11
          || buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_12)
        {
-         charset = emacs_mule_charset[buf[1]];
+         charset = CHARSET_FROM_ID (emacs_mule_charset[buf[1]]);
          code = buf[2] & 0x7F;
        }
       else
        {
-         charset = emacs_mule_charset[buf[0]];
+         charset = CHARSET_FROM_ID (emacs_mule_charset[buf[0]]);
          code = ((buf[1] << 8) | buf[2]) & 0x7F7F;
        }
     }
   else
     {
-      charset = emacs_mule_charset[buf[1]];
+      charset = CHARSET_FROM_ID (emacs_mule_charset[buf[1]]);
       code = ((buf[2] << 8) | buf[3]) & 0x7F7F;
     }
   c = DECODE_CHAR (charset, code);
@@ -1007,6 +1007,10 @@ Loading a file records its definitions, and its `provide' and
 `require' calls, in an element of `load-history' whose
 car is the file name loaded.  See `load-history'.
 
+While the file is in the process of being loaded, the variable
+`load-in-progress' is non-nil and the variable `load-file-name'
+is bound to the file's name.
+
 Return t if the file exists and loads successfully.  */)
      (file, noerror, nomessage, nosuffix, must_suffix)
      Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
@@ -1155,7 +1159,7 @@ Return t if the file exists and loads successfully.  */)
 
   if (!bcmp (SDATA (found) + SBYTES (found) - 4,
             ".elc", 4)
-      || (version = safe_to_load_p (fd)) > 0)
+      || (fd >= 0 && (version = safe_to_load_p (fd)) > 0))
     /* Load .elc files directly, but not when they are
        remote and have no handler!  */
     {
@@ -2377,28 +2381,28 @@ read1 (readcharfun, pch, 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);
@@ -2419,6 +2423,8 @@ read1 (readcharfun, pch, first_in_list)
 
              return ht;
            }
+         UNREAD (c);
+         invalid_syntax ("#", 1);
        }
       if (c == '^')
        {
@@ -2427,7 +2433,7 @@ read1 (readcharfun, pch, first_in_list)
            {
              Lisp_Object tmp;
              tmp = read_vector (readcharfun, 0);
-             if (XVECTOR (tmp)->size < CHAR_TABLE_STANDARD_SLOTS)
+             if (XVECTOR_SIZE (tmp) < CHAR_TABLE_STANDARD_SLOTS)
                error ("Invalid size char-table");
              XSETPVECTYPE (XVECTOR (tmp), PVEC_CHAR_TABLE);
              return tmp;
@@ -2446,7 +2452,7 @@ read1 (readcharfun, pch, first_in_list)
                  depth = XINT (AREF (tmp, 0));
                  if (depth < 1 || depth > 3)
                    error ("Invalid depth in char-table");
-                 size = XVECTOR (tmp)->size - 2;
+                 size = XVECTOR_SIZE (tmp) - 2;
                  if (chartab_size [depth] != size)
                    error ("Invalid size char-table");
                  XSETPVECTYPE (XVECTOR (tmp), PVEC_SUB_CHAR_TABLE);
@@ -2497,7 +2503,7 @@ read1 (readcharfun, pch, first_in_list)
             build them using function calls.  */
          Lisp_Object tmp;
          tmp = read_vector (readcharfun, 1);
-         return Fmake_byte_code (XVECTOR (tmp)->size,
+         return Fmake_byte_code (XVECTOR_SIZE (tmp),
                                  XVECTOR (tmp)->contents);
        }
       if (c == '(')
@@ -3326,7 +3332,7 @@ read_vector (readcharfun, bytecodeflag)
   len = Flength (tem);
   vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil));
 
-  size = XVECTOR (vector)->size;
+  size = XVECTOR_SIZE (vector);
   ptr = XVECTOR (vector)->contents;
   for (i = 0; i < size; i++)
     {
@@ -3595,7 +3601,7 @@ Lisp_Object
 check_obarray (obarray)
      Lisp_Object obarray;
 {
-  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || XVECTOR_SIZE (obarray) == 0)
     {
       /* If Vobarray is now invalid, force it to be valid.  */
       if (EQ (Vobarray, obarray)) Vobarray = initial_obarray;
@@ -3616,7 +3622,7 @@ intern (str)
   Lisp_Object obarray;
 
   obarray = Vobarray;
-  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || XVECTOR_SIZE (obarray) == 0)
     obarray = check_obarray (obarray);
   tem = oblookup (obarray, str, len, len);
   if (SYMBOLP (tem))
@@ -3632,7 +3638,7 @@ intern_c_string (const char *str)
   Lisp_Object obarray;
 
   obarray = Vobarray;
-  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || XVECTOR_SIZE (obarray) == 0)
     obarray = check_obarray (obarray);
   tem = oblookup (obarray, str, len, len);
   if (SYMBOLP (tem))
@@ -3825,10 +3831,10 @@ oblookup (obarray, ptr, size, size_byte)
   Lisp_Object bucket, tem;
 
   if (!VECTORP (obarray)
-      || (obsize = XVECTOR (obarray)->size) == 0)
+      || (obsize = XVECTOR_SIZE (obarray)) == 0)
     {
       obarray = check_obarray (obarray);
-      obsize = XVECTOR (obarray)->size;
+      obsize = XVECTOR_SIZE (obarray);
     }
   /* This is sometimes needed in the middle of GC.  */
   obsize &= ~ARRAY_MARK_FLAG;
@@ -3881,7 +3887,7 @@ map_obarray (obarray, fn, arg)
   register int i;
   register Lisp_Object tail;
   CHECK_VECTOR (obarray);
-  for (i = XVECTOR (obarray)->size - 1; i >= 0; i--)
+  for (i = XVECTOR_SIZE (obarray) - 1; i >= 0; i--)
     {
       tail = XVECTOR (obarray)->contents[i];
       if (SYMBOLP (tail))
@@ -3968,7 +3974,7 @@ defsubr (sname)
 {
   Lisp_Object sym;
   sym = intern_c_string (sname->symbol_name);
-  XSETPVECTYPE (sname, PVEC_SUBR);
+  XSETTYPED_PVECTYPE (sname, size, PVEC_SUBR);
   XSETSUBR (XSYMBOL (sym)->function, sname);
 }
 
@@ -4377,20 +4383,20 @@ the rest of the FORMS.  */);
   Vafter_load_alist = Qnil;
 
   DEFVAR_LISP ("load-history", &Vload_history,
-              doc: /* Alist mapping file names to symbols and features.
-Each alist element is a list that starts with a file name,
-except for one element (optional) that starts with nil and describes
-definitions evaluated from buffers not visiting files.
-
-The file name is absolute and is the true file name (i.e. it doesn't
-contain symbolic links) of the loaded file.
-
-The remaining elements of each list are symbols defined as variables
-and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)',
-`(defun . FUNCTION)', `(autoload . SYMBOL)', `(defface . SYMBOL)'
-and `(t . SYMBOL)'.  An element `(t . SYMBOL)' precedes an entry
-`(defun . FUNCTION)', and means that SYMBOL was an autoload before
-this file redefined it as a function.
+              doc: /* Alist mapping loaded file names to symbols and features.
+Each alist element should be a list (FILE-NAME ENTRIES...), where
+FILE-NAME is the name of a file that has been loaded into Emacs.
+The file name is absolute and true (i.e. it doesn't contain symlinks).
+As an exception, one of the alist elements may have FILE-NAME nil,
+for symbols and features not associated with any file.
+
+The remaining ENTRIES in the alist element describe the functions and
+variables defined in that file, the features provided, and the
+features required.  Each entry has the form `(provide . FEATURE)',
+`(require . FEATURE)', `(defun . FUNCTION)', `(autoload . SYMBOL)',
+`(defface . SYMBOL)', or `(t . SYMBOL)'.  In addition, an entry `(t
+. SYMBOL)' may precede an entry `(defun . FUNCTION)', and means that
+SYMBOL was an autoload before this file redefined it as a function.
 
 During preloading, the file name recorded is relative to the main Lisp
 directory.  These file names are converted to absolute at startup.  */);