static char *get_doc_string_buffer;
static ptrdiff_t get_doc_string_buffer_size;
-static unsigned char *read_bytecode_pointer;
-
static char const sibling_etc[] = "../etc/";
-/* `readchar' in lread.c calls back here to fetch the next byte.
- If UNREADFLAG is 1, we unread a byte. */
-
-int
-read_bytecode_char (bool unreadflag)
-{
- if (unreadflag)
- {
- read_bytecode_pointer--;
- return 0;
- }
- return *read_bytecode_pointer++;
-}
-
#ifdef USE_ANDROID_ASSETS
/* Like `close_file_unwind'. However, PTR is a pointer to an Android
(e.g. because the file has been modified and the location is stale),
return nil.
- If UNIBYTE, always make a unibyte string.
-
- If DEFINITION, assume this is for reading
- a dynamic function definition; convert the bytestring
- and the constants vector with appropriate byte handling,
- and return a cons cell. */
+ If UNIBYTE, always make a unibyte string. */
Lisp_Object
-get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
+get_doc_string (Lisp_Object filepos, bool unibyte)
{
char *from, *to, *name, *p, *p1;
Lisp_Object file, pos;
*to++ = *from++;
}
- /* If DEFINITION, read from this buffer
- the same way we would read bytes from a file. */
- if (definition)
- {
- read_bytecode_pointer = (unsigned char *) get_doc_string_buffer + offset;
- return Fread (Qlambda);
- }
-
if (unibyte)
return make_unibyte_string (get_doc_string_buffer + offset,
to - (get_doc_string_buffer + offset));
}
}
-/* Get a string from position FILEPOS and pass it through the Lisp reader.
- We use this for fetching the bytecode string and constants vector
- of a compiled function from the .elc file. */
-
-Lisp_Object
-read_doc_string (Lisp_Object filepos)
-{
- return get_doc_string (filepos, 0, 1);
-}
-
static bool
reread_doc_file (Lisp_Object file)
{
if (FIXNUMP (doc) || CONSP (doc))
{
Lisp_Object tem;
- tem = get_doc_string (doc, 0, 0);
+ tem = get_doc_string (doc, 0);
if (NILP (tem) && try_reload)
{
/* The file is newer, we need to reset the pointers. */
if (FIXNUMP (tem) || (CONSP (tem) && FIXNUMP (XCDR (tem))))
{
Lisp_Object doc = tem;
- tem = get_doc_string (tem, 0, 0);
+ tem = get_doc_string (tem, 0);
if (NILP (tem) && try_reload)
{
/* The file is newer, we need to reset the pointers. */
ptrdiff_t *);
\f
-/* Functions that read one byte from the current source READCHARFUN
+/* Function that reads one byte from the current source READCHARFUN
or unreads one byte. If the integer argument C is -1, it returns
one read byte, or -1 when there's no more byte in the source. If C
is 0 or positive, it unreads C, and the return value is not
interesting. */
-static int readbyte_for_lambda (int, Lisp_Object);
static int readbyte_from_file (int, Lisp_Object);
-static int readbyte_from_string (int, Lisp_Object);
/* Handle unreading and rereading of characters.
Write READCHAR to read a character,
/* Same as READCHAR but set *MULTIBYTE to the multibyteness of the source. */
#define READCHAR_REPORT_MULTIBYTE(multibyte) readchar (readcharfun, multibyte)
-/* When READCHARFUN is Qget_file_char, Qget_emacs_mule_file_char,
- Qlambda, or a cons, we use this to keep an unread character because
+/* When READCHARFUN is Qget_file_char or Qget_emacs_mule_file_char,
+ we use this to keep an unread character because
a file stream can't handle multibyte-char unreading. The value -1
means that there's no unread character. */
static int unread_char = -1;
return c;
}
- if (EQ (readcharfun, Qlambda))
- {
- readbyte = readbyte_for_lambda;
- goto read_multibyte;
- }
-
if (EQ (readcharfun, Qget_file_char))
{
eassert (infile);
return c;
}
- if (CONSP (readcharfun) && STRINGP (XCAR (readcharfun)))
- {
- /* This is the case that read_vector is reading from a unibyte
- string that contains a byte sequence previously skipped
- because of #@NUMBER. The car part of readcharfun is that
- string, and the cdr part is a value of readcharfun given to
- read_vector. */
- readbyte = readbyte_from_string;
- eassert (infile);
- if (EQ (XCDR (readcharfun), Qget_emacs_mule_file_char))
- emacs_mule_encoding = 1;
- goto read_multibyte;
- }
-
if (EQ (readcharfun, Qget_emacs_mule_file_char))
{
readbyte = readbyte_from_file;
read_from_string_index_byte
= string_char_to_byte (readcharfun, read_from_string_index);
}
- else if (CONSP (readcharfun) && STRINGP (XCAR (readcharfun)))
- {
- unread_char = c;
- }
- else if (EQ (readcharfun, Qlambda))
- {
- unread_char = c;
- }
else if (FROM_FILE_P (readcharfun))
{
unread_char = c;
call1 (readcharfun, make_fixnum (c));
}
-static int
-readbyte_for_lambda (int c, Lisp_Object readcharfun)
-{
- return read_bytecode_char (c >= 0);
-}
-
-
static int
readbyte_from_stdio (void)
{
return readbyte_from_stdio ();
}
-static int
-readbyte_from_string (int c, Lisp_Object readcharfun)
-{
- Lisp_Object string = XCAR (readcharfun);
-
- if (c >= 0)
- {
- read_from_string_index--;
- read_from_string_index_byte
- = string_char_to_byte (string, read_from_string_index);
- }
-
- return (read_from_string_index < read_from_string_limit
- ? fetch_string_char_advance (string,
- &read_from_string_index,
- &read_from_string_index_byte)
- : -1);
-}
-
-
/* Signal Qinvalid_read_syntax error.
S is error string of length N (if > 0) */
/* Lazily-loaded bytecode is represented by the constant slot being nil
and the bytecode slot a (lazily loaded) string containing the
- print representation of (BYTECODE . CONSTANTS). Unpack the
- pieces by coerceing the string to unibyte and reading the result. */
+ print representation of (BYTECODE . CONSTANTS). */
if (NILP (vec[CLOSURE_CONSTANTS]) && STRINGP (vec[CLOSURE_CODE]))
{
Lisp_Object enc = vec[CLOSURE_CODE];
- Lisp_Object pair = Fread (Fcons (enc, readcharfun));
+ eassert (!STRING_MULTIBYTE (enc));
+ /* The string (always unibyte) must be decoded to be parsed. */
+ enc = Fdecode_coding_string (enc,
+ EQ (readcharfun,
+ Qget_emacs_mule_file_char)
+ ? Qemacs_mule : Qutf_8_emacs,
+ Qt, Qnil);
+ Lisp_Object pair = Fread (enc);
if (!CONSP (pair))
invalid_syntax ("Invalid byte-code object", readcharfun);
&& !(pos >= ss->position && pos < ss->position + ss->length))
ss++;
if (ss >= ssend)
- return get_doc_string (val, 1, 0);
+ return get_doc_string (val, 1);
ptrdiff_t start = pos - ss->position;
char *str = ss->string;