and INTEGER as the position in that file.
But if INTEGER is negative, make it positive.
(A negative integer is used for user variables, so we can distinguish
- them without actually fetching the doc string.) */
+ them without actually fetching the doc string.)
-static Lisp_Object
-get_doc_string (filepos)
+ If UNIBYTE is nonzero, always return the result as a unibyte string. */
+
+Lisp_Object
+get_doc_string (filepos, unibyte)
Lisp_Object filepos;
+ int unibyte;
{
char *from, *to;
register int fd;
*to++ = *from++;
}
- return make_string (get_doc_string_buffer + offset,
- to - (get_doc_string_buffer + offset));
+ if (unibyte)
+ return make_unibyte_string (get_doc_string_buffer + offset,
+ to - (get_doc_string_buffer + offset));
+ else
+ return make_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.
read_doc_string (filepos)
Lisp_Object filepos;
{
- return Fread (get_doc_string (filepos));
+ return Fread (get_doc_string (filepos, 1));
}
DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0,
if ((EMACS_INT) XSUBR (fun)->doc >= 0)
doc = build_string (XSUBR (fun)->doc);
else
- doc = get_doc_string (make_number (- (EMACS_INT) XSUBR (fun)->doc));
+ doc = get_doc_string (make_number (- (EMACS_INT) XSUBR (fun)->doc), 0);
}
else if (COMPILEDP (fun))
{
if (STRINGP (tem))
doc = tem;
else if (NATNUMP (tem) || CONSP (tem))
- doc = get_doc_string (tem);
+ doc = get_doc_string (tem, 1);
else
return Qnil;
}
in the function body, so reject them if they are last. */
else if ((NATNUMP (tem) || CONSP (tem))
&& ! NILP (XCONS (tem1)->cdr))
- doc = get_doc_string (tem);
+ doc = get_doc_string (tem, 1);
else
return Qnil;
}
tem = Fget (symbol, prop);
if (INTEGERP (tem))
- tem = get_doc_string (XINT (tem) > 0 ? tem : make_number (- XINT (tem)));
+ tem = get_doc_string (XINT (tem) > 0 ? tem : make_number (- XINT (tem)), 0);
else if (CONSP (tem))
- tem = get_doc_string (tem);
+ tem = get_doc_string (tem, 0);
if (NILP (raw) && STRINGP (tem))
return Fsubstitute_command_keys (tem);
return tem;
Lisp_Object tem;
Lisp_Object keymap;
unsigned char *start;
- int length;
+ int length, length_byte;
Lisp_Object name;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
int multibyte;
if (NILP (keymap))
keymap = Voverriding_local_map;
- bsize = XSTRING (string)->size_byte;
+ bsize = STRING_BYTES (XSTRING (string));
bufp = buf = (unsigned char *) xmalloc (bsize);
strp = (unsigned char *) XSTRING (string)->data;
- while (strp < XSTRING (string)->data + XSTRING (string)->size_byte)
+ while (strp < XSTRING (string)->data + STRING_BYTES (XSTRING (string)))
{
if (strp[0] == '\\' && strp[1] == '=')
{
if (multibyte)
{
int len;
- int maxlen = XSTRING (string)->data + XSTRING (string)->size_byte - strp;
+ int maxlen = XSTRING (string)->data + STRING_BYTES (XSTRING (string)) - strp;
STRING_CHAR_AND_LENGTH (strp, maxlen, len);
if (len == 1)
else if (strp[0] == '\\' && strp[1] == '[')
{
Lisp_Object firstkey;
- int length_byte;
changed = 1;
strp += 2; /* skip \[ */
start = strp;
while ((strp - (unsigned char *) XSTRING (string)->data
- < XSTRING (string)->size_byte)
+ < STRING_BYTES (XSTRING (string)))
&& *strp != ']')
strp++;
length_byte = strp - start;
else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
{
struct buffer *oldbuf;
- int length_byte;
changed = 1;
strp += 2; /* skip \{ or \< */
insert_string ("\nUses keymap \"");
insert_from_string (name, 0, 0,
XSTRING (name)->size,
- XSTRING (name)->size_byte, 1);
+ STRING_BYTES (XSTRING (name)), 1);
insert_string ("\", which is not currently defined.\n");
if (start[-1] == '<') keymap = Qnil;
}
subst_string:
start = XSTRING (tem)->data;
length = XSTRING (tem)->size;
- length_byte = XSTRING (tem)->size_byte;
+ length_byte = STRING_BYTES (XSTRING (tem));
subst:
new = (unsigned char *) xrealloc (buf, bsize += length_byte);
bufp += new - buf;
else
{
int len;
- int maxlen = XSTRING (string)->data + XSTRING (string)->size_byte - strp;
+ int maxlen = XSTRING (string)->data + STRING_BYTES (XSTRING (string)) - strp;
STRING_CHAR_AND_LENGTH (strp, maxlen, len);
if (len == 1)
}
if (changed) /* don't bother if nothing substituted */
- tem = make_multibyte_string (buf, nchars, bufp - buf);
+ tem = make_string_from_bytes (buf, nchars, bufp - buf);
else
tem = string;
xfree (buf);
RETURN_UNGCPRO (tem);
}
\f
+void
syms_of_doc ()
{
DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name,