comparison src/doc.c @ 41823:e192139240f2

(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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 05 Dec 2001 01:47:27 +0000
parents ace002127a1c
children 4bb44400f978
comparison
equal deleted inserted replaced
41822:50b6bc7ee607 41823:e192139240f2
79 /* Buffer used for reading from documentation file. */ 79 /* Buffer used for reading from documentation file. */
80 static char *get_doc_string_buffer; 80 static char *get_doc_string_buffer;
81 static int get_doc_string_buffer_size; 81 static int get_doc_string_buffer_size;
82 82
83 static unsigned char *read_bytecode_pointer; 83 static unsigned char *read_bytecode_pointer;
84 Lisp_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. */
87 88
88 int 89 int
132 } 133 }
133 else if (CONSP (filepos)) 134 else if (CONSP (filepos))
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;
141
142 if (position < 0)
143 position = - position;
142 144
143 if (!STRINGP (Vdoc_directory)) 145 if (!STRINGP (Vdoc_directory))
144 return Qnil; 146 return Qnil;
145 147
146 if (!STRINGP (file)) 148 if (!STRINGP (file))
327 if (XSUBR (fun)->doc == 0) 329 if (XSUBR (fun)->doc == 0)
328 return Qnil; 330 return Qnil;
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 }
347 else if (STRINGP (fun) || VECTORP (fun)) 348 else if (STRINGP (fun) || VECTORP (fun))
348 { 349 {
363 tem = Fcar (tem1); 364 tem = Fcar (tem1);
364 if (STRINGP (tem)) 365 if (STRINGP (tem))
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 }
374 else if (EQ (funcar, Qmocklisp)) 375 else if (EQ (funcar, Qmocklisp))
375 return Qnil; 376 return Qnil;
382 { 383 {
383 oops: 384 oops:
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;
390 } 394 }
391 395
402 Lisp_Object symbol, prop, raw; 406 Lisp_Object symbol, prop, raw;
403 { 407 {
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. */
413 tem = Feval (tem); 415 tem = Feval (tem);
414 416
452 /* Bytecode objects sometimes have slots for it. */ 454 /* Bytecode objects sometimes have slots for it. */
453 else if (COMPILEDP (fun)) 455 else if (COMPILEDP (fun))
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
462 464
463 DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation, 465 DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation,