diff options
Diffstat (limited to 'src/doc.c')
| -rw-r--r-- | src/doc.c | 41 |
1 files changed, 24 insertions, 17 deletions
| @@ -1,6 +1,7 @@ | |||
| 1 | /* Record indices of function doc strings stored in a file. | 1 | /* Record indices of function doc strings stored in a file. |
| 2 | 2 | ||
| 3 | Copyright (C) 1985-1986, 1993-1995, 1997-2012 Free Software Foundation, Inc. | 3 | Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software Foundation, |
| 4 | Inc. | ||
| 4 | 5 | ||
| 5 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| 6 | 7 | ||
| @@ -83,24 +84,23 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 83 | ptrdiff_t minsize; | 84 | ptrdiff_t minsize; |
| 84 | int offset; | 85 | int offset; |
| 85 | EMACS_INT position; | 86 | EMACS_INT position; |
| 86 | Lisp_Object file, tem; | 87 | Lisp_Object file, tem, pos; |
| 87 | USE_SAFE_ALLOCA; | 88 | USE_SAFE_ALLOCA; |
| 88 | 89 | ||
| 89 | if (INTEGERP (filepos)) | 90 | if (INTEGERP (filepos)) |
| 90 | { | 91 | { |
| 91 | file = Vdoc_file_name; | 92 | file = Vdoc_file_name; |
| 92 | position = XINT (filepos); | 93 | pos = filepos; |
| 93 | } | 94 | } |
| 94 | else if (CONSP (filepos)) | 95 | else if (CONSP (filepos)) |
| 95 | { | 96 | { |
| 96 | file = XCAR (filepos); | 97 | file = XCAR (filepos); |
| 97 | position = XINT (XCDR (filepos)); | 98 | pos = XCDR (filepos); |
| 98 | } | 99 | } |
| 99 | else | 100 | else |
| 100 | return Qnil; | 101 | return Qnil; |
| 101 | 102 | ||
| 102 | if (position < 0) | 103 | position = eabs (XINT (pos)); |
| 103 | position = - position; | ||
| 104 | 104 | ||
| 105 | if (!STRINGP (Vdoc_directory)) | 105 | if (!STRINGP (Vdoc_directory)) |
| 106 | return Qnil; | 106 | return Qnil; |
| @@ -176,9 +176,9 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 176 | if (space_left <= 0) | 176 | if (space_left <= 0) |
| 177 | { | 177 | { |
| 178 | ptrdiff_t in_buffer = p - get_doc_string_buffer; | 178 | ptrdiff_t in_buffer = p - get_doc_string_buffer; |
| 179 | get_doc_string_buffer = | 179 | get_doc_string_buffer |
| 180 | xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size, | 180 | = xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size, |
| 181 | 16 * 1024, -1, 1); | 181 | 16 * 1024, -1, 1); |
| 182 | p = get_doc_string_buffer + in_buffer; | 182 | p = get_doc_string_buffer + in_buffer; |
| 183 | space_left = (get_doc_string_buffer_size - 1 | 183 | space_left = (get_doc_string_buffer_size - 1 |
| 184 | - (p - get_doc_string_buffer)); | 184 | - (p - get_doc_string_buffer)); |
| @@ -279,10 +279,10 @@ Invalid data in documentation file -- %c followed by code %03o", | |||
| 279 | else | 279 | else |
| 280 | { | 280 | { |
| 281 | /* The data determines whether the string is multibyte. */ | 281 | /* The data determines whether the string is multibyte. */ |
| 282 | ptrdiff_t nchars = | 282 | ptrdiff_t nchars |
| 283 | multibyte_chars_in_text (((unsigned char *) get_doc_string_buffer | 283 | = multibyte_chars_in_text (((unsigned char *) get_doc_string_buffer |
| 284 | + offset), | 284 | + offset), |
| 285 | to - (get_doc_string_buffer + offset)); | 285 | to - (get_doc_string_buffer + offset)); |
| 286 | return make_string_from_bytes (get_doc_string_buffer + offset, | 286 | return make_string_from_bytes (get_doc_string_buffer + offset, |
| 287 | nchars, | 287 | nchars, |
| 288 | to - (get_doc_string_buffer + offset)); | 288 | to - (get_doc_string_buffer + offset)); |
| @@ -338,6 +338,14 @@ string is passed through `substitute-command-keys'. */) | |||
| 338 | 338 | ||
| 339 | doc = Qnil; | 339 | doc = Qnil; |
| 340 | 340 | ||
| 341 | if (SYMBOLP (function)) | ||
| 342 | { | ||
| 343 | Lisp_Object tem = Fget (function, Qfunction_documentation); | ||
| 344 | if (!NILP (tem)) | ||
| 345 | return Fdocumentation_property (function, Qfunction_documentation, | ||
| 346 | raw); | ||
| 347 | } | ||
| 348 | |||
| 341 | fun = Findirect_function (function, Qnil); | 349 | fun = Findirect_function (function, Qnil); |
| 342 | if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) | 350 | if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) |
| 343 | fun = XCDR (fun); | 351 | fun = XCDR (fun); |
| @@ -622,11 +630,10 @@ the same file name is found in the `doc-directory'. */) | |||
| 622 | break; | 630 | break; |
| 623 | 631 | ||
| 624 | buf[filled] = 0; | 632 | buf[filled] = 0; |
| 625 | p = buf; | ||
| 626 | end = buf + (filled < 512 ? filled : filled - 128); | 633 | end = buf + (filled < 512 ? filled : filled - 128); |
| 627 | while (p != end && *p != '\037') p++; | 634 | p = memchr (buf, '\037', end - buf); |
| 628 | /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */ | 635 | /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */ |
| 629 | if (p != end) | 636 | if (p) |
| 630 | { | 637 | { |
| 631 | end = strchr (p, '\n'); | 638 | end = strchr (p, '\n'); |
| 632 | 639 | ||
| @@ -819,7 +826,7 @@ Otherwise, return a new string, without any text properties. */) | |||
| 819 | if (NILP (tem)) /* but not on any keys */ | 826 | if (NILP (tem)) /* but not on any keys */ |
| 820 | { | 827 | { |
| 821 | ptrdiff_t offset = bufp - buf; | 828 | ptrdiff_t offset = bufp - buf; |
| 822 | if (STRING_BYTES_BOUND - 4 < bsize) | 829 | if (bsize > STRING_BYTES_BOUND - 4) |
| 823 | string_overflow (); | 830 | string_overflow (); |
| 824 | buf = xrealloc (buf, bsize += 4); | 831 | buf = xrealloc (buf, bsize += 4); |
| 825 | bufp = buf + offset; | 832 | bufp = buf + offset; |