X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/f3bbbd11451643c49997116d639612ae434dcaa0..14fe7b530dc927a88169a841afc0cd806593dea8:/src/doc.c diff --git a/src/doc.c b/src/doc.c index ecb0197b3c..d22c3bf872 100644 --- a/src/doc.c +++ b/src/doc.c @@ -1,13 +1,14 @@ /* Record indices of function doc strings stored in a file. Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. This file is part of GNU Emacs. -GNU Emacs is free software; you can redistribute it and/or modify +GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,16 +16,15 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ +along with GNU Emacs. If not, see . */ #include #include -#include /* Must be after sys/types.h for USG and BSD4_1*/ +#include /* Must be after sys/types.h for USG*/ #include +#include #ifdef HAVE_FCNTL_H #include @@ -43,6 +43,7 @@ Boston, MA 02110-1301, USA. */ #include "keyboard.h" #include "character.h" #include "keymap.h" +#include "buildobj.h" #ifdef HAVE_INDEX extern char *index P_ ((const char *, int)); @@ -59,28 +60,6 @@ extern Lisp_Object Voverriding_local_map; extern Lisp_Object Qremap; -/* For VMS versions with limited file name syntax, - convert the name to something VMS will allow. */ -static void -munge_doc_file_name (name) - char *name; -{ -#ifdef VMS -#ifndef NO_HYPHENS_IN_FILENAMES - extern char * sys_translate_unix (char *ufile); - strcpy (name, sys_translate_unix (name)); -#else /* NO_HYPHENS_IN_FILENAMES */ - char *p = name; - while (*p) - { - if (*p == '-') - *p = '_'; - p++; - } -#endif /* NO_HYPHENS_IN_FILENAMES */ -#endif /* VMS */ -} - /* Buffer used for reading from documentation file. */ static char *get_doc_string_buffer; static int get_doc_string_buffer_size; @@ -170,7 +149,6 @@ get_doc_string (filepos, unibyte, definition) name = (char *) alloca (minsize + SCHARS (file) + 8); strcpy (name, SDATA (Vdoc_directory)); strcat (name, SDATA (file)); - munge_doc_file_name (name); } else { @@ -187,7 +165,6 @@ get_doc_string (filepos, unibyte, definition) So check in ../etc. */ strcpy (name, "../etc/"); strcat (name, SDATA (file)); - munge_doc_file_name (name); fd = emacs_open (name, O_RDONLY, 0); } @@ -446,6 +423,18 @@ string is passed through `substitute-command-keys'. */) xsignal1 (Qinvalid_function, fun); } + /* Check for an advised function. Its doc string + has an `ad-advice-info' text property. */ + if (STRINGP (doc)) + { + Lisp_Object innerfunc; + innerfunc = Fget_text_property (make_number (0), + intern ("ad-advice-info"), + doc); + if (! NILP (innerfunc)) + doc = call1 (intern ("ad-make-advised-docstring"), innerfunc); + } + /* If DOC is 0, it's typically because of a dumped file missing from the DOC file (bug in src/Makefile.in). */ if (EQ (doc, make_number (0))) @@ -561,10 +550,11 @@ store_function_docstring (fun, offset) /* This bytecode object must have a slot for the docstring, since we've found a docstring for it. */ if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) - XSETFASTINT (AREF (fun, COMPILED_DOC_STRING), offset); + ASET (fun, COMPILED_DOC_STRING, make_number (offset)); } } +static const char buildobj[] = BUILDOBJ; DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation, 1, 1, 0, @@ -607,37 +597,13 @@ the same file name is found in the `doc-directory'. */) strcpy (name, SDATA (Vdoc_directory)); } strcat (name, SDATA (filename)); /*** Add this line ***/ - munge_doc_file_name (name); /* Vbuild_files is nil when temacs is run, and non-nil after that. */ if (NILP (Vbuild_files)) { - size_t cp_size = 0; - size_t to_read; - int nr_read; - char *cp = NULL; - char *beg, *end; - - fd = emacs_open ("buildobj.lst", O_RDONLY, 0); - if (fd < 0) - report_file_error ("Opening file buildobj.lst", Qnil); - - filled = 0; - for (;;) - { - cp_size += 1024; - to_read = cp_size - 1 - filled; - cp = xrealloc (cp, cp_size); - nr_read = emacs_read (fd, &cp[filled], to_read); - filled += nr_read; - if (nr_read < to_read) - break; - } - - emacs_close (fd); - cp[filled] = 0; + const char *beg, *end; - for (beg = cp; *beg; beg = end) + for (beg = buildobj; *beg; beg = end) { int len; @@ -653,8 +619,7 @@ the same file name is found in the `doc-directory'. */) if (len > 0) Vbuild_files = Fcons (make_string (beg, len), Vbuild_files); } - - xfree (cp); + Vbuild_files = Fpurecopy (Vbuild_files); } fd = emacs_open (name, O_RDONLY, 0); @@ -675,31 +640,37 @@ the same file name is found in the `doc-directory'. */) p = buf; end = buf + (filled < 512 ? filled : filled - 128); while (p != end && *p != '\037') p++; - /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */ + /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */ if (p != end) { end = (char *) index (p, '\n'); /* See if this is a file name, and if it is a file in build-files. */ - if (p[1] == 'S' && end - p > 4 && end[-2] == '.' - && (end[-1] == 'o' || end[-1] == 'c')) + if (p[1] == 'S') { - int len = end - p - 2; - char *fromfile = alloca (len + 1); - strncpy (fromfile, &p[2], len); - fromfile[len] = 0; - if (fromfile[len-1] == 'c') - fromfile[len-1] = 'o'; - - if (EQ (Fmember (build_string (fromfile), Vbuild_files), Qnil)) - skip_file = 1; - else - skip_file = 0; + skip_file = 0; + if (end - p > 4 && end[-2] == '.' + && (end[-1] == 'o' || end[-1] == 'c')) + { + int len = end - p - 2; + char *fromfile = alloca (len + 1); + strncpy (fromfile, &p[2], len); + fromfile[len] = 0; + if (fromfile[len-1] == 'c') + fromfile[len-1] = 'o'; + + skip_file = NILP (Fmember (build_string (fromfile), + Vbuild_files)); + } } sym = oblookup (Vobarray, p + 2, multibyte_chars_in_text (p + 2, end - p - 2), end - p - 2); + /* Check skip_file so that when a function is defined several + times in different files (typically, once in xterm, once in + w32term, ...), we only pay attention to the one that + matters. */ if (! skip_file && SYMBOLP (sym)) { /* Attach a docstring to a variable? */ @@ -745,7 +716,7 @@ as the keymap for future \\=\\[COMMAND] substrings. \\=\\= quotes the following character and is discarded; thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output. -Returns original STRING if no substitutions were made. Othwerwise, +Returns original STRING if no substitutions were made. Otherwise, a new string, without any text properties, is returned. */) (string) Lisp_Object string; @@ -800,9 +771,8 @@ a new string, without any text properties, is returned. */) if (multibyte) { int len; - int maxlen = SDATA (string) + SBYTES (string) - strp; - STRING_CHAR_AND_LENGTH (strp, maxlen, len); + STRING_CHAR_AND_LENGTH (strp, len); if (len == 1) *bufp = *strp; else @@ -837,12 +807,9 @@ a new string, without any text properties, is returned. */) name = Fintern (make_string (start, length_byte), Qnil); do_remap: - /* Ignore remappings unless there are no ordinary bindings. */ - tem = Fwhere_is_internal (name, keymap, Qt, Qnil, Qt); - if (NILP (tem)) - tem = Fwhere_is_internal (name, keymap, Qt, Qnil, Qnil); + tem = Fwhere_is_internal (name, keymap, Qt, Qnil, Qnil); - if (VECTORP (tem) && XVECTOR (tem)->size > 1 + if (VECTORP (tem) && XVECTOR_SIZE (tem) > 1 && EQ (AREF (tem, 0), Qremap) && SYMBOLP (AREF (tem, 1)) && follow_remap) { @@ -883,7 +850,7 @@ a new string, without any text properties, is returned. */) struct buffer *oldbuf; int start_idx; /* This is for computing the SHADOWS arg for describe_map_tree. */ - Lisp_Object active_maps = Fcurrent_active_maps (Qnil); + Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil); Lisp_Object earlier_maps; changed = 1; @@ -967,9 +934,8 @@ a new string, without any text properties, is returned. */) else { int len; - int maxlen = SDATA (string) + SBYTES (string) - strp; - STRING_CHAR_AND_LENGTH (strp, maxlen, len); + STRING_CHAR_AND_LENGTH (strp, len); if (len == 1) *bufp = *strp; else @@ -991,7 +957,7 @@ a new string, without any text properties, is returned. */) void syms_of_doc () { - Qfunction_documentation = intern ("function-documentation"); + Qfunction_documentation = intern_c_string ("function-documentation"); staticpro (&Qfunction_documentation); DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name,