diff options
Diffstat (limited to 'src/doc.c')
| -rw-r--r-- | src/doc.c | 90 |
1 files changed, 37 insertions, 53 deletions
| @@ -45,10 +45,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 45 | #include "keymap.h" | 45 | #include "keymap.h" |
| 46 | #include "buildobj.h" | 46 | #include "buildobj.h" |
| 47 | 47 | ||
| 48 | #ifdef HAVE_INDEX | ||
| 49 | extern char *index P_ ((const char *, int)); | ||
| 50 | #endif | ||
| 51 | |||
| 52 | Lisp_Object Vdoc_file_name; | 48 | Lisp_Object Vdoc_file_name; |
| 53 | 49 | ||
| 54 | Lisp_Object Qfunction_documentation; | 50 | Lisp_Object Qfunction_documentation; |
| @@ -56,23 +52,18 @@ Lisp_Object Qfunction_documentation; | |||
| 56 | /* A list of files used to build this Emacs binary. */ | 52 | /* A list of files used to build this Emacs binary. */ |
| 57 | static Lisp_Object Vbuild_files; | 53 | static Lisp_Object Vbuild_files; |
| 58 | 54 | ||
| 59 | extern Lisp_Object Voverriding_local_map; | ||
| 60 | |||
| 61 | extern Lisp_Object Qremap; | ||
| 62 | |||
| 63 | /* Buffer used for reading from documentation file. */ | 55 | /* Buffer used for reading from documentation file. */ |
| 64 | static char *get_doc_string_buffer; | 56 | static char *get_doc_string_buffer; |
| 65 | static int get_doc_string_buffer_size; | 57 | static int get_doc_string_buffer_size; |
| 66 | 58 | ||
| 67 | static unsigned char *read_bytecode_pointer; | 59 | static unsigned char *read_bytecode_pointer; |
| 68 | Lisp_Object Fsnarf_documentation P_ ((Lisp_Object)); | 60 | Lisp_Object Fsnarf_documentation (Lisp_Object); |
| 69 | 61 | ||
| 70 | /* readchar in lread.c calls back here to fetch the next byte. | 62 | /* readchar in lread.c calls back here to fetch the next byte. |
| 71 | If UNREADFLAG is 1, we unread a byte. */ | 63 | If UNREADFLAG is 1, we unread a byte. */ |
| 72 | 64 | ||
| 73 | int | 65 | int |
| 74 | read_bytecode_char (unreadflag) | 66 | read_bytecode_char (int unreadflag) |
| 75 | int unreadflag; | ||
| 76 | { | 67 | { |
| 77 | if (unreadflag) | 68 | if (unreadflag) |
| 78 | { | 69 | { |
| @@ -102,9 +93,7 @@ read_bytecode_char (unreadflag) | |||
| 102 | and return a cons cell. */ | 93 | and return a cons cell. */ |
| 103 | 94 | ||
| 104 | Lisp_Object | 95 | Lisp_Object |
| 105 | get_doc_string (filepos, unibyte, definition) | 96 | get_doc_string (Lisp_Object filepos, int unibyte, int definition) |
| 106 | Lisp_Object filepos; | ||
| 107 | int unibyte, definition; | ||
| 108 | { | 97 | { |
| 109 | char *from, *to; | 98 | char *from, *to; |
| 110 | register int fd; | 99 | register int fd; |
| @@ -221,9 +210,9 @@ get_doc_string (filepos, unibyte, definition) | |||
| 221 | if (!nread) | 210 | if (!nread) |
| 222 | break; | 211 | break; |
| 223 | if (p == get_doc_string_buffer) | 212 | if (p == get_doc_string_buffer) |
| 224 | p1 = (char *) index (p + offset, '\037'); | 213 | p1 = strchr (p + offset, '\037'); |
| 225 | else | 214 | else |
| 226 | p1 = (char *) index (p, '\037'); | 215 | p1 = strchr (p, '\037'); |
| 227 | if (p1) | 216 | if (p1) |
| 228 | { | 217 | { |
| 229 | *p1 = 0; | 218 | *p1 = 0; |
| @@ -296,8 +285,7 @@ get_doc_string (filepos, unibyte, definition) | |||
| 296 | to - (get_doc_string_buffer + offset)); | 285 | to - (get_doc_string_buffer + offset)); |
| 297 | else | 286 | else |
| 298 | { | 287 | { |
| 299 | /* Let the data determine whether the string is multibyte, | 288 | /* The data determines whether the string is multibyte. */ |
| 300 | even if Emacs is running in --unibyte mode. */ | ||
| 301 | int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, | 289 | int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, |
| 302 | to - (get_doc_string_buffer + offset)); | 290 | to - (get_doc_string_buffer + offset)); |
| 303 | return make_string_from_bytes (get_doc_string_buffer + offset, | 291 | return make_string_from_bytes (get_doc_string_buffer + offset, |
| @@ -311,15 +299,13 @@ get_doc_string (filepos, unibyte, definition) | |||
| 311 | of a compiled function from the .elc file. */ | 299 | of a compiled function from the .elc file. */ |
| 312 | 300 | ||
| 313 | Lisp_Object | 301 | Lisp_Object |
| 314 | read_doc_string (filepos) | 302 | read_doc_string (Lisp_Object filepos) |
| 315 | Lisp_Object filepos; | ||
| 316 | { | 303 | { |
| 317 | return get_doc_string (filepos, 0, 1); | 304 | return get_doc_string (filepos, 0, 1); |
| 318 | } | 305 | } |
| 319 | 306 | ||
| 320 | static int | 307 | static int |
| 321 | reread_doc_file (file) | 308 | reread_doc_file (Lisp_Object file) |
| 322 | Lisp_Object file; | ||
| 323 | { | 309 | { |
| 324 | #if 0 | 310 | #if 0 |
| 325 | Lisp_Object reply, prompt[3]; | 311 | Lisp_Object reply, prompt[3]; |
| @@ -346,8 +332,7 @@ DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, | |||
| 346 | doc: /* Return the documentation string of FUNCTION. | 332 | doc: /* Return the documentation string of FUNCTION. |
| 347 | Unless a non-nil second argument RAW is given, the | 333 | Unless a non-nil second argument RAW is given, the |
| 348 | string is passed through `substitute-command-keys'. */) | 334 | string is passed through `substitute-command-keys'. */) |
| 349 | (function, raw) | 335 | (Lisp_Object function, Lisp_Object raw) |
| 350 | Lisp_Object function, raw; | ||
| 351 | { | 336 | { |
| 352 | Lisp_Object fun; | 337 | Lisp_Object fun; |
| 353 | Lisp_Object funcar; | 338 | Lisp_Object funcar; |
| @@ -474,8 +459,7 @@ Third argument RAW omitted or nil means pass the result through | |||
| 474 | This differs from `get' in that it can refer to strings stored in the | 459 | This differs from `get' in that it can refer to strings stored in the |
| 475 | `etc/DOC' file; and that it evaluates documentation properties that | 460 | `etc/DOC' file; and that it evaluates documentation properties that |
| 476 | aren't strings. */) | 461 | aren't strings. */) |
| 477 | (symbol, prop, raw) | 462 | (Lisp_Object symbol, Lisp_Object prop, Lisp_Object raw) |
| 478 | Lisp_Object symbol, prop, raw; | ||
| 479 | { | 463 | { |
| 480 | int try_reload = 1; | 464 | int try_reload = 1; |
| 481 | Lisp_Object tem; | 465 | Lisp_Object tem; |
| @@ -515,10 +499,8 @@ aren't strings. */) | |||
| 515 | /* Scanning the DOC files and placing docstring offsets into functions. */ | 499 | /* Scanning the DOC files and placing docstring offsets into functions. */ |
| 516 | 500 | ||
| 517 | static void | 501 | static void |
| 518 | store_function_docstring (fun, offset) | 502 | store_function_docstring (Lisp_Object fun, EMACS_INT offset) |
| 519 | Lisp_Object fun; | 503 | /* Use EMACS_INT because we get offset from pointer subtraction. */ |
| 520 | /* Use EMACS_INT because we get this from pointer subtraction. */ | ||
| 521 | EMACS_INT offset; | ||
| 522 | { | 504 | { |
| 523 | fun = indirect_function (fun); | 505 | fun = indirect_function (fun); |
| 524 | 506 | ||
| @@ -565,8 +547,7 @@ The function takes one argument, FILENAME, a string; | |||
| 565 | it specifies the file name (without a directory) of the DOC file. | 547 | it specifies the file name (without a directory) of the DOC file. |
| 566 | That file is found in `../etc' now; later, when the dumped Emacs is run, | 548 | That file is found in `../etc' now; later, when the dumped Emacs is run, |
| 567 | the same file name is found in the `doc-directory'. */) | 549 | the same file name is found in the `doc-directory'. */) |
| 568 | (filename) | 550 | (Lisp_Object filename) |
| 569 | Lisp_Object filename; | ||
| 570 | { | 551 | { |
| 571 | int fd; | 552 | int fd; |
| 572 | char buf[1024 + 1]; | 553 | char buf[1024 + 1]; |
| @@ -640,24 +621,28 @@ the same file name is found in the `doc-directory'. */) | |||
| 640 | p = buf; | 621 | p = buf; |
| 641 | end = buf + (filled < 512 ? filled : filled - 128); | 622 | end = buf + (filled < 512 ? filled : filled - 128); |
| 642 | while (p != end && *p != '\037') p++; | 623 | while (p != end && *p != '\037') p++; |
| 643 | /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */ | 624 | /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */ |
| 644 | if (p != end) | 625 | if (p != end) |
| 645 | { | 626 | { |
| 646 | end = (char *) index (p, '\n'); | 627 | end = strchr (p, '\n'); |
| 647 | 628 | ||
| 648 | /* See if this is a file name, and if it is a file in build-files. */ | 629 | /* See if this is a file name, and if it is a file in build-files. */ |
| 649 | if (p[1] == 'S' && end - p > 4 && end[-2] == '.' | 630 | if (p[1] == 'S') |
| 650 | && (end[-1] == 'o' || end[-1] == 'c')) | ||
| 651 | { | 631 | { |
| 652 | int len = end - p - 2; | 632 | skip_file = 0; |
| 653 | char *fromfile = alloca (len + 1); | 633 | if (end - p > 4 && end[-2] == '.' |
| 654 | strncpy (fromfile, &p[2], len); | 634 | && (end[-1] == 'o' || end[-1] == 'c')) |
| 655 | fromfile[len] = 0; | 635 | { |
| 656 | if (fromfile[len-1] == 'c') | 636 | int len = end - p - 2; |
| 657 | fromfile[len-1] = 'o'; | 637 | char *fromfile = alloca (len + 1); |
| 658 | 638 | strncpy (fromfile, &p[2], len); | |
| 659 | skip_file = NILP (Fmember (build_string (fromfile), | 639 | fromfile[len] = 0; |
| 660 | Vbuild_files)); | 640 | if (fromfile[len-1] == 'c') |
| 641 | fromfile[len-1] = 'o'; | ||
| 642 | |||
| 643 | skip_file = NILP (Fmember (build_string (fromfile), | ||
| 644 | Vbuild_files)); | ||
| 645 | } | ||
| 661 | } | 646 | } |
| 662 | 647 | ||
| 663 | sym = oblookup (Vobarray, p + 2, | 648 | sym = oblookup (Vobarray, p + 2, |
| @@ -693,7 +678,7 @@ the same file name is found in the `doc-directory'. */) | |||
| 693 | } | 678 | } |
| 694 | pos += end - buf; | 679 | pos += end - buf; |
| 695 | filled -= end - buf; | 680 | filled -= end - buf; |
| 696 | bcopy (end, buf, filled); | 681 | memcpy (buf, end, filled); |
| 697 | } | 682 | } |
| 698 | emacs_close (fd); | 683 | emacs_close (fd); |
| 699 | return Qnil; | 684 | return Qnil; |
| @@ -714,8 +699,7 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int | |||
| 714 | 699 | ||
| 715 | Returns original STRING if no substitutions were made. Otherwise, | 700 | Returns original STRING if no substitutions were made. Otherwise, |
| 716 | a new string, without any text properties, is returned. */) | 701 | a new string, without any text properties, is returned. */) |
| 717 | (string) | 702 | (Lisp_Object string) |
| 718 | Lisp_Object string; | ||
| 719 | { | 703 | { |
| 720 | unsigned char *buf; | 704 | unsigned char *buf; |
| 721 | int changed = 0; | 705 | int changed = 0; |
| @@ -772,7 +756,7 @@ a new string, without any text properties, is returned. */) | |||
| 772 | if (len == 1) | 756 | if (len == 1) |
| 773 | *bufp = *strp; | 757 | *bufp = *strp; |
| 774 | else | 758 | else |
| 775 | bcopy (strp, bufp, len); | 759 | memcpy (bufp, strp, len); |
| 776 | strp += len; | 760 | strp += len; |
| 777 | bufp += len; | 761 | bufp += len; |
| 778 | nchars++; | 762 | nchars++; |
| @@ -824,7 +808,7 @@ a new string, without any text properties, is returned. */) | |||
| 824 | int offset = bufp - buf; | 808 | int offset = bufp - buf; |
| 825 | buf = (unsigned char *) xrealloc (buf, bsize += 4); | 809 | buf = (unsigned char *) xrealloc (buf, bsize += 4); |
| 826 | bufp = buf + offset; | 810 | bufp = buf + offset; |
| 827 | bcopy ("M-x ", bufp, 4); | 811 | memcpy (bufp, "M-x ", 4); |
| 828 | bufp += 4; | 812 | bufp += 4; |
| 829 | nchars += 4; | 813 | nchars += 4; |
| 830 | if (multibyte) | 814 | if (multibyte) |
| @@ -918,7 +902,7 @@ a new string, without any text properties, is returned. */) | |||
| 918 | int offset = bufp - buf; | 902 | int offset = bufp - buf; |
| 919 | buf = (unsigned char *) xrealloc (buf, bsize += length_byte); | 903 | buf = (unsigned char *) xrealloc (buf, bsize += length_byte); |
| 920 | bufp = buf + offset; | 904 | bufp = buf + offset; |
| 921 | bcopy (start, bufp, length_byte); | 905 | memcpy (bufp, start, length_byte); |
| 922 | bufp += length_byte; | 906 | bufp += length_byte; |
| 923 | nchars += length; | 907 | nchars += length; |
| 924 | /* Check STRING again in case gc relocated it. */ | 908 | /* Check STRING again in case gc relocated it. */ |
| @@ -935,7 +919,7 @@ a new string, without any text properties, is returned. */) | |||
| 935 | if (len == 1) | 919 | if (len == 1) |
| 936 | *bufp = *strp; | 920 | *bufp = *strp; |
| 937 | else | 921 | else |
| 938 | bcopy (strp, bufp, len); | 922 | memcpy (bufp, strp, len); |
| 939 | strp += len; | 923 | strp += len; |
| 940 | bufp += len; | 924 | bufp += len; |
| 941 | nchars++; | 925 | nchars++; |
| @@ -951,7 +935,7 @@ a new string, without any text properties, is returned. */) | |||
| 951 | } | 935 | } |
| 952 | 936 | ||
| 953 | void | 937 | void |
| 954 | syms_of_doc () | 938 | syms_of_doc (void) |
| 955 | { | 939 | { |
| 956 | Qfunction_documentation = intern_c_string ("function-documentation"); | 940 | Qfunction_documentation = intern_c_string ("function-documentation"); |
| 957 | staticpro (&Qfunction_documentation); | 941 | staticpro (&Qfunction_documentation); |