Make Emacs functions such as Fatom 'static' by default.
[bpt/emacs.git] / src / lread.c
index 7a8d7cf..7d12f5a 100644 (file)
@@ -681,7 +681,7 @@ read_filtered_event (int no_switch_frame, int ascii_required,
   return val;
 }
 
-DEFUN ("read-char", Fread_char, Sread_char, 0, 3, 0,
+DEFUE ("read-char", Fread_char, Sread_char, 0, 3, 0,
        doc: /* Read a character from the command input (keyboard or macro).
 It is returned as a number.
 If the character has modifiers, they are resolved and reflected to the
@@ -714,7 +714,7 @@ floating-point value.  */)
          : make_number (char_resolve_modifier_mask (XINT (val))));
 }
 
-DEFUN ("read-event", Fread_event, Sread_event, 0, 3, 0,
+DEFUE ("read-event", Fread_event, Sread_event, 0, 3, 0,
        doc: /* Read an event object from the input stream.
 If the optional argument PROMPT is non-nil, display that as a prompt.
 If the optional argument INHERIT-INPUT-METHOD is non-nil and some
@@ -796,16 +796,16 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun)
       } beg_end_state = NOMINAL;
       int in_file_vars = 0;
 
-#define UPDATE_BEG_END_STATE(ch)                                             \
-  if (beg_end_state == NOMINAL)                                                      \
-    beg_end_state = (ch == '-' ? AFTER_FIRST_DASH : NOMINAL);                \
-  else if (beg_end_state == AFTER_FIRST_DASH)                                \
-    beg_end_state = (ch == '*' ? AFTER_ASTERIX : NOMINAL);                   \
-  else if (beg_end_state == AFTER_ASTERIX)                                   \
-    {                                                                        \
-      if (ch == '-')                                                         \
-       in_file_vars = !in_file_vars;                                         \
-      beg_end_state = NOMINAL;                                               \
+#define UPDATE_BEG_END_STATE(ch)                               \
+  if (beg_end_state == NOMINAL)                                        \
+    beg_end_state = (ch == '-' ? AFTER_FIRST_DASH : NOMINAL);  \
+  else if (beg_end_state == AFTER_FIRST_DASH)                  \
+    beg_end_state = (ch == '*' ? AFTER_ASTERIX : NOMINAL);     \
+  else if (beg_end_state == AFTER_ASTERIX)                     \
+    {                                                          \
+      if (ch == '-')                                           \
+       in_file_vars = !in_file_vars;                           \
+      beg_end_state = NOMINAL;                                 \
     }
 
       /* Skip until we get to the file vars, if any.  */
@@ -818,7 +818,8 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun)
 
       while (in_file_vars)
        {
-         char var[100], *var_end, val[100], *val_end;
+         char var[100], val[100];
+         unsigned i;
 
          ch = READCHAR;
 
@@ -826,19 +827,18 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun)
          while (ch == ' ' || ch == '\t')
            ch = READCHAR;
 
-         var_end = var;
+         i = 0;
          while (ch != ':' && ch != '\n' && ch != EOF)
            {
-             if (var_end < var + sizeof var - 1)
-               *var_end++ = ch;
+             if (i < sizeof var - 1)
+               var[i++] = ch;
              UPDATE_BEG_END_STATE (ch);
              ch = READCHAR;
            }
-         
-         while (var_end > var
-                && (var_end[-1] == ' ' || var_end[-1] == '\t'))
-           var_end--;
-         *var_end = '\0';
+
+         while (i > 0 && (var[i - 1] == ' ' || var[i - 1] == '\t'))
+           i--;
+         var[i] = '\0';
 
          if (ch == ':')
            {
@@ -848,22 +848,21 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun)
              while (ch == ' ' || ch == '\t')
                ch = READCHAR;
 
-             val_end = val;
+             i = 0;
              while (ch != ';' && ch != '\n' && ch != EOF && in_file_vars)
                {
-                 if (val_end < val + sizeof val - 1)
-                   *val_end++ = ch;
+                 if (i < sizeof val - 1)
+                   val[i++] = ch;
                  UPDATE_BEG_END_STATE (ch);
                  ch = READCHAR;
                }
              if (! in_file_vars)
                /* The value was terminated by an end-marker, which
                   remove.  */
-               val_end -= 3;
-             while (val_end > val
-                    && (val_end[-1] == ' ' || val_end[-1] == '\t'))
-               val_end--;
-             *val_end = '\0';
+               i -= 3;
+             while (i > 0 && (val[i - 1] == ' ' || val[i - 1] == '\t'))
+               i--;
+             val[i] = '\0';
 
              if (strcmp (var, "lexical-binding") == 0)
                /* This is it...  */
@@ -880,7 +879,6 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun)
       return rv;
     }
 }
-
 \f
 /* Value is a version number of byte compiled code if the file
    associated with file descriptor FD is a compiled Lisp file that's
@@ -909,7 +907,7 @@ safe_to_load_p (int fd)
        if (i == 4)
          version = buf[i];
 
-      if (i == nbytes
+      if (i >= nbytes
          || fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
                                              buf + i) < 0)
        safe_p = 0;
@@ -952,7 +950,7 @@ load_warn_old_style_backquotes (Lisp_Object file)
   return Qnil;
 }
 
-DEFUN ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0,
+DEFUE ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0,
        doc: /* Return the suffixes that `load' should try if a suffix is \
 required.
 This uses the variables `load-suffixes' and `load-file-rep-suffixes'.  */)
@@ -974,7 +972,7 @@ This uses the variables `load-suffixes' and `load-file-rep-suffixes'.  */)
   return Fnreverse (lst);
 }
 
-DEFUN ("load", Fload, Sload, 1, 5, 0,
+DEFUE ("load", Fload, Sload, 1, 5, 0,
        doc: /* Execute a file of Lisp code named FILE.
 First try FILE with `.elc' appended, then try with `.el',
 then try FILE unmodified (the exact suffixes in the exact order are
@@ -1275,7 +1273,6 @@ Return t if the file exists and loads successfully.  */)
   specbind (Qinhibit_file_name_operation, Qnil);
   load_descriptor_list
     = Fcons (make_number (fileno (stream)), load_descriptor_list);
-
   specbind (Qload_in_progress, Qt);
 
   instream = stream;
@@ -1863,11 +1860,9 @@ This function preserves the position of point.  */)
 
   specbind (Qeval_buffer_list, Fcons (buf, Veval_buffer_list));
   specbind (Qstandard_output, tem);
-  specbind (Qlexical_binding, Qnil);
   record_unwind_protect (save_excursion_restore, save_excursion_save ());
   BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
-  if (lisp_file_lexically_bound_p (buf))
-    Fset (Qlexical_binding, Qt);
+  specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil);
   readevalloop (buf, 0, filename,
                !NILP (printflag), unibyte, Qnil, Qnil, Qnil);
   unbind_to (count, Qnil);
@@ -1889,6 +1884,7 @@ which is the input stream for reading characters.
 This function does not move point.  */)
   (Lisp_Object start, Lisp_Object end, Lisp_Object printflag, Lisp_Object read_function)
 {
+  /* FIXME: Do the eval-sexp-add-defvars danse!  */
   int count = SPECPDL_INDEX ();
   Lisp_Object tem, cbuf;
 
@@ -1910,7 +1906,7 @@ This function does not move point.  */)
 }
 
 \f
-DEFUN ("read", Fread, Sread, 0, 1, 0,
+DEFUE ("read", Fread, Sread, 0, 1, 0,
        doc: /* Read one Lisp expression as text from STREAM, return as Lisp object.
 If STREAM is nil, use the value of `standard-input' (which see).
 STREAM or the value of `standard-input' may be:
@@ -1933,7 +1929,7 @@ STREAM or the value of `standard-input' may be:
   return read_internal_start (stream, Qnil, Qnil);
 }
 
-DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0,
+DEFUE ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0,
        doc: /* Read one Lisp expression which is represented as text by STRING.
 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).
 START and END optionally delimit a substring of STRING from which to read;
@@ -2323,7 +2319,7 @@ static Lisp_Object
 read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
 {
   register int c;
-  int uninterned_symbol = 0;
+  unsigned uninterned_symbol = 0;
   int multibyte;
 
   *pch = 0;
@@ -3335,7 +3331,6 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag)
   for (i = 0; i < size; i++)
     {
       item = Fcar (tem);
-
       /* If `load-force-doc-strings' is t when reading a lazily-loaded
         bytecode object, the docstring containing the bytecode and
         constants values must be treated as unibyte and passed to
@@ -3393,7 +3388,6 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag)
       tem = Fcdr (tem);
       free_cons (otem);
     }
-
   return vector;
 }
 
@@ -3660,7 +3654,7 @@ make_symbol (const char *str)
                       : make_string (str, len));
 }
 \f
-DEFUN ("intern", Fintern, Sintern, 1, 2, 0,
+DEFUE ("intern", Fintern, Sintern, 1, 2, 0,
        doc: /* Return the canonical symbol whose name is STRING.
 If there is none, one is created by this function and returned.
 A second optional argument specifies the obarray to use;
@@ -3706,7 +3700,7 @@ it defaults to the value of `obarray'.  */)
   return sym;
 }
 
-DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0,
+DEFUE ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0,
        doc: /* Return the canonical symbol named NAME, or nil if none exists.
 NAME may be a string or a symbol.  If it is a symbol, that exact
 symbol is searched for.
@@ -3734,7 +3728,7 @@ it defaults to the value of `obarray'.  */)
     return tem;
 }
 \f
-DEFUN ("unintern", Funintern, Sunintern, 1, 2, 0,
+DEFUE ("unintern", Funintern, Sunintern, 1, 2, 0,
        doc: /* Delete the symbol named NAME, if any, from OBARRAY.
 The value is t if a symbol was found and deleted, nil otherwise.
 NAME may be a string or a symbol.  If it is a symbol, that symbol
@@ -4023,7 +4017,6 @@ defvar_lisp (struct Lisp_Objfwd *o_fwd,
   staticpro (address);
 }
 
-
 /* Similar but define a variable whose value is the Lisp Object stored
    at a particular offset in the current kboard object.  */
 
@@ -4469,7 +4462,7 @@ to load.  See also `load-dangerous-libraries'.  */);
               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'.  */);
+  Lisp file read using `load'.  */);
   Fmake_variable_buffer_local (Qlexical_binding);
 
   DEFVAR_LISP ("eval-buffer-list", Veval_buffer_list,