/* Record indices of function doc strings stored in a file.
-Copyright (C) 1985-1986, 1993-1995, 1997-2012 Free Software Foundation, Inc.
+Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software Foundation,
+Inc.
This file is part of GNU Emacs.
ptrdiff_t minsize;
int offset;
EMACS_INT position;
- Lisp_Object file, tem;
+ Lisp_Object file, tem, pos;
USE_SAFE_ALLOCA;
if (INTEGERP (filepos))
{
file = Vdoc_file_name;
- position = XINT (filepos);
+ pos = filepos;
}
else if (CONSP (filepos))
{
file = XCAR (filepos);
- position = XINT (XCDR (filepos));
+ pos = XCDR (filepos);
}
else
return Qnil;
- if (position < 0)
- position = - position;
+ position = eabs (XINT (pos));
if (!STRINGP (Vdoc_directory))
return Qnil;
if (space_left <= 0)
{
ptrdiff_t in_buffer = p - get_doc_string_buffer;
- get_doc_string_buffer =
- xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size,
- 16 * 1024, -1, 1);
+ get_doc_string_buffer
+ = xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size,
+ 16 * 1024, -1, 1);
p = get_doc_string_buffer + in_buffer;
space_left = (get_doc_string_buffer_size - 1
- (p - get_doc_string_buffer));
else
{
/* The data determines whether the string is multibyte. */
- ptrdiff_t nchars =
- multibyte_chars_in_text (((unsigned char *) get_doc_string_buffer
- + offset),
- to - (get_doc_string_buffer + offset));
+ ptrdiff_t nchars
+ = multibyte_chars_in_text (((unsigned char *) get_doc_string_buffer
+ + offset),
+ to - (get_doc_string_buffer + offset));
return make_string_from_bytes (get_doc_string_buffer + offset,
nchars,
to - (get_doc_string_buffer + offset));
doc = Qnil;
+ if (SYMBOLP (function))
+ {
+ Lisp_Object tem = Fget (function, Qfunction_documentation);
+ if (!NILP (tem))
+ return Fdocumentation_property (function, Qfunction_documentation,
+ raw);
+ }
+
fun = Findirect_function (function, Qnil);
if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
fun = XCDR (fun);
break;
buf[filled] = 0;
- p = buf;
end = buf + (filled < 512 ? filled : filled - 128);
- while (p != end && *p != '\037') p++;
+ p = memchr (buf, '\037', end - buf);
/* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */
- if (p != end)
+ if (p)
{
end = strchr (p, '\n');