diff options
| author | Richard M. Stallman | 1998-06-24 04:11:00 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-06-24 04:11:00 +0000 |
| commit | f1df0d6764fd9192212a7805d2fe120572d60eb8 (patch) | |
| tree | d2a5920ee5c57d2e4a4bde24db52a074605c57a4 /src | |
| parent | 2fa8603a523c3e414e5a81be754eec5ec5d5e778 (diff) | |
| download | emacs-f1df0d6764fd9192212a7805d2fe120572d60eb8.tar.gz emacs-f1df0d6764fd9192212a7805d2fe120572d60eb8.zip | |
(get_doc_string): 2nd arg is now DEFINITION;
if non-nil, read a dynamic function definition.
(read_doc_string): Don't call read here.
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc.c | 50 |
1 files changed, 40 insertions, 10 deletions
| @@ -83,12 +83,15 @@ static int get_doc_string_buffer_size; | |||
| 83 | (A negative integer is used for user variables, so we can distinguish | 83 | (A negative integer is used for user variables, so we can distinguish |
| 84 | them without actually fetching the doc string.) | 84 | them without actually fetching the doc string.) |
| 85 | 85 | ||
| 86 | If UNIBYTE is nonzero, always return the result as a unibyte string. */ | 86 | If DEFINITION is nonzero, assume this is for reading |
| 87 | a dynamic function definition; convert the bytestring | ||
| 88 | and the constants vector with appropriate byte handling, | ||
| 89 | and return a cons cell. */ | ||
| 87 | 90 | ||
| 88 | Lisp_Object | 91 | Lisp_Object |
| 89 | get_doc_string (filepos, unibyte) | 92 | get_doc_string (filepos, definition) |
| 90 | Lisp_Object filepos; | 93 | Lisp_Object filepos; |
| 91 | int unibyte; | 94 | int definition; |
| 92 | { | 95 | { |
| 93 | char *from, *to; | 96 | char *from, *to; |
| 94 | register int fd; | 97 | register int fd; |
| @@ -242,12 +245,39 @@ get_doc_string (filepos, unibyte) | |||
| 242 | *to++ = *from++; | 245 | *to++ = *from++; |
| 243 | } | 246 | } |
| 244 | 247 | ||
| 245 | if (unibyte) | 248 | if (definition) |
| 246 | return make_unibyte_string (get_doc_string_buffer + offset, | 249 | { |
| 247 | to - (get_doc_string_buffer + offset)); | 250 | char *p = get_doc_string_buffer + offset; |
| 248 | else | 251 | char *start_ptr; |
| 249 | return make_string (get_doc_string_buffer + offset, | 252 | Lisp_Object bytestring, vector; |
| 250 | to - (get_doc_string_buffer + offset)); | 253 | |
| 254 | if (*p++ != '(') | ||
| 255 | return Qnil; | ||
| 256 | start_ptr = p; | ||
| 257 | if (*p++ != '"') | ||
| 258 | return Qnil; | ||
| 259 | while (*p != '"') | ||
| 260 | { | ||
| 261 | if (*p == '\\') | ||
| 262 | p++; | ||
| 263 | p++; | ||
| 264 | } | ||
| 265 | p++; | ||
| 266 | bytestring = Fread (make_unibyte_string (start_ptr, p - start_ptr)); | ||
| 267 | if (*p++ != ' ') | ||
| 268 | return Qnil; | ||
| 269 | if (*p++ != '.') | ||
| 270 | return Qnil; | ||
| 271 | if (*p++ != ' ') | ||
| 272 | return Qnil; | ||
| 273 | if (to[-1] != ')') | ||
| 274 | return Qnil; | ||
| 275 | vector = Fread (make_string (p, to - p - 1)); | ||
| 276 | return Fcons (bytestring, vector); | ||
| 277 | } | ||
| 278 | |||
| 279 | return make_string (get_doc_string_buffer + offset, | ||
| 280 | to - (get_doc_string_buffer + offset)); | ||
| 251 | } | 281 | } |
| 252 | 282 | ||
| 253 | /* Get a string from position FILEPOS and pass it through the Lisp reader. | 283 | /* Get a string from position FILEPOS and pass it through the Lisp reader. |
| @@ -258,7 +288,7 @@ Lisp_Object | |||
| 258 | read_doc_string (filepos) | 288 | read_doc_string (filepos) |
| 259 | Lisp_Object filepos; | 289 | Lisp_Object filepos; |
| 260 | { | 290 | { |
| 261 | return Fread (get_doc_string (filepos, 1)); | 291 | return get_doc_string (filepos, 1); |
| 262 | } | 292 | } |
| 263 | 293 | ||
| 264 | DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, | 294 | DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, |