emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DOC for Mac OS shown for Emacs compiled for X.


From: Jan D.
Subject: Re: DOC for Mac OS shown for Emacs compiled for X.
Date: Mon, 01 Nov 2004 09:47:29 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040916

Richard Stallman wrote:
    Then we need to include symbols from all w32 files also.

To make it fully platform-independent, that is necessary.

But the patch doesn't make the DOC file dependent on platform, it just makes the Emacs binary selective of what it reads from it.

I did not realize that.  In that case, I take back what I said.
However, what does the patch do?  There is nothing in the DOC file
that says what file each doc string was read from.

The ^_S markers in the DOC file shows the file from where the following doc-strings came from. They where introduced on April 7, (revision 1.57 of lib-src/make-docfile.c), presumably to support the link when a function/variable is "defined in C source file".

The patch has been somewhat updated since I posted it last, so I add it again. Here what it does:

1. When temacs is linked, output the object file names used to link it to buildobj.lst.
2. A new variable Vbuild_files is declared in doc.c, initialize to nil.
3. When temacs is run, Snarf_documentation checks if Vbuild_files is nil, and if it is, reads buildobj.lst and inserts the file names into Vbuild_files as a list. 4. When looking for pointers to doc strings, Snarf_documentation skips strings that belongs to a file not in Vbuild_list. 5. The function in help-fns.el that finds C files also skips files not in build-files.

The patch still does not work on W32/msdos, because from what I understand the file names in DOC for those platforms are the .c files, not the .o files. Plus the fact that the buildobj.lst file would contain .obj extensions instead of .o.

        Jan D.


diff -c src/Makefile.in.~1.303.~ src/Makefile.in
Index: src/Makefile.in
*** src/Makefile.in.~1.303.~    2004-10-20 17:44:02.000000000 +0200
--- src/Makefile.in     2004-10-30 19:46:52.000000000 +0200
***************
*** 943,949 ****
  #define MAKE_PARALLEL
  #endif
  
! temacs${EXEEXT}: MAKE_PARALLEL $(LOCALCPP) $(STARTFILES) stamp-oldxmenu 
${obj} ${otherobj} OBJECTS_MACHINE prefix-args${EXEEXT}
        $(LD) YMF_PASS_LDFLAGS (${STARTFLAGS} ${TEMACS_LDFLAGS}) $(LDFLAGS) \
      -o temacs ${STARTFILES} ${obj} ${otherobj}  \
      OBJECTS_MACHINE ${LIBES}
--- 943,950 ----
  #define MAKE_PARALLEL
  #endif
  
! temacs${EXEEXT}: MAKE_PARALLEL $(LOCALCPP) $(STARTFILES) stamp-oldxmenu 
${obj} ${otherobj} OBJECTS_MACHINE prefix-args${EXEEXT} buildobj.lst
!       echo "${obj} ${otherobj} " OBJECTS_MACHINE > buildobj.lst
        $(LD) YMF_PASS_LDFLAGS (${STARTFLAGS} ${TEMACS_LDFLAGS}) $(LDFLAGS) \
      -o temacs ${STARTFILES} ${obj} ${otherobj}  \
      OBJECTS_MACHINE ${LIBES}
***************
*** 1272,1277 ****
--- 1273,1279 ----
        rm -f temacs${EXEEXT} prefix-args${EXEEXT} core *.core \#* *.o 
libXMenu11.a liblw.a
        rm -f ../etc/DOC
        rm -f bootstrap-emacs${EXEEXT}
+       rm -f buildobj.lst
  clean: mostlyclean
        rm -f emacs-*${EXEEXT} emacs${EXEEXT}
  /**/# This is used in making a distribution.
diff -c src/doc.c.~1.108.~ src/doc.c
Index: src/doc.c
*** src/doc.c.~1.108.~  2004-10-28 22:22:33.000000000 +0200
--- src/doc.c   2004-10-30 19:25:02.000000000 +0200
***************
*** 51,56 ****
--- 51,59 ----
  
  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;
  
  /* For VMS versions with limited file name syntax,
***************
*** 581,586 ****
--- 584,590 ----
    register char *p, *end;
    Lisp_Object sym;
    char *name;
+   int skip_file = 0;
  
    CHECK_STRING (filename);
  
***************
*** 617,622 ****
--- 621,657 ----
    strcpy (name, sys_translate_unix (name));
  #endif /* VMS4_4 */
  #endif /* VMS */
+   
+   if (NILP (Vbuild_files))
+   {
+     size_t cp_size = 0;
+     size_t to_read;
+     int nr_read;
+     char *cp = NULL;
+ 
+     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;
+       }
+ 
+     cp[filled] = 0;
+ 
+     Vbuild_files = Feval (Fcons (intern ("split-string"),
+                                  Fcons (build_string (cp), Qnil)));
+     emacs_close (fd);
+     xfree (cp);
+   }
  
    fd = emacs_open (name, O_RDONLY, 0);
    if (fd < 0)
***************
*** 640,649 ****
        if (p != end)
        {
          end = (char *) index (p, '\n');
          sym = oblookup (Vobarray, p + 2,
                          multibyte_chars_in_text (p + 2, end - p - 2),
                          end - p - 2);
!         if (SYMBOLP (sym))
            {
              /* Attach a docstring to a variable?  */
              if (p[1] == 'V')
--- 675,699 ----
        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')
+             {
+               int len = end - p - 2;
+               char *fromfile = alloca (len + 1);
+               strncpy (fromfile, &p[2], len);
+               fromfile[len] = 0;
+ 
+               if (EQ (Fmember (build_string (fromfile), Vbuild_files), Qnil))
+                 skip_file = 1;
+               else
+                 skip_file = 0;
+             }
+ 
          sym = oblookup (Vobarray, p + 2,
                          multibyte_chars_in_text (p + 2, end - p - 2),
                          end - p - 2);
!         if (! skip_file && SYMBOLP (sym))
            {
              /* Attach a docstring to a variable?  */
              if (p[1] == 'V')
***************
*** 919,924 ****
--- 969,978 ----
               doc: /* Name of file containing documentation strings of 
built-in symbols.  */);
    Vdoc_file_name = Qnil;
  
+   DEFVAR_LISP ("build-files", &Vbuild_files,
+                doc: /* A list of files used to build this Emacs binary.  */);
+   Vbuild_files = Qnil;
+ 
    defsubr (&Sdocumentation);
    defsubr (&Sdocumentation_property);
    defsubr (&Ssnarf_documentation);
diff -c lisp/help-fns.el.~1.57.~ lisp/help-fns.el
Index: lisp/help-fns.el
*** lisp/help-fns.el.~1.57.~    2004-11-01 09:25:38.000000000 +0100
--- lisp/help-fns.el    2004-11-01 09:21:49.000000000 +0100
***************
*** 228,236 ****
        (if (eobp)
          (insert-file-contents-literally
           (expand-file-name internal-doc-file-name doc-directory)))
!       (search-forward (concat "" name "\n"))
!       (re-search-backward "S\\(.*\\)")
!       (let ((file (match-string 1)))
        (if (string-match "\\.\\(o\\|obj\\)\\'" file)
            (setq file (replace-match ".c" t t file)))
        (if (string-match "\\.c\\'" file)
--- 228,241 ----
        (if (eobp)
          (insert-file-contents-literally
           (expand-file-name internal-doc-file-name doc-directory)))
!       (let ((file (catch 'loop
!                   (while t
!                     (let ((pnt (search-forward (concat "" name "\n"))))
!                       (re-search-backward "S\\(.*\\)")
!                       (let ((file (match-string 1)))
!                         (if (member file build-files)
!                             (throw 'loop file)
!                           (goto-char pnt))))))))
        (if (string-match "\\.\\(o\\|obj\\)\\'" file)
            (setq file (replace-match ".c" t t file)))
        (if (string-match "\\.c\\'" file)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]