(widget-specify-secret): New function.
[bpt/emacs.git] / lib-src / make-docfile.c
index df9c6e0..82e7f7c 100644 (file)
@@ -1,5 +1,5 @@
 /* Generate doc-string file for GNU Emacs from source files.
-   Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 92, 93, 94, 1997 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -15,7 +15,8 @@ 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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 /* 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.
@@ -31,6 +32,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  Then comes the documentation for that function or variable.
  */
 
+#define NO_SHORTNAMES   /* Tell config not to load remap.h */
+#include <../src/config.h>
+
 #include <stdio.h>
 #ifdef MSDOS
 #include <fcntl.h>
@@ -53,6 +57,16 @@ int scan_file ();
 int scan_lisp_file ();
 int scan_c_file ();
 
+#ifdef MSDOS
+/* s/msdos.h defines this as sys_chdir, but we're not linking with the
+   file where that function is defined.  */
+#undef chdir
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 /* Stdio stream for output to the DOC file.  */
 FILE *outfile;
 
@@ -84,11 +98,11 @@ fatal (s1, s2)
 
 /* Like malloc but get fatal error if memory is exhausted.  */
 
-char *
+long *
 xmalloc (size)
      unsigned int size;
 {
-  char *result = (char *) malloc (size);
+  long *result = (long *) malloc (size);
   if (result == NULL)
     fatal ("virtual memory exhausted", 0);
   return result;
@@ -105,19 +119,23 @@ main (argc, argv)
 
   progname = argv[0];
 
+  outfile = stdout;
+
   /* Don't put CRs in the DOC file.  */
 #ifdef MSDOS
   _fmode = O_BINARY;
+#if 0  /* Suspicion is that this causes hanging.
+         So instead we require people to use -o on MSDOS.  */
   (stdout)->_flag &= ~_IOTEXT;
   _setmode (fileno (stdout), O_BINARY);
+#endif
+  outfile = 0;
 #endif /* MSDOS */
 #ifdef WINDOWSNT
   _fmode = O_BINARY;
   _setmode (fileno (stdout), O_BINARY);
 #endif /* WINDOWSNT */
 
-  outfile = stdout;
-
   /* If first two args are -o FILE, output to FILE.  */
   i = 1;
   if (argc > i + 1 && !strcmp (argv[i], "-o"))
@@ -136,6 +154,9 @@ main (argc, argv)
       i += 2;
     }
 
+  if (outfile == 0)
+    fatal ("No output file specified", "");
+
   first_infile = i;
   for (; i < argc; i++)
     {
@@ -161,9 +182,9 @@ scan_file (filename)
      char *filename;
 {
   int len = strlen (filename);
-  if (!strcmp (filename + len - 4, ".elc"))
+  if (len > 4 && !strcmp (filename + len - 4, ".elc"))
     return scan_lisp_file (filename, READ_BINARY);
-  else if (!strcmp (filename + len - 3, ".el"))
+  else if (len > 3 && !strcmp (filename + len - 3, ".el"))
     return scan_lisp_file (filename, READ_TEXT);
   else
     return scan_c_file (filename, READ_TEXT);
@@ -322,8 +343,9 @@ scan_c_file (filename, mode)
   register int defvarperbufferflag;
   register int defvarflag;
   int minargs, maxargs;
+  int extension = filename[strlen (filename) - 1];
 
-  if (filename[strlen (filename) - 1] == 'o')
+  if (extension == 'o')
     filename[strlen (filename) - 1] = 'c';
 
   infile = fopen (filename, mode);
@@ -335,6 +357,9 @@ scan_c_file (filename, mode)
       return 0;
     }
 
+  /* Reset extension to be able to detect duplicate files. */
+  filename[strlen (filename) - 1] = extension;
+
   c = '\n';
   while (!feof (infile))
     {
@@ -502,6 +527,7 @@ scan_c_file (filename, mode)
   (fset (quote NAME) (make-byte-code ... DOCSTRING ...))
   (fset (quote NAME) #[... DOCSTRING ...])
   (defalias (quote NAME) #[... DOCSTRING ...])
+  (custom-declare-variable (quote NAME) VALUE DOCSTRING ...)
  starting in column zero.
  (quote NAME) may appear as 'NAME as well.
 
@@ -711,6 +737,66 @@ scan_lisp_file (filename, mode)
            }
        }
 
+      else if (! strcmp (buffer, "custom-declare-variable"))
+       {
+         char c1 = 0, c2 = 0;
+         type = 'V';
+
+         c = getc (infile);
+         if (c == '\'')
+           read_lisp_symbol (infile, buffer);
+         else
+           {
+             if (c != '(')
+               {
+                 fprintf (stderr,
+                          "## unparsable name in custom-declare-variable in %s\n",
+                          filename);
+                 continue;
+               }
+             read_lisp_symbol (infile, buffer);
+             if (strcmp (buffer, "quote"))
+               {
+                 fprintf (stderr,
+                          "## unparsable name in custom-declare-variable in %s\n",
+                          filename);
+                 continue;
+               }
+             read_lisp_symbol (infile, buffer);
+             c = getc (infile);
+             if (c != ')')
+               {
+                 fprintf (stderr,
+                          "## unparsable quoted name in custom-declare-variable in %s\n",
+                          filename);
+                 continue;
+               }
+           }
+
+         if (saved_string == 0)
+           {
+             /* Skip until the first newline; remember the two previous
+                chars. */
+             while (c != '\n' && c >= 0)
+               {
+                 c2 = c1;
+                 c1 = c;
+                 c = getc (infile);
+               }
+         
+             /* If two previous characters were " and \,
+                this is a doc string.  Otherwise, there is none.  */
+             if (c2 != '"' || c1 != '\\')
+               {
+#ifdef DEBUG
+                 fprintf (stderr, "## non-docstring in %s (%s)\n",
+                          buffer, filename);
+#endif
+                 continue;
+               }
+           }
+       }
+
       else if (! strcmp (buffer, "fset") || ! strcmp (buffer, "defalias"))
        {
          char c1 = 0, c2 = 0;