]> code.delx.au - gnu-emacs/blobdiff - lib-src/make-docfile.c
* windows.texi (Cyclic Window Ordering, Cyclic Window Ordering)
[gnu-emacs] / lib-src / make-docfile.c
index ba73f5800a745a1fb7680948e64c03990efdb67e..219e9d24ac1de62828a7358f4bdfa6f9fd9735f7 100644 (file)
@@ -1,13 +1,14 @@
 /* Generate doc-string file for GNU Emacs from source files.
-   Copyright (C) 1985, 86, 92, 93, 94, 97, 1999, 2000, 01, 2004
-   Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1992, 1993, 1994, 1997, 1999, 2000, 2001,
+                 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+                 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,9 +16,8 @@ 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., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
 
 /* The arguments given to this program are all the C and Lisp source files
  of GNU Emacs.  .elc and .el and .c files are allowed.
@@ -34,7 +34,6 @@ Boston, MA 02111-1307, USA.  */
  Then comes the documentation for that function or variable.
  */
 
-#define NO_SHORTNAMES   /* Tell config not to load remap.h */
 #include <config.h>
 
 /* defined to be emacs_main, sys_fopen, etc. in config.h */
@@ -60,6 +59,14 @@ Boston, MA 02111-1307, USA.  */
 #define READ_BINARY "r"
 #endif /* not DOS_NT */
 
+#ifndef DIRECTORY_SEP
+#define DIRECTORY_SEP '/'
+#endif
+
+#ifndef IS_DIRECTORY_SEP
+#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
+#endif
+
 int scan_file ();
 int scan_lisp_file ();
 int scan_c_file ();
@@ -100,7 +107,7 @@ fatal (s1, s2)
      char *s1, *s2;
 {
   error (s1, s2);
-  exit (1);
+  exit (EXIT_FAILURE);
 }
 
 /* Like malloc but get fatal error if memory is exhausted.  */
@@ -183,11 +190,13 @@ void
 put_filename (filename)
      char *filename;
 {
-  char *tmp = filename;
-  int len;
-  
-  while ((tmp = index (filename, '/')))
-    filename = tmp + 1;
+  char *tmp;
+
+  for (tmp = filename; *tmp; tmp++)
+    {
+      if (IS_DIRECTORY_SEP(*tmp))
+       filename = tmp + 1;
+    }
 
   putc (037, outfile);
   putc ('S', outfile);
@@ -524,7 +533,7 @@ write_c_args (out, func, buf, minargs, maxargs)
 }
 \f
 /* Read through a c file.  If a .o file is named,
-   the corresponding .c file is read instead.
+   the corresponding .c or .m file is read instead.
    Looks for DEFUN constructs such as are defined in ../src/lisp.h.
    Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED.  */
 
@@ -546,6 +555,15 @@ scan_c_file (filename, mode)
 
   infile = fopen (filename, mode);
 
+  if (infile == NULL && extension == 'o')
+    {
+      /* try .m */
+      filename[strlen (filename) - 1] = 'm';
+      infile = fopen (filename, mode);
+      if (infile == NULL)
+        filename[strlen (filename) - 1] = 'c'; /* don't confuse people */
+    }
+
   /* No error if non-ex input file */
   if (infile == NULL)
     {
@@ -611,6 +629,7 @@ scan_c_file (filename, mode)
          c = getc (infile);
          defunflag = c == 'U';
          defvarflag = 0;
+         defvarperbufferflag = 0;
        }
       else continue;
 
@@ -890,7 +909,7 @@ scan_lisp_file (filename, mode)
              /* Read in the contents.  */
              if (saved_string != 0)
                free (saved_string);
-             saved_string = (char *) malloc (length);
+             saved_string = (char *) xmalloc (length);
              for (i = 0; i < length; i++)
                saved_string[i] = getc (infile);
              /* The last character is a ^_.
@@ -1172,7 +1191,7 @@ scan_lisp_file (filename, mode)
       else
        {
 #ifdef DEBUG
-         fprintf (stderr, "## unrecognised top-level form, %s (%s)\n",
+         fprintf (stderr, "## unrecognized top-level form, %s (%s)\n",
                   buffer, filename);
 #endif
          continue;
@@ -1204,3 +1223,5 @@ scan_lisp_file (filename, mode)
 
 /* arch-tag: f7203aaf-991a-4238-acb5-601db56f2894
    (do not change this comment) */
+
+/* make-docfile.c ends here */