aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.c
diff options
context:
space:
mode:
authorStefan Monnier2001-12-05 01:47:27 +0000
committerStefan Monnier2001-12-05 01:47:27 +0000
commit87afdd65ce2117e0dc85fc15e146a64324dc6b22 (patch)
treeeed13c454fbf10e476f5bd6738a7afb0a3380df8 /src/doc.c
parent162873a199b1dfa5fe2b8686c2204b8cf267f15c (diff)
downloademacs-87afdd65ce2117e0dc85fc15e146a64324dc6b22.tar.gz
emacs-87afdd65ce2117e0dc85fc15e146a64324dc6b22.zip
(Fsnarf_documentation): Add prototype.
(get_doc_string): Handle negative arguments. (Fdocumentation): Use AREF and ASIZE. Move the calls to get_doc_string to a single place. Don't confuse an interactive-spec for a docstring reference. (Fdocumentation_property): Take advantage of the fact that get_doc_string now ignores the sign of the docstring position.
Diffstat (limited to 'src/doc.c')
-rw-r--r--src/doc.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/doc.c b/src/doc.c
index be976909f61..c632e1b1c2b 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -81,6 +81,7 @@ static char *get_doc_string_buffer;
81static int get_doc_string_buffer_size; 81static int get_doc_string_buffer_size;
82 82
83static unsigned char *read_bytecode_pointer; 83static unsigned char *read_bytecode_pointer;
84Lisp_Object Fsnarf_documentation P_ ((Lisp_Object));
84 85
85/* readchar in lread.c calls back here to fetch the next byte. 86/* readchar in lread.c calls back here to fetch the next byte.
86 If UNREADFLAG is 1, we unread a byte. */ 87 If UNREADFLAG is 1, we unread a byte. */
@@ -134,12 +135,13 @@ get_doc_string (filepos, unibyte, definition)
134 { 135 {
135 file = XCAR (filepos); 136 file = XCAR (filepos);
136 position = XINT (XCDR (filepos)); 137 position = XINT (XCDR (filepos));
137 if (position < 0)
138 position = - position;
139 } 138 }
140 else 139 else
141 return Qnil; 140 return Qnil;
142 141
142 if (position < 0)
143 position = - position;
144
143 if (!STRINGP (Vdoc_directory)) 145 if (!STRINGP (Vdoc_directory))
144 return Qnil; 146 return Qnil;
145 147
@@ -329,18 +331,17 @@ string is passed through `substitute-command-keys'. */)
329 else if ((EMACS_INT) XSUBR (fun)->doc >= 0) 331 else if ((EMACS_INT) XSUBR (fun)->doc >= 0)
330 doc = build_string (XSUBR (fun)->doc); 332 doc = build_string (XSUBR (fun)->doc);
331 else 333 else
332 doc = get_doc_string (make_number (- (EMACS_INT) XSUBR (fun)->doc), 334 doc = make_number ((EMACS_INT) XSUBR (fun)->doc);
333 0, 0);
334 } 335 }
335 else if (COMPILEDP (fun)) 336 else if (COMPILEDP (fun))
336 { 337 {
337 if ((XVECTOR (fun)->size & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING) 338 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING)
338 return Qnil; 339 return Qnil;
339 tem = XVECTOR (fun)->contents[COMPILED_DOC_STRING]; 340 tem = AREF (fun, COMPILED_DOC_STRING);
340 if (STRINGP (tem)) 341 if (STRINGP (tem))
341 doc = tem; 342 doc = tem;
342 else if (NATNUMP (tem) || CONSP (tem)) 343 else if (NATNUMP (tem) || CONSP (tem))
343 doc = get_doc_string (tem, 0, 0); 344 doc = tem;
344 else 345 else
345 return Qnil; 346 return Qnil;
346 } 347 }
@@ -365,9 +366,9 @@ string is passed through `substitute-command-keys'. */)
365 doc = tem; 366 doc = tem;
366 /* Handle a doc reference--but these never come last 367 /* Handle a doc reference--but these never come last
367 in the function body, so reject them if they are last. */ 368 in the function body, so reject them if they are last. */
368 else if ((NATNUMP (tem) || CONSP (tem)) 369 else if ((NATNUMP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem))))
369 && ! NILP (XCDR (tem1))) 370 && !NILP (XCDR (tem1)))
370 doc = get_doc_string (tem, 0, 0); 371 doc = tem;
371 else 372 else
372 return Qnil; 373 return Qnil;
373 } 374 }
@@ -384,6 +385,9 @@ string is passed through `substitute-command-keys'. */)
384 Fsignal (Qinvalid_function, Fcons (fun, Qnil)); 385 Fsignal (Qinvalid_function, Fcons (fun, Qnil));
385 } 386 }
386 387
388 if (INTEGERP (doc) || CONSP (doc))
389 doc = get_doc_string (doc, 0, 0);
390
387 if (NILP (raw)) 391 if (NILP (raw))
388 doc = Fsubstitute_command_keys (doc); 392 doc = Fsubstitute_command_keys (doc);
389 return doc; 393 return doc;
@@ -404,9 +408,7 @@ aren't strings. */)
404 Lisp_Object tem; 408 Lisp_Object tem;
405 409
406 tem = Fget (symbol, prop); 410 tem = Fget (symbol, prop);
407 if (INTEGERP (tem)) 411 if (INTEGERP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem))))
408 tem = get_doc_string (XINT (tem) > 0 ? tem : make_number (- XINT (tem)), 0, 0);
409 else if (CONSP (tem) && INTEGERP (XCDR (tem)))
410 tem = get_doc_string (tem, 0, 0); 412 tem = get_doc_string (tem, 0, 0);
411 else if (!STRINGP (tem)) 413 else if (!STRINGP (tem))
412 /* Feval protects its argument. */ 414 /* Feval protects its argument. */
@@ -454,8 +456,8 @@ store_function_docstring (fun, offset)
454 { 456 {
455 /* This bytecode object must have a slot for the 457 /* This bytecode object must have a slot for the
456 docstring, since we've found a docstring for it. */ 458 docstring, since we've found a docstring for it. */
457 if ((XVECTOR (fun)->size & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) 459 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING)
458 XSETFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING], offset); 460 XSETFASTINT (AREF (fun, COMPILED_DOC_STRING), offset);
459 } 461 }
460} 462}
461 463