/* Function to use for reading, in `load' and friends. */
Lisp_Object Vload_read_function;
+/* 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;
else
{
UNREAD (c);
+ read_objects = Qnil;
if (NILP (Vload_read_function))
val = read0 (readcharfun);
else
stream = Qread_char;
new_backquote_flag = 0;
+ read_objects = Qnil;
#ifndef standalone
if (EQ (stream, Qread_char))
read_from_string_limit = endval;
new_backquote_flag = 0;
+ read_objects = Qnil;
tem = read0 (string);
return Fcons (tem, make_number (read_from_string_index));
int first_in_list;
{
register int c;
+ int uninterned_symbol = 0;
+
*pch = 0;
retry:
return Vload_file_name;
if (c == '\'')
return Fcons (Qfunction, Fcons (read0 (readcharfun), Qnil));
+ /* #:foo is the uninterned symbol named foo. */
+ if (c == ':')
+ {
+ uninterned_symbol = 1;
+ c = READCHAR;
+ goto default_label;
+ }
+ /* Reader forms that can reuse previously read objects. */
+ if (c >= '0' && c <= '9')
+ {
+ int n = 0;
+ Lisp_Object tem;
+ /* Read a non-negative integer. */
+ while (c >= '0' && c <= '9')
+ {
+ n *= 10;
+ n += c - '0';
+ c = READCHAR;
+ }
+ /* #n=object returns object, but associates it with n for #n#. */
+ if (c == '=')
+ {
+ tem = read0 (readcharfun);
+ read_objects = Fcons (Fcons (make_number (n), tem), read_objects);
+ return tem;
+ }
+ /* #n# returns a previously read object. */
+ if (c == '#')
+ {
+ tem = Fassq (make_number (n), read_objects);
+ if (CONSP (tem))
+ return XCDR (tem);
+ /* Fall through to error message. */
+ }
+ /* Fall through to error message. */
+ }
UNREAD (c);
Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
UNREAD (c);
}
- if (!quoted)
+ if (!quoted && !uninterned_symbol)
{
register char *p1;
register Lisp_Object val;
#endif
}
- return intern (read_buffer);
+ if (uninterned_symbol)
+ return make_symbol (read_buffer);
+ else
+ return intern (read_buffer);
}
}
}
: make_string (str, len)),
obarray);
}
+
+/* Create an uninterned symbol with name STR. */
+
+Lisp_Object
+make_symbol (str)
+ char *str;
+{
+ int len = strlen (str);
+
+ return Fmake_symbol ((!NILP (Vpurify_flag)
+ ? make_pure_string (str, len)
+ : make_string (str, len)));
+}
\f
DEFUN ("intern", Fintern, Sintern, 1, 2, 0,
"Return the canonical symbol whose name is STRING.\n\
if (!NILP (Vpurify_flag))
string = Fpurecopy (string);
sym = Fmake_symbol (string);
+ XSYMBOL (sym)->obarray = obarray;
ptr = &XVECTOR (obarray)->contents[XINT (tem)];
if (SYMBOLP (*ptr))
initial_obarray = Vobarray;
staticpro (&initial_obarray);
/* Intern nil in the obarray */
+ XSYMBOL (Qnil)->obarray = Vobarray;
/* These locals are to kludge around a pyramid compiler bug. */
hash = hash_string ("nil", 3);
/* Separate statement here to avoid VAXC bug. */
staticpro (&Qload_file_name);
staticpro (&dump_path);
+
+ staticpro (&read_objects);
+ read_objects = Qnil;
}