diff options
| author | Paul Eggert | 2016-06-14 12:19:36 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-06-14 12:21:00 -0700 |
| commit | c5461d03a411ff5c6f43885a0a9030e8a94bbc2e (patch) | |
| tree | 3670c5dd1941dde89b1ac4b6e765ec084fa1a546 /src/doc.c | |
| parent | 7f35d5cbaf055dddcf0489a6f6a46df7ddaeeaf4 (diff) | |
| download | emacs-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.c | 18 |
1 files changed, 3 insertions, 15 deletions
| @@ -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 | ||
| 475 | static void | 466 | static void |
| 476 | store_function_docstring (Lisp_Object obj, ptrdiff_t offset) | 467 | store_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)) |