aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c173
1 files changed, 52 insertions, 121 deletions
diff --git a/src/lread.c b/src/lread.c
index 550b5f076f..c4ae831352 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1,8 +1,6 @@
/* 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, 2010 Free Software Foundation, Inc.
+Copyright (C) 1985-1989, 1993-1995, 1997-2011 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -45,10 +43,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "msdos.h"
#endif
-#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#endif
-
#include <math.h>
#ifdef HAVE_SETLOCALE
@@ -73,11 +68,11 @@ Lisp_Object Qrehash_size;
Lisp_Object Qrehash_threshold;
Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
-Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
+Lisp_Object Qvariable_documentation;
Lisp_Object Qascii_character, Qload, Qload_file_name;
Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
Lisp_Object Qinhibit_file_name_operation;
-Lisp_Object Qeval_buffer_list, Veval_buffer_list;
+Lisp_Object Qeval_buffer_list;
Lisp_Object Qlexical_binding;
Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */
@@ -89,69 +84,19 @@ static Lisp_Object Qload_force_doc_strings;
extern Lisp_Object Qinternal_interpreter_environment;
-/* non-zero if inside `load' */
-int load_in_progress;
static Lisp_Object Qload_in_progress;
-/* Directory in which the sources were found. */
-Lisp_Object Vsource_directory;
-
-/* Search path and suffixes for files to be loaded. */
-Lisp_Object Vload_path, Vload_suffixes, Vload_file_rep_suffixes;
-
-/* File name of user's init file. */
-Lisp_Object Vuser_init_file;
-
-/* This is the user-visible association list that maps features to
- lists of defs in their load files. */
-Lisp_Object Vload_history;
-
-/* This is used to build the load history. */
-Lisp_Object Vcurrent_load_list;
-
-/* List of files that were preloaded. */
-Lisp_Object Vpreloaded_file_list;
-
-/* Name of file actually being read by `load'. */
-Lisp_Object Vload_file_name;
-
-/* Function to use for reading, in `load' and friends. */
-Lisp_Object Vload_read_function;
-
-/* Non-nil means read recursive structures using #n= and #n# syntax. */
-Lisp_Object Vread_circle;
-
/* The association list of objects read with the #n=object form.
Each member of the list has the form (n . object), and is used to
look up the object for the corresponding #n# construct.
It must be set to nil before all top-level calls to read0. */
Lisp_Object read_objects;
-/* Nonzero means load should forcibly load all dynamic doc strings. */
-static int load_force_doc_strings;
-
-/* Nonzero means read should convert strings to unibyte. */
-static int load_convert_to_unibyte;
-
/* Nonzero means READCHAR should read bytes one by one (not character)
when READCHARFUN is Qget_file_char or Qget_emacs_mule_file_char.
This is set to 1 by read1 temporarily while handling #@NUMBER. */
static int load_each_byte;
-/* Function to use for loading an Emacs Lisp source file (not
- compiled) instead of readevalloop. */
-Lisp_Object Vload_source_file_function;
-
-/* List of all DEFVAR_BOOL variables. Used by the byte optimizer. */
-Lisp_Object Vbyte_boolean_vars;
-
-/* Whether or not to add a `read-positions' property to symbols
- read. */
-Lisp_Object Vread_with_symbol_positions;
-
-/* List of (SYMBOL . POSITION) accumulated so far. */
-Lisp_Object Vread_symbol_positions_list;
-
/* If non-nil `readevalloop' evaluates code in a lexical environment. */
Lisp_Object Vlexical_binding;
@@ -198,25 +143,13 @@ static file_offset prev_saved_doc_string_position;
Fread initializes this to zero, so we need not specbind it
or worry about what happens to it when there is an error. */
static int new_backquote_flag;
-static Lisp_Object Vold_style_backquotes, Qold_style_backquotes;
+static Lisp_Object Qold_style_backquotes;
/* A list of file names for files being loaded in Fload. Used to
check for recursive loads. */
static Lisp_Object Vloads_in_progress;
-/* Non-zero means load dangerous compiled Lisp files. */
-
-int load_dangerous_libraries;
-
-/* Non-zero means force printing messages when loading Lisp files. */
-
-int force_load_messages;
-
-/* A regular expression used to detect files compiled with Emacs. */
-
-static Lisp_Object Vbytecomp_version_regexp;
-
static int read_emacs_mule_char (int, int (*) (int, Lisp_Object),
Lisp_Object);
@@ -655,7 +588,7 @@ static void substitute_in_interval (INTERVAL, Lisp_Object);
If SECONDS is a number, we wait that many seconds for input, and
return Qnil if no input arrives within that time. */
-Lisp_Object
+static Lisp_Object
read_filtered_event (int no_switch_frame, int ascii_required,
int error_nonascii, int input_method, Lisp_Object seconds)
{
@@ -1146,10 +1079,10 @@ Return t if the file exists and loads successfully. */)
{
/* Don't insist on adding a suffix if FILE already ends with one. */
if (size > 3
- && !strcmp (SDATA (file) + size - 3, ".el"))
+ && !strcmp (SSDATA (file) + size - 3, ".el"))
must_suffix = Qnil;
else if (size > 4
- && !strcmp (SDATA (file) + size - 4, ".elc"))
+ && !strcmp (SSDATA (file) + size - 4, ".elc"))
must_suffix = Qnil;
/* Don't insist on adding a suffix
if the argument includes a directory name. */
@@ -1269,9 +1202,9 @@ Return t if the file exists and loads successfully. */)
#ifdef DOS_NT
fmode = "rb";
#endif /* DOS_NT */
- stat ((char *)SDATA (efound), &s1);
+ stat (SSDATA (efound), &s1);
SSET (efound, SBYTES (efound) - 1, 0);
- result = stat ((char *)SDATA (efound), &s2);
+ result = stat (SSDATA (efound), &s2);
SSET (efound, SBYTES (efound) - 1, 'c');
if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
@@ -1312,7 +1245,7 @@ Return t if the file exists and loads successfully. */)
#ifdef WINDOWSNT
emacs_close (fd);
efound = ENCODE_FILE (found);
- stream = fopen ((char *) SDATA (efound), fmode);
+ stream = fopen (SSDATA (efound), fmode);
#else /* not WINDOWSNT */
stream = fdopen (fd, fmode);
#endif /* not WINDOWSNT */
@@ -1543,19 +1476,19 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
&& SREF (filename, 0) == '/'
&& SREF (filename, 1) == ':')
{
- strncpy (fn, SDATA (filename) + 2,
+ strncpy (fn, SSDATA (filename) + 2,
SBYTES (filename) - 2);
fn[SBYTES (filename) - 2] = 0;
}
else
{
- strncpy (fn, SDATA (filename),
+ strncpy (fn, SSDATA (filename),
SBYTES (filename));
fn[SBYTES (filename)] = 0;
}
if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */
- strncat (fn, SDATA (XCAR (tail)), lsuffix);
+ strncat (fn, SSDATA (XCAR (tail)), lsuffix);
/* Check that the file exists and is not a directory. */
/* We used to only check for handlers on non-absolute file names:
@@ -1590,7 +1523,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
const char *pfn;
encoded_fn = ENCODE_FILE (string);
- pfn = SDATA (encoded_fn);
+ pfn = SSDATA (encoded_fn);
exists = (stat (pfn, &st) >= 0
&& (st.st_mode & S_IFMT) != S_IFDIR);
if (exists)
@@ -3021,10 +2954,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
{
char *end = read_buffer + read_buffer_size;
- while (c > 040
- && c != 0x8a0 /* NBSP */
- && (c >= 0200
- || !(strchr ("\"';()[]#`,", c))))
+ do
{
if (end - p < MAX_MULTIBYTE_LENGTH)
{
@@ -3048,7 +2978,10 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
else
*p++ = c;
c = READCHAR;
- }
+ } while (c > 040
+ && c != 0x8a0 /* NBSP */
+ && (c >= 0200
+ || !(strchr ("\"';()[]#`,", c))));
if (p == end)
{
@@ -3657,7 +3590,6 @@ read_list (int flag, register Lisp_Object readcharfun)
}
}
-Lisp_Object Vobarray;
Lisp_Object initial_obarray;
/* oblookup stores the bucket number here, for the sake of Funintern. */
@@ -3749,7 +3681,7 @@ it defaults to the value of `obarray'. */)
CHECK_STRING (string);
- tem = oblookup (obarray, SDATA (string),
+ tem = oblookup (obarray, SSDATA (string),
SCHARS (string),
SBYTES (string));
if (!INTEGERP (tem))
@@ -3802,7 +3734,7 @@ it defaults to the value of `obarray'. */)
else
string = SYMBOL_NAME (name);
- tem = oblookup (obarray, SDATA (string), SCHARS (string), SBYTES (string));
+ tem = oblookup (obarray, SSDATA (string), SCHARS (string), SBYTES (string));
if (INTEGERP (tem) || (SYMBOLP (name) && !EQ (name, tem)))
return Qnil;
else
@@ -3831,7 +3763,7 @@ OBARRAY defaults to the value of the variable `obarray'. */)
string = name;
}
- tem = oblookup (obarray, SDATA (string),
+ tem = oblookup (obarray, SSDATA (string),
SCHARS (string),
SBYTES (string));
if (INTEGERP (tem))
@@ -4245,7 +4177,7 @@ init_lread (void)
Vload_path = Fcons (tem, Vload_path);
}
}
- if (!NILP (sitelisp))
+ if (!NILP (sitelisp) && !no_site_lisp)
Vload_path = nconc2 (Fnreverse (sitelisp), Vload_path);
}
}
@@ -4282,7 +4214,7 @@ init_lread (void)
if (STRINGP (dirfile))
{
dirfile = Fdirectory_file_name (dirfile);
- if (access (SDATA (dirfile), 0) < 0)
+ if (access (SSDATA (dirfile), 0) < 0)
dir_warning ("Warning: Lisp directory `%s' does not exist.\n",
XCAR (path_tail));
}
@@ -4344,22 +4276,22 @@ syms_of_lread (void)
defsubr (&Smapatoms);
defsubr (&Slocate_file_internal);
- DEFVAR_LISP ("obarray", &Vobarray,
+ DEFVAR_LISP ("obarray", Vobarray,
doc: /* Symbol table for use by `intern' and `read'.
It is a vector whose length ought to be prime for best results.
The vector's contents don't make sense if examined from Lisp programs;
to find all the symbols in an obarray, use `mapatoms'. */);
- DEFVAR_LISP ("values", &Vvalues,
+ DEFVAR_LISP ("values", Vvalues,
doc: /* List of values of all expressions which were read, evaluated and printed.
Order is reverse chronological. */);
- DEFVAR_LISP ("standard-input", &Vstandard_input,
+ DEFVAR_LISP ("standard-input", Vstandard_input,
doc: /* Stream for read to get input from.
See documentation of `read' for possible values. */);
Vstandard_input = Qt;
- DEFVAR_LISP ("read-with-symbol-positions", &Vread_with_symbol_positions,
+ DEFVAR_LISP ("read-with-symbol-positions", Vread_with_symbol_positions,
doc: /* If non-nil, add position of read symbols to `read-symbol-positions-list'.
If this variable is a buffer, then only forms read from that buffer
@@ -4373,7 +4305,7 @@ The positions are relative to the last call to `read' or
the toplevel; bind it instead. */);
Vread_with_symbol_positions = Qnil;
- DEFVAR_LISP ("read-symbol-positions-list", &Vread_symbol_positions_list,
+ DEFVAR_LISP ("read-symbol-positions-list", Vread_symbol_positions_list,
doc: /* A list mapping read symbols to their positions.
This variable is modified during calls to `read' or
`read-from-string', but only when `read-with-symbol-positions' is
@@ -4388,24 +4320,24 @@ read multiple times. The list is in the same order as the symbols
were read in. */);
Vread_symbol_positions_list = Qnil;
- DEFVAR_LISP ("read-circle", &Vread_circle,
+ DEFVAR_LISP ("read-circle", Vread_circle,
doc: /* Non-nil means read recursive structures using #N= and #N# syntax. */);
Vread_circle = Qt;
- DEFVAR_LISP ("load-path", &Vload_path,
+ DEFVAR_LISP ("load-path", Vload_path,
doc: /* *List of directories to search for files to load.
Each element is a string (directory name) or nil (try default directory).
Initialized based on EMACSLOADPATH environment variable, if any,
otherwise to default specified by file `epaths.h' when Emacs was built. */);
- DEFVAR_LISP ("load-suffixes", &Vload_suffixes,
+ DEFVAR_LISP ("load-suffixes", Vload_suffixes,
doc: /* List of suffixes for (compiled or source) Emacs Lisp files.
This list should not include the empty string.
`load' and related functions try to append these suffixes, in order,
to the specified file name if a Lisp suffix is allowed or required. */);
Vload_suffixes = Fcons (make_pure_c_string (".elc"),
Fcons (make_pure_c_string (".el"), Qnil));
- DEFVAR_LISP ("load-file-rep-suffixes", &Vload_file_rep_suffixes,
+ DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes,
doc: /* List of suffixes that indicate representations of \
the same file.
This list should normally start with the empty string.
@@ -4420,12 +4352,12 @@ the loading functions recognize as compression suffixes, you should
customize `jka-compr-load-suffixes' rather than the present variable. */);
Vload_file_rep_suffixes = Fcons (empty_unibyte_string, Qnil);
- DEFVAR_BOOL ("load-in-progress", &load_in_progress,
+ DEFVAR_BOOL ("load-in-progress", load_in_progress,
doc: /* Non-nil if inside of `load'. */);
Qload_in_progress = intern_c_string ("load-in-progress");
staticpro (&Qload_in_progress);
- DEFVAR_LISP ("after-load-alist", &Vafter_load_alist,
+ DEFVAR_LISP ("after-load-alist", Vafter_load_alist,
doc: /* An alist of expressions to be evalled when particular files are loaded.
Each element looks like (REGEXP-OR-FEATURE FORMS...).
@@ -4440,7 +4372,7 @@ An error in FORMS does not undo the load, but does prevent execution of
the rest of the FORMS. */);
Vafter_load_alist = Qnil;
- DEFVAR_LISP ("load-history", &Vload_history,
+ DEFVAR_LISP ("load-history", Vload_history,
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.
@@ -4460,11 +4392,11 @@ During preloading, the file name recorded is relative to the main Lisp
directory. These file names are converted to absolute at startup. */);
Vload_history = Qnil;
- DEFVAR_LISP ("load-file-name", &Vload_file_name,
+ DEFVAR_LISP ("load-file-name", Vload_file_name,
doc: /* Full name of file being loaded by `load'. */);
Vload_file_name = Qnil;
- DEFVAR_LISP ("user-init-file", &Vuser_init_file,
+ DEFVAR_LISP ("user-init-file", Vuser_init_file,
doc: /* File name, including directory, of user's initialization file.
If the file loaded had extension `.elc', and the corresponding source file
exists, this variable contains the name of source file, suitable for use
@@ -4473,16 +4405,16 @@ While Emacs loads and evaluates the init file, value is the real name
of the file, regardless of whether or not it has the `.elc' extension. */);
Vuser_init_file = Qnil;
- DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
+ DEFVAR_LISP ("current-load-list", Vcurrent_load_list,
doc: /* Used for internal purposes by `load'. */);
Vcurrent_load_list = Qnil;
- DEFVAR_LISP ("load-read-function", &Vload_read_function,
+ DEFVAR_LISP ("load-read-function", Vload_read_function,
doc: /* Function used by `load' and `eval-region' for reading expressions.
The default is nil, which means use the function `read'. */);
Vload_read_function = Qnil;
- DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function,
+ DEFVAR_LISP ("load-source-file-function", Vload_source_file_function,
doc: /* Function called in `load' for loading an Emacs Lisp source file.
This function is for doing code conversion before reading the source file.
If nil, loading is done without any code conversion.
@@ -4491,45 +4423,45 @@ Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where
See `load' for the meaning of the remaining arguments. */);
Vload_source_file_function = Qnil;
- DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings,
+ DEFVAR_BOOL ("load-force-doc-strings", load_force_doc_strings,
doc: /* Non-nil means `load' should force-load all dynamic doc strings.
This is useful when the file being loaded is a temporary copy. */);
load_force_doc_strings = 0;
- DEFVAR_BOOL ("load-convert-to-unibyte", &load_convert_to_unibyte,
+ DEFVAR_BOOL ("load-convert-to-unibyte", load_convert_to_unibyte,
doc: /* Non-nil means `read' converts strings to unibyte whenever possible.
This is normally bound by `load' and `eval-buffer' to control `read',
and is not meant for users to change. */);
load_convert_to_unibyte = 0;
- DEFVAR_LISP ("source-directory", &Vsource_directory,
+ DEFVAR_LISP ("source-directory", Vsource_directory,
doc: /* Directory in which Emacs sources were found when Emacs was built.
You cannot count on them to still be there! */);
Vsource_directory
= Fexpand_file_name (build_string ("../"),
Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH)));
- DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list,
+ DEFVAR_LISP ("preloaded-file-list", Vpreloaded_file_list,
doc: /* List of files that were preloaded (when dumping Emacs). */);
Vpreloaded_file_list = Qnil;
- DEFVAR_LISP ("byte-boolean-vars", &Vbyte_boolean_vars,
+ DEFVAR_LISP ("byte-boolean-vars", Vbyte_boolean_vars,
doc: /* List of all DEFVAR_BOOL variables, used by the byte code optimizer. */);
Vbyte_boolean_vars = Qnil;
- DEFVAR_BOOL ("load-dangerous-libraries", &load_dangerous_libraries,
+ DEFVAR_BOOL ("load-dangerous-libraries", load_dangerous_libraries,
doc: /* Non-nil means load dangerous compiled Lisp files.
Some versions of XEmacs use different byte codes than Emacs. These
incompatible byte codes can make Emacs crash when it tries to execute
them. */);
load_dangerous_libraries = 0;
- DEFVAR_BOOL ("force-load-messages", &force_load_messages,
+ DEFVAR_BOOL ("force-load-messages", force_load_messages,
doc: /* Non-nil means force printing messages when loading Lisp files.
This overrides the value of the NOMESSAGE argument to `load'. */);
force_load_messages = 0;
- DEFVAR_LISP ("bytecomp-version-regexp", &Vbytecomp_version_regexp,
+ DEFVAR_LISP ("bytecomp-version-regexp", Vbytecomp_version_regexp,
doc: /* Regular expression matching safe to load compiled Lisp files.
When Emacs loads a compiled Lisp file, it reads the first 512 bytes
from the file, and matches them against this regular expression.
@@ -4540,18 +4472,18 @@ to load. See also `load-dangerous-libraries'. */);
Qlexical_binding = intern ("lexical-binding");
staticpro (&Qlexical_binding);
- DEFVAR_LISP ("lexical-binding", &Vlexical_binding,
+ DEFVAR_LISP ("lexical-binding", Vlexical_binding,
doc: /* If non-nil, use lexical binding when evaluating code.
This only applies to code evaluated by `eval-buffer' and `eval-region'.
This variable is automatically set from the file variables of an interpreted
lisp file read using `load'. */);
Fmake_variable_buffer_local (Qlexical_binding);
- DEFVAR_LISP ("eval-buffer-list", &Veval_buffer_list,
+ DEFVAR_LISP ("eval-buffer-list", Veval_buffer_list,
doc: /* List of buffers being read from by calls to `eval-buffer' and `eval-region'. */);
Veval_buffer_list = Qnil;
- DEFVAR_LISP ("old-style-backquotes", &Vold_style_backquotes,
+ DEFVAR_LISP ("old-style-backquotes", Vold_style_backquotes,
doc: /* Set to non-nil when `read' encounters an old-style backquote. */);
Vold_style_backquotes = Qnil;
Qold_style_backquotes = intern_c_string ("old-style-backquotes");
@@ -4638,4 +4570,3 @@ This variable is automatically set from the file variables of an interpreted
Qrehash_threshold = intern_c_string ("rehash-threshold");
staticpro (&Qrehash_threshold);
}
-