aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.c
diff options
context:
space:
mode:
authorPaul Eggert2016-06-14 12:19:36 -0700
committerPaul Eggert2016-06-14 12:21:00 -0700
commitc5461d03a411ff5c6f43885a0a9030e8a94bbc2e (patch)
tree3670c5dd1941dde89b1ac4b6e765ec084fa1a546 /src/doc.c
parent7f35d5cbaf055dddcf0489a6f6a46df7ddaeeaf4 (diff)
downloademacs-c5461d03a411ff5c6f43885a0a9030e8a94bbc2e.tar.gz
emacs-c5461d03a411ff5c6f43885a0a9030e8a94bbc2e.zip
Port to platforms where char * has top bit set
This fixes a five-year-old FIXME comment. Although I don’t know of a platform where this is a problem in practice, better safe than sorry. * src/doc.c (Fdocumentation): If SUBRP, simply use doc as integer, as it is now an integer, not char *. (store_function_docstring): Offset is now EMACS_INT, not ptrdiff_t; this is a file offset and EMACS_INT is better if --with-wide-int. If SUBRP, simply store the offset rather than negating it and converting it to char *. * src/lisp.h (struct Lisp_Subr.doc): Now EMACS_INT, not char *.
Diffstat (limited to 'src/doc.c')
-rw-r--r--src/doc.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/doc.c b/src/doc.c
index 7107580cf8b..6ffdad10f03 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -339,16 +339,7 @@ string is passed through `substitute-command-keys'. */)
339 if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) 339 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
340 fun = XCDR (fun); 340 fun = XCDR (fun);
341 if (SUBRP (fun)) 341 if (SUBRP (fun))
342 { 342 doc = make_number (XSUBR (fun)->doc);
343 if (XSUBR (fun)->doc == 0)
344 return Qnil;
345 /* FIXME: This is not portable, as it assumes that string
346 pointers have the top bit clear. */
347 else if ((intptr_t) XSUBR (fun)->doc >= 0)
348 doc = build_string (XSUBR (fun)->doc);
349 else
350 doc = make_number ((intptr_t) XSUBR (fun)->doc);
351 }
352 else if (COMPILEDP (fun)) 343 else if (COMPILEDP (fun))
353 { 344 {
354 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING) 345 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING)
@@ -473,7 +464,7 @@ aren't strings. */)
473/* Scanning the DOC files and placing docstring offsets into functions. */ 464/* Scanning the DOC files and placing docstring offsets into functions. */
474 465
475static void 466static void
476store_function_docstring (Lisp_Object obj, ptrdiff_t offset) 467store_function_docstring (Lisp_Object obj, EMACS_INT offset)
477{ 468{
478 /* Don't use indirect_function here, or defaliases will apply their 469 /* Don't use indirect_function here, or defaliases will apply their
479 docstrings to the base functions (Bug#2603). */ 470 docstrings to the base functions (Bug#2603). */
@@ -502,10 +493,7 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
502 493
503 /* Lisp_Subrs have a slot for it. */ 494 /* Lisp_Subrs have a slot for it. */
504 else if (SUBRP (fun)) 495 else if (SUBRP (fun))
505 { 496 XSUBR (fun)->doc = offset;
506 intptr_t negative_offset = - offset;
507 XSUBR (fun)->doc = (char *) negative_offset;
508 }
509 497
510 /* Bytecode objects sometimes have slots for it. */ 498 /* Bytecode objects sometimes have slots for it. */
511 else if (COMPILEDP (fun)) 499 else if (COMPILEDP (fun))