diff options
| author | Stefan Kangas | 2025-01-24 00:16:08 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2025-01-24 00:16:08 +0100 |
| commit | c7f6da7a4141a9f3492b8dbb0c1de710bd4757fa (patch) | |
| tree | ef2693642eec14333f7b4047efb6402dd3078f87 /src | |
| parent | ed5067e689a5e38795d5c27c5a688886d259a298 (diff) | |
| download | emacs-c7f6da7a4141a9f3492b8dbb0c1de710bd4757fa.tar.gz emacs-c7f6da7a4141a9f3492b8dbb0c1de710bd4757fa.zip | |
Don't use negative positions for docstrings
These were used for user-variables (doc starts with a '*'), but we don't
use that convention any more. On my machine, there are no docstrings
starting with a '*' in etc/DOC.
* src/doc.c (Fsnarf_documentation): Never use negative positions.
(get_doc_string): Don't use eabs; position must now be positive, and all
callers are verified to do that.
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc.c | 24 |
1 files changed, 8 insertions, 16 deletions
| @@ -96,9 +96,6 @@ close_file_unwind_android_fd (void *ptr) | |||
| 96 | If it is an integer, use that position in the standard DOC file. | 96 | If it is an integer, use that position in the standard DOC file. |
| 97 | If it is (FILE . INTEGER), use FILE as the file name | 97 | If it is (FILE . INTEGER), use FILE as the file name |
| 98 | and INTEGER as the position in that file. | 98 | and INTEGER as the position in that file. |
| 99 | But if INTEGER is negative, make it positive. | ||
| 100 | (A negative integer is used for user variables, so we can distinguish | ||
| 101 | them without actually fetching the doc string.) | ||
| 102 | 99 | ||
| 103 | If the location does not point to the beginning of a docstring | 100 | If the location does not point to the beginning of a docstring |
| 104 | (e.g. because the file has been modified and the location is stale), | 101 | (e.g. because the file has been modified and the location is stale), |
| @@ -130,7 +127,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte) | |||
| 130 | else | 127 | else |
| 131 | return Qnil; | 128 | return Qnil; |
| 132 | 129 | ||
| 133 | EMACS_INT position = eabs (XFIXNUM (pos)); | 130 | EMACS_INT position = XFIXNUM (pos); |
| 134 | 131 | ||
| 135 | if (!STRINGP (dir)) | 132 | if (!STRINGP (dir)) |
| 136 | return Qnil; | 133 | return Qnil; |
| @@ -192,7 +189,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte) | |||
| 192 | P points beyond the data just read. */ | 189 | P points beyond the data just read. */ |
| 193 | 190 | ||
| 194 | p = get_doc_string_buffer; | 191 | p = get_doc_string_buffer; |
| 195 | while (1) | 192 | while (true) |
| 196 | { | 193 | { |
| 197 | ptrdiff_t space_left = (get_doc_string_buffer_size - 1 | 194 | ptrdiff_t space_left = (get_doc_string_buffer_size - 1 |
| 198 | - (p - get_doc_string_buffer)); | 195 | - (p - get_doc_string_buffer)); |
| @@ -508,10 +505,7 @@ That file is found in `../etc' now; later, when the dumped Emacs is run, | |||
| 508 | the same file name is found in the `doc-directory'. */) | 505 | the same file name is found in the `doc-directory'. */) |
| 509 | (Lisp_Object filename) | 506 | (Lisp_Object filename) |
| 510 | { | 507 | { |
| 511 | doc_fd fd; | ||
| 512 | char buf[1024 + 1]; | 508 | char buf[1024 + 1]; |
| 513 | int filled; | ||
| 514 | EMACS_INT pos; | ||
| 515 | Lisp_Object sym; | 509 | Lisp_Object sym; |
| 516 | char *p, *name; | 510 | char *p, *name; |
| 517 | char const *dirname; | 511 | char const *dirname; |
| @@ -555,7 +549,7 @@ the same file name is found in the `doc-directory'. */) | |||
| 555 | Vbuild_files = Fpurecopy (Vbuild_files); | 549 | Vbuild_files = Fpurecopy (Vbuild_files); |
| 556 | } | 550 | } |
| 557 | 551 | ||
| 558 | fd = doc_open (name, O_RDONLY, 0); | 552 | doc_fd fd = doc_open (name, O_RDONLY, 0); |
| 559 | if (!doc_fd_p (fd)) | 553 | if (!doc_fd_p (fd)) |
| 560 | { | 554 | { |
| 561 | int open_errno = errno; | 555 | int open_errno = errno; |
| @@ -568,8 +562,8 @@ the same file name is found in the `doc-directory'. */) | |||
| 568 | record_unwind_protect_ptr (close_file_unwind_android_fd, &fd); | 562 | record_unwind_protect_ptr (close_file_unwind_android_fd, &fd); |
| 569 | #endif /* !USE_ANDROID_ASSETS */ | 563 | #endif /* !USE_ANDROID_ASSETS */ |
| 570 | Vdoc_file_name = filename; | 564 | Vdoc_file_name = filename; |
| 571 | filled = 0; | 565 | int filled = 0; |
| 572 | pos = 0; | 566 | EMACS_INT pos = 0; |
| 573 | while (true) | 567 | while (true) |
| 574 | { | 568 | { |
| 575 | if (filled < 512) | 569 | if (filled < 512) |
| @@ -609,15 +603,13 @@ the same file name is found in the `doc-directory'. */) | |||
| 609 | /* Attach a docstring to a variable? */ | 603 | /* Attach a docstring to a variable? */ |
| 610 | if (p[1] == 'V') | 604 | if (p[1] == 'V') |
| 611 | { | 605 | { |
| 612 | /* Install file-position as variable-documentation property | 606 | /* Install file-position as variable-documentation |
| 613 | and make it negative for a user-variable | 607 | property. */ |
| 614 | (doc starts with a `*'). */ | ||
| 615 | if ((!NILP (Fboundp (sym)) | 608 | if ((!NILP (Fboundp (sym)) |
| 616 | || !NILP (Fmemq (sym, delayed_init))) | 609 | || !NILP (Fmemq (sym, delayed_init))) |
| 617 | && strncmp (end, "\nSKIP", 5)) | 610 | && strncmp (end, "\nSKIP", 5)) |
| 618 | Fput (sym, Qvariable_documentation, | 611 | Fput (sym, Qvariable_documentation, |
| 619 | make_fixnum ((pos + end + 1 - buf) | 612 | make_fixnum (pos + end + 1 - buf)); |
| 620 | * (end[1] == '*' ? -1 : 1))); | ||
| 621 | } | 613 | } |
| 622 | 614 | ||
| 623 | /* Attach a docstring to a function? */ | 615 | /* Attach a docstring to a function? */ |