#include <sys/file.h>
#include <errno.h>
#include <limits.h> /* For CHAR_BIT. */
-#include <setjmp.h>
#include <stat-time.h>
#include "lisp.h"
#include "intervals.h"
#endif
#include <unistd.h>
-#include <math.h>
#ifdef HAVE_SETLOCALE
#include <locale.h>
Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
static Lisp_Object Qinhibit_file_name_operation;
static Lisp_Object Qeval_buffer_list;
-static Lisp_Object Qlexical_binding;
+Lisp_Object Qlexical_binding;
static Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */
/* Used instead of Qget_file_char while loading *.elc files compiled
static Lisp_Object Qload_force_doc_strings;
-extern Lisp_Object Qinternal_interpreter_environment;
-
static Lisp_Object Qload_in_progress;
/* The association list of objects read with the #n=object form.
static int unread_char;
static int
-readchar (Lisp_Object readcharfun, int *multibyte)
+readchar (Lisp_Object readcharfun, bool *multibyte)
{
Lisp_Object tem;
register int c;
{
if (load_each_byte)
{
- BLOCK_INPUT;
+ block_input ();
ungetc (c, instream);
- UNBLOCK_INPUT;
+ unblock_input ();
}
else
unread_char = c;
{
if (c >= 0)
{
- BLOCK_INPUT;
+ block_input ();
ungetc (c, instream);
- UNBLOCK_INPUT;
+ unblock_input ();
return 0;
}
- BLOCK_INPUT;
+ block_input ();
c = getc (instream);
#ifdef EINTR
/* Interrupted reads have been observed while reading over the network. */
while (c == EOF && ferror (instream) && errno == EINTR)
{
- UNBLOCK_INPUT;
+ unblock_input ();
QUIT;
- BLOCK_INPUT;
+ block_input ();
clearerr (instream);
c = getc (instream);
}
#endif
- UNBLOCK_INPUT;
+ unblock_input ();
return (c == EOF ? -1 : c);
}
(void)
{
register Lisp_Object val;
- BLOCK_INPUT;
+ block_input ();
XSETINT (val, getc (instream));
- UNBLOCK_INPUT;
+ unblock_input ();
return val;
}
/* Return true if the lisp code read using READCHARFUN defines a non-nil
`lexical-binding' file variable. After returning, the stream is
- positioned following the first line, if it is a comment, otherwise
- nothing is read. */
+ positioned following the first line, if it is a comment or #! line,
+ otherwise nothing is read. */
static int
lisp_file_lexically_bound_p (Lisp_Object readcharfun)
{
int ch = READCHAR;
+
+ if (ch == '#')
+ {
+ ch = READCHAR;
+ if (ch != '!')
+ {
+ UNREAD (ch);
+ UNREAD ('#');
+ return 0;
+ }
+ while (ch != '\n' && ch != EOF)
+ ch = READCHAR;
+ if (ch == '\n') ch = READCHAR;
+ /* It is OK to leave the position after a #! line, since
+ that is what read1 does. */
+ }
+
if (ch != ';')
/* The first line isn't a comment, just give up. */
{
FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer;
if (stream != NULL)
{
- BLOCK_INPUT;
+ block_input ();
fclose (stream);
- UNBLOCK_INPUT;
+ unblock_input ();
}
return Qnil;
}
int whole_buffer = 0;
/* 1 on the first time around. */
int first_sexp = 1;
+ Lisp_Object macroexpand = intern ("internal-macroexpand-for-load");
+
+ if (NILP (Ffboundp (macroexpand))
+ /* Don't macroexpand in .elc files, since it should have been done
+ already. We actually don't know whether we're in a .elc file or not,
+ so we use circumstantial evidence: .el files normally go through
+ Vload_source_file_function -> load-with-code-conversion
+ -> eval-buffer. */
+ || EQ (readcharfun, Qget_file_char)
+ || EQ (readcharfun, Qget_emacs_mule_file_char))
+ macroexpand = Qnil;
if (MARKERP (readcharfun))
{
/* We assume START is nil when input is not from a buffer. */
if (! NILP (start) && !b)
- abort ();
+ emacs_abort ();
specbind (Qstandard_input, readcharfun); /* GCPROs readcharfun. */
specbind (Qcurrent_load_list, Qnil);
{
ptrdiff_t count1 = SPECPDL_INDEX ();
- if (b != 0 && NILP (BVAR (b, name)))
+ if (b != 0 && !BUFFER_LIVE_P (b))
error ("Reading from killed buffer");
if (!NILP (start))
unbind_to (count1, Qnil);
/* Now eval what we just read. */
+ if (!NILP (macroexpand))
+ val = call1 (macroexpand, val);
val = eval_sub (val);
if (printflag)
/* Return the digit that CHARACTER stands for in the given BASE.
Return -1 if CHARACTER is out of range for BASE,
and -2 if CHARACTER is not valid for any supported BASE. */
-static inline int
+static int
digit_to_number (int character, int base)
{
int digit;
static Lisp_Object
read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
{
- register int c;
- unsigned uninterned_symbol = 0;
- int multibyte;
+ int c;
+ bool uninterned_symbol = 0;
+ bool multibyte;
*pch = 0;
load_each_byte = 0;
/* Check for text properties in each interval.
substitute_in_interval contains part of the logic. */
- INTERVAL root_interval = STRING_INTERVALS (subtree);
- Lisp_Object arg = Fcons (object, placeholder);
+ INTERVAL root_interval = string_intervals (subtree);
+ Lisp_Object arg = Fcons (object, placeholder);
traverse_intervals_noorder (root_interval,
&substitute_in_interval, arg);
Lisp_Object object = Fcar (arg);
Lisp_Object placeholder = Fcdr (arg);
- SUBSTITUTE (interval->plist, interval->plist = true_value);
+ SUBSTITUTE (interval->plist, set_interval_plist (interval, true_value));
}
\f
/* Delay handling the bytecode slot until we know whether
it is lazily-loaded (we can tell by whether the
constants slot is nil). */
- ptr[COMPILED_CONSTANTS] = item;
+ ASET (vector, COMPILED_CONSTANTS, item);
item = Qnil;
}
else if (i == COMPILED_CONSTANTS)
}
/* Now handle the bytecode slot. */
- ptr[COMPILED_BYTECODE] = bytestr;
+ ASET (vector, COMPILED_BYTECODE, bytestr);
}
else if (i == COMPILED_DOC_STRING
&& STRINGP (item)
item = Fstring_as_multibyte (item);
}
}
- ptr[i] = item;
+ ASET (vector, i, item);
otem = XCONS (tem);
tem = Fcdr (tem);
free_cons (otem);
/* Creating a non-pure string from a string literal not
implemented yet. We could just use make_string here and live
with the extra copy. */
- abort ();
+ emacs_abort ();
return Fintern (make_pure_c_string (str, len), obarray);
}
ptr = aref_addr (obarray, XINT(tem));
if (SYMBOLP (*ptr))
- XSYMBOL (sym)->next = XSYMBOL (*ptr);
+ set_symbol_next (sym, XSYMBOL (*ptr));
else
- XSYMBOL (sym)->next = 0;
+ set_symbol_next (sym, NULL);
*ptr = sym;
return sym;
}
XSETSYMBOL (following, XSYMBOL (tail)->next);
if (EQ (following, tem))
{
- XSYMBOL (tail)->next = XSYMBOL (following)->next;
+ set_symbol_next (tail, XSYMBOL (following)->next);
break;
}
}
/* Fmake_symbol inits fields of new symbols with Qunbound and Qnil,
so those two need to be fixed manually. */
SET_SYMBOL_VAL (XSYMBOL (Qunbound), Qunbound);
- SVAR (XSYMBOL (Qunbound), function) = Qunbound;
- SVAR (XSYMBOL (Qunbound), plist) = Qnil;
- /* XSYMBOL (Qnil)->function = Qunbound; */
+ set_symbol_function (Qunbound, Qunbound);
+ set_symbol_plist (Qunbound, Qnil);
SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil);
XSYMBOL (Qnil)->constant = 1;
XSYMBOL (Qnil)->declared_special = 1;
- SVAR (XSYMBOL (Qnil), plist) = Qnil;
+ set_symbol_plist (Qnil, Qnil);
Qt = intern_c_string ("t");
SET_SYMBOL_VAL (XSYMBOL (Qt), Qt);
void
defsubr (struct Lisp_Subr *sname)
{
- Lisp_Object sym;
+ Lisp_Object sym, tem;
sym = intern_c_string (sname->symbol_name);
XSETTYPED_PVECTYPE (sname, size, PVEC_SUBR);
- XSETSUBR (SVAR (XSYMBOL (sym), function), sname);
+ XSETSUBR (tem, sname);
+ set_symbol_function (sym, tem);
}
#ifdef NOTDEF /* Use fset in subr.el now! */
nil if address contains 0. */
void
defvar_bool (struct Lisp_Boolfwd *b_fwd,
- const char *namestring, int *address)
+ const char *namestring, bool *address)
{
Lisp_Object sym;
sym = intern_c_string (namestring);
{
tem = Fexpand_file_name (build_string ("site-lisp"),
Vsource_directory);
-
- if (NILP (Fmember (tem, Vload_path)))
- Vload_path = Fcons (tem, Vload_path);
+ tem1 = Ffile_exists_p (tem);
+ if (!NILP (tem1))
+ {
+ if (NILP (Fmember (tem, Vload_path)))
+ Vload_path = Fcons (tem, Vload_path);
+ }
}
}
} /* Vinstallation_directory != Vsource_directory */
Vbytecomp_version_regexp
= build_pure_c_string ("^;;;.\\(in Emacs version\\|bytecomp version FSF\\)");
- Qlexical_binding = intern ("lexical-binding");
- staticpro (&Qlexical_binding);
+ DEFSYM (Qlexical_binding, "lexical-binding");
DEFVAR_LISP ("lexical-binding", Vlexical_binding,
doc: /* Whether to use lexical binding when evaluating code.
Non-nil means that the code in the current buffer should be evaluated
This variable is automatically set from the file variables of an
interpreted Lisp file read using `load'. Unlike other file local
variables, this must be set in the first line of a file. */);
+ Vlexical_binding = Qnil;
Fmake_variable_buffer_local (Qlexical_binding);
DEFVAR_LISP ("eval-buffer-list", Veval_buffer_list,