diff options
Diffstat (limited to 'src/doc.c')
-rw-r--r-- | src/doc.c | 109 |
1 files changed, 41 insertions, 68 deletions
diff --git a/src/doc.c b/src/doc.c index 9b72b17cffa..ab4d401d616 100644 --- a/src/doc.c +++ b/src/doc.c @@ -25,19 +25,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/file.h> /* Must be after sys/types.h for USG*/ #include <ctype.h> #include <setjmp.h> - -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif - #include "lisp.h" #include "buffer.h" #include "keyboard.h" @@ -45,10 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "keymap.h" #include "buildobj.h" -#ifdef HAVE_INDEX -extern char *index P_ ((const char *, int)); -#endif - Lisp_Object Vdoc_file_name; Lisp_Object Qfunction_documentation; @@ -56,23 +45,18 @@ Lisp_Object Qfunction_documentation; /* A list of files used to build this Emacs binary. */ static Lisp_Object Vbuild_files; -extern Lisp_Object Voverriding_local_map; - -extern Lisp_Object Qremap; - /* Buffer used for reading from documentation file. */ static char *get_doc_string_buffer; static int get_doc_string_buffer_size; static unsigned char *read_bytecode_pointer; -Lisp_Object Fsnarf_documentation P_ ((Lisp_Object)); +Lisp_Object Fsnarf_documentation (Lisp_Object); /* readchar in lread.c calls back here to fetch the next byte. If UNREADFLAG is 1, we unread a byte. */ int -read_bytecode_char (unreadflag) - int unreadflag; +read_bytecode_char (int unreadflag) { if (unreadflag) { @@ -102,16 +86,14 @@ read_bytecode_char (unreadflag) and return a cons cell. */ Lisp_Object -get_doc_string (filepos, unibyte, definition) - Lisp_Object filepos; - int unibyte, definition; +get_doc_string (Lisp_Object filepos, int unibyte, int definition) { char *from, *to; register int fd; register char *name; register char *p, *p1; - int minsize; - int offset, position; + EMACS_INT minsize; + EMACS_INT offset, position; Lisp_Object file, tem; if (INTEGERP (filepos)) @@ -190,14 +172,14 @@ get_doc_string (filepos, unibyte, definition) p = get_doc_string_buffer; while (1) { - int space_left = (get_doc_string_buffer_size - - (p - get_doc_string_buffer)); + EMACS_INT space_left = (get_doc_string_buffer_size + - (p - get_doc_string_buffer)); int nread; /* Allocate or grow the buffer if we need to. */ if (space_left == 0) { - int in_buffer = p - get_doc_string_buffer; + EMACS_INT in_buffer = p - get_doc_string_buffer; get_doc_string_buffer_size += 16 * 1024; get_doc_string_buffer = (char *) xrealloc (get_doc_string_buffer, @@ -221,9 +203,9 @@ get_doc_string (filepos, unibyte, definition) if (!nread) break; if (p == get_doc_string_buffer) - p1 = (char *) index (p + offset, '\037'); + p1 = strchr (p + offset, '\037'); else - p1 = (char *) index (p, '\037'); + p1 = strchr (p, '\037'); if (p1) { *p1 = 0; @@ -296,10 +278,9 @@ get_doc_string (filepos, unibyte, definition) to - (get_doc_string_buffer + offset)); else { - /* Let the data determine whether the string is multibyte, - even if Emacs is running in --unibyte mode. */ - int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, - to - (get_doc_string_buffer + offset)); + /* The data determines whether the string is multibyte. */ + EMACS_INT nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, + to - (get_doc_string_buffer + offset)); return make_string_from_bytes (get_doc_string_buffer + offset, nchars, to - (get_doc_string_buffer + offset)); @@ -311,15 +292,13 @@ get_doc_string (filepos, unibyte, definition) of a compiled function from the .elc file. */ Lisp_Object -read_doc_string (filepos) - Lisp_Object filepos; +read_doc_string (Lisp_Object filepos) { return get_doc_string (filepos, 0, 1); } static int -reread_doc_file (file) - Lisp_Object file; +reread_doc_file (Lisp_Object file) { #if 0 Lisp_Object reply, prompt[3]; @@ -346,8 +325,7 @@ DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, doc: /* Return the documentation string of FUNCTION. Unless a non-nil second argument RAW is given, the string is passed through `substitute-command-keys'. */) - (function, raw) - Lisp_Object function, raw; + (Lisp_Object function, Lisp_Object raw) { Lisp_Object fun; Lisp_Object funcar; @@ -474,8 +452,7 @@ Third argument RAW omitted or nil means pass the result through This differs from `get' in that it can refer to strings stored in the `etc/DOC' file; and that it evaluates documentation properties that aren't strings. */) - (symbol, prop, raw) - Lisp_Object symbol, prop, raw; + (Lisp_Object symbol, Lisp_Object prop, Lisp_Object raw) { int try_reload = 1; Lisp_Object tem; @@ -515,10 +492,8 @@ aren't strings. */) /* Scanning the DOC files and placing docstring offsets into functions. */ static void -store_function_docstring (fun, offset) - Lisp_Object fun; - /* Use EMACS_INT because we get this from pointer subtraction. */ - EMACS_INT offset; +store_function_docstring (Lisp_Object fun, EMACS_INT offset) +/* Use EMACS_INT because we get offset from pointer subtraction. */ { fun = indirect_function (fun); @@ -538,7 +513,7 @@ store_function_docstring (fun, offset) { tem = Fcdr (Fcdr (fun)); if (CONSP (tem) && INTEGERP (XCAR (tem))) - XSETCARFASTINT (tem, offset); + XSETCAR (tem, make_number (offset)); } else if (EQ (tem, Qmacro)) store_function_docstring (XCDR (fun), offset); @@ -565,13 +540,12 @@ The function takes one argument, FILENAME, a string; it specifies the file name (without a directory) of the DOC file. That file is found in `../etc' now; later, when the dumped Emacs is run, the same file name is found in the `doc-directory'. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { int fd; char buf[1024 + 1]; - register int filled; - register int pos; + register EMACS_INT filled; + register EMACS_INT pos; register char *p, *end; Lisp_Object sym; char *name; @@ -605,7 +579,7 @@ the same file name is found in the `doc-directory'. */) for (beg = buildobj; *beg; beg = end) { - int len; + EMACS_INT len; while (*beg && isspace (*beg)) ++beg; @@ -643,7 +617,7 @@ the same file name is found in the `doc-directory'. */) /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */ if (p != end) { - end = (char *) index (p, '\n'); + end = strchr (p, '\n'); /* See if this is a file name, and if it is a file in build-files. */ if (p[1] == 'S') @@ -652,7 +626,7 @@ the same file name is found in the `doc-directory'. */) if (end - p > 4 && end[-2] == '.' && (end[-1] == 'o' || end[-1] == 'c')) { - int len = end - p - 2; + EMACS_INT len = end - p - 2; char *fromfile = alloca (len + 1); strncpy (fromfile, &p[2], len); fromfile[len] = 0; @@ -697,7 +671,7 @@ the same file name is found in the `doc-directory'. */) } pos += end - buf; filled -= end - buf; - bcopy (end, buf, filled); + memmove (buf, end, filled); } emacs_close (fd); return Qnil; @@ -718,23 +692,22 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int Returns original STRING if no substitutions were made. Otherwise, a new string, without any text properties, is returned. */) - (string) - Lisp_Object string; + (Lisp_Object string) { unsigned char *buf; int changed = 0; register unsigned char *strp; register unsigned char *bufp; - int idx; - int bsize; + EMACS_INT idx; + EMACS_INT bsize; Lisp_Object tem; Lisp_Object keymap; unsigned char *start; - int length, length_byte; + EMACS_INT length, length_byte; Lisp_Object name; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; int multibyte; - int nchars; + EMACS_INT nchars; if (NILP (string)) return Qnil; @@ -776,7 +749,7 @@ a new string, without any text properties, is returned. */) if (len == 1) *bufp = *strp; else - bcopy (strp, bufp, len); + memcpy (bufp, strp, len); strp += len; bufp += len; nchars++; @@ -786,7 +759,7 @@ a new string, without any text properties, is returned. */) } else if (strp[0] == '\\' && strp[1] == '[') { - int start_idx; + EMACS_INT start_idx; int follow_remap = 1; changed = 1; @@ -825,10 +798,10 @@ a new string, without any text properties, is returned. */) if (NILP (tem)) /* but not on any keys */ { - int offset = bufp - buf; + EMACS_INT offset = bufp - buf; buf = (unsigned char *) xrealloc (buf, bsize += 4); bufp = buf + offset; - bcopy ("M-x ", bufp, 4); + memcpy (bufp, "M-x ", 4); bufp += 4; nchars += 4; if (multibyte) @@ -848,7 +821,7 @@ a new string, without any text properties, is returned. */) else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<')) { struct buffer *oldbuf; - int start_idx; + EMACS_INT start_idx; /* This is for computing the SHADOWS arg for describe_map_tree. */ Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil); Lisp_Object earlier_maps; @@ -919,10 +892,10 @@ a new string, without any text properties, is returned. */) length_byte = SBYTES (tem); subst: { - int offset = bufp - buf; + EMACS_INT offset = bufp - buf; buf = (unsigned char *) xrealloc (buf, bsize += length_byte); bufp = buf + offset; - bcopy (start, bufp, length_byte); + memcpy (bufp, start, length_byte); bufp += length_byte; nchars += length; /* Check STRING again in case gc relocated it. */ @@ -939,7 +912,7 @@ a new string, without any text properties, is returned. */) if (len == 1) *bufp = *strp; else - bcopy (strp, bufp, len); + memcpy (bufp, strp, len); strp += len; bufp += len; nchars++; @@ -955,7 +928,7 @@ a new string, without any text properties, is returned. */) } void -syms_of_doc () +syms_of_doc (void) { Qfunction_documentation = intern_c_string ("function-documentation"); staticpro (&Qfunction_documentation); |