aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.c
diff options
context:
space:
mode:
authorStefan Monnier2010-07-23 17:23:09 +0200
committerStefan Monnier2010-07-23 17:23:09 +0200
commit0ee81a0ce066375eac701c06cdfbdebefe594fdc (patch)
treef0dccd24163316cfe688f927681a3032a9b1fe2f /src/doc.c
parent894e369ddf48e191638b8e66ce732f24ff9abe2a (diff)
parent94da839793affa2a270bc26cee9c4d95d4dc4708 (diff)
downloademacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.tar.gz
emacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.zip
Merge from trunk
Diffstat (limited to 'src/doc.c')
-rw-r--r--src/doc.c55
1 files changed, 20 insertions, 35 deletions
diff --git a/src/doc.c b/src/doc.c
index 9133c2e6b84..5f4fe426da0 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -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
49extern char *index P_ ((const char *, int));
50#endif
51
52Lisp_Object Vdoc_file_name; 48Lisp_Object Vdoc_file_name;
53 49
54Lisp_Object Qfunction_documentation; 50Lisp_Object Qfunction_documentation;
@@ -65,14 +61,13 @@ static char *get_doc_string_buffer;
65static int get_doc_string_buffer_size; 61static int get_doc_string_buffer_size;
66 62
67static unsigned char *read_bytecode_pointer; 63static unsigned char *read_bytecode_pointer;
68Lisp_Object Fsnarf_documentation P_ ((Lisp_Object)); 64Lisp_Object Fsnarf_documentation (Lisp_Object);
69 65
70/* readchar in lread.c calls back here to fetch the next byte. 66/* readchar in lread.c calls back here to fetch the next byte.
71 If UNREADFLAG is 1, we unread a byte. */ 67 If UNREADFLAG is 1, we unread a byte. */
72 68
73int 69int
74read_bytecode_char (unreadflag) 70read_bytecode_char (int unreadflag)
75 int unreadflag;
76{ 71{
77 if (unreadflag) 72 if (unreadflag)
78 { 73 {
@@ -102,9 +97,7 @@ read_bytecode_char (unreadflag)
102 and return a cons cell. */ 97 and return a cons cell. */
103 98
104Lisp_Object 99Lisp_Object
105get_doc_string (filepos, unibyte, definition) 100get_doc_string (Lisp_Object filepos, int unibyte, int definition)
106 Lisp_Object filepos;
107 int unibyte, definition;
108{ 101{
109 char *from, *to; 102 char *from, *to;
110 register int fd; 103 register int fd;
@@ -221,9 +214,9 @@ get_doc_string (filepos, unibyte, definition)
221 if (!nread) 214 if (!nread)
222 break; 215 break;
223 if (p == get_doc_string_buffer) 216 if (p == get_doc_string_buffer)
224 p1 = (char *) index (p + offset, '\037'); 217 p1 = strchr (p + offset, '\037');
225 else 218 else
226 p1 = (char *) index (p, '\037'); 219 p1 = strchr (p, '\037');
227 if (p1) 220 if (p1)
228 { 221 {
229 *p1 = 0; 222 *p1 = 0;
@@ -311,15 +304,13 @@ get_doc_string (filepos, unibyte, definition)
311 of a compiled function from the .elc file. */ 304 of a compiled function from the .elc file. */
312 305
313Lisp_Object 306Lisp_Object
314read_doc_string (filepos) 307read_doc_string (Lisp_Object filepos)
315 Lisp_Object filepos;
316{ 308{
317 return get_doc_string (filepos, 0, 1); 309 return get_doc_string (filepos, 0, 1);
318} 310}
319 311
320static int 312static int
321reread_doc_file (file) 313reread_doc_file (Lisp_Object file)
322 Lisp_Object file;
323{ 314{
324#if 0 315#if 0
325 Lisp_Object reply, prompt[3]; 316 Lisp_Object reply, prompt[3];
@@ -346,8 +337,7 @@ DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0,
346 doc: /* Return the documentation string of FUNCTION. 337 doc: /* Return the documentation string of FUNCTION.
347Unless a non-nil second argument RAW is given, the 338Unless a non-nil second argument RAW is given, the
348string is passed through `substitute-command-keys'. */) 339string is passed through `substitute-command-keys'. */)
349 (function, raw) 340 (Lisp_Object function, Lisp_Object raw)
350 Lisp_Object function, raw;
351{ 341{
352 Lisp_Object fun; 342 Lisp_Object fun;
353 Lisp_Object funcar; 343 Lisp_Object funcar;
@@ -481,8 +471,7 @@ Third argument RAW omitted or nil means pass the result through
481This differs from `get' in that it can refer to strings stored in the 471This differs from `get' in that it can refer to strings stored in the
482`etc/DOC' file; and that it evaluates documentation properties that 472`etc/DOC' file; and that it evaluates documentation properties that
483aren't strings. */) 473aren't strings. */)
484 (symbol, prop, raw) 474 (Lisp_Object symbol, Lisp_Object prop, Lisp_Object raw)
485 Lisp_Object symbol, prop, raw;
486{ 475{
487 int try_reload = 1; 476 int try_reload = 1;
488 Lisp_Object tem; 477 Lisp_Object tem;
@@ -522,10 +511,8 @@ aren't strings. */)
522/* Scanning the DOC files and placing docstring offsets into functions. */ 511/* Scanning the DOC files and placing docstring offsets into functions. */
523 512
524static void 513static void
525store_function_docstring (fun, offset) 514store_function_docstring (Lisp_Object fun, EMACS_INT offset)
526 Lisp_Object fun; 515/* Use EMACS_INT because we get offset from pointer subtraction. */
527 /* Use EMACS_INT because we get this from pointer subtraction. */
528 EMACS_INT offset;
529{ 516{
530 fun = indirect_function (fun); 517 fun = indirect_function (fun);
531 518
@@ -574,8 +561,7 @@ The function takes one argument, FILENAME, a string;
574it specifies the file name (without a directory) of the DOC file. 561it specifies the file name (without a directory) of the DOC file.
575That file is found in `../etc' now; later, when the dumped Emacs is run, 562That file is found in `../etc' now; later, when the dumped Emacs is run,
576the same file name is found in the `doc-directory'. */) 563the same file name is found in the `doc-directory'. */)
577 (filename) 564 (Lisp_Object filename)
578 Lisp_Object filename;
579{ 565{
580 int fd; 566 int fd;
581 char buf[1024 + 1]; 567 char buf[1024 + 1];
@@ -652,7 +638,7 @@ the same file name is found in the `doc-directory'. */)
652 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */ 638 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */
653 if (p != end) 639 if (p != end)
654 { 640 {
655 end = (char *) index (p, '\n'); 641 end = strchr (p, '\n');
656 642
657 /* See if this is a file name, and if it is a file in build-files. */ 643 /* See if this is a file name, and if it is a file in build-files. */
658 if (p[1] == 'S' && end - p > 4 && end[-2] == '.' 644 if (p[1] == 'S' && end - p > 4 && end[-2] == '.'
@@ -702,7 +688,7 @@ the same file name is found in the `doc-directory'. */)
702 } 688 }
703 pos += end - buf; 689 pos += end - buf;
704 filled -= end - buf; 690 filled -= end - buf;
705 bcopy (end, buf, filled); 691 memcpy (buf, end, filled);
706 } 692 }
707 emacs_close (fd); 693 emacs_close (fd);
708 return Qnil; 694 return Qnil;
@@ -723,8 +709,7 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int
723 709
724Returns original STRING if no substitutions were made. Otherwise, 710Returns original STRING if no substitutions were made. Otherwise,
725a new string, without any text properties, is returned. */) 711a new string, without any text properties, is returned. */)
726 (string) 712 (Lisp_Object string)
727 Lisp_Object string;
728{ 713{
729 unsigned char *buf; 714 unsigned char *buf;
730 int changed = 0; 715 int changed = 0;
@@ -781,7 +766,7 @@ a new string, without any text properties, is returned. */)
781 if (len == 1) 766 if (len == 1)
782 *bufp = *strp; 767 *bufp = *strp;
783 else 768 else
784 bcopy (strp, bufp, len); 769 memcpy (bufp, strp, len);
785 strp += len; 770 strp += len;
786 bufp += len; 771 bufp += len;
787 nchars++; 772 nchars++;
@@ -833,7 +818,7 @@ a new string, without any text properties, is returned. */)
833 int offset = bufp - buf; 818 int offset = bufp - buf;
834 buf = (unsigned char *) xrealloc (buf, bsize += 4); 819 buf = (unsigned char *) xrealloc (buf, bsize += 4);
835 bufp = buf + offset; 820 bufp = buf + offset;
836 bcopy ("M-x ", bufp, 4); 821 memcpy (bufp, "M-x ", 4);
837 bufp += 4; 822 bufp += 4;
838 nchars += 4; 823 nchars += 4;
839 if (multibyte) 824 if (multibyte)
@@ -927,7 +912,7 @@ a new string, without any text properties, is returned. */)
927 int offset = bufp - buf; 912 int offset = bufp - buf;
928 buf = (unsigned char *) xrealloc (buf, bsize += length_byte); 913 buf = (unsigned char *) xrealloc (buf, bsize += length_byte);
929 bufp = buf + offset; 914 bufp = buf + offset;
930 bcopy (start, bufp, length_byte); 915 memcpy (bufp, start, length_byte);
931 bufp += length_byte; 916 bufp += length_byte;
932 nchars += length; 917 nchars += length;
933 /* Check STRING again in case gc relocated it. */ 918 /* Check STRING again in case gc relocated it. */
@@ -944,7 +929,7 @@ a new string, without any text properties, is returned. */)
944 if (len == 1) 929 if (len == 1)
945 *bufp = *strp; 930 *bufp = *strp;
946 else 931 else
947 bcopy (strp, bufp, len); 932 memcpy (bufp, strp, len);
948 strp += len; 933 strp += len;
949 bufp += len; 934 bufp += len;
950 nchars++; 935 nchars++;
@@ -960,7 +945,7 @@ a new string, without any text properties, is returned. */)
960} 945}
961 946
962void 947void
963syms_of_doc () 948syms_of_doc (void)
964{ 949{
965 Qfunction_documentation = intern_c_string ("function-documentation"); 950 Qfunction_documentation = intern_c_string ("function-documentation");
966 staticpro (&Qfunction_documentation); 951 staticpro (&Qfunction_documentation);