]> code.delx.au - gnu-emacs/blobdiff - lib-src/make-docfile.c
(mac_make_lispy_event_code): Remove extern.
[gnu-emacs] / lib-src / make-docfile.c
index 3d275fdd4224d36f7d74c49df0ddb1ae48df7882..bfdb206ad97088aacb1967d944bf24234b071079 100644 (file)
@@ -1,6 +1,6 @@
 /* Generate doc-string file for GNU Emacs from source files.
-   Copyright (C) 1985, 86, 92, 93, 94, 97, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1992, 1993, 1994, 1997, 1999, 2000, 2001,
+                 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -16,13 +16,14 @@ 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.  */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, 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.
  A .o file can also be specified; the .c file it was made from is used.
  This helps the makefile pass the correct list of files.
+ Option -d DIR means change to DIR before looking for files.
 
  The results, which go to standard output or to a file
  specified with -a or -o (-a to append, -o to start from nothing),
@@ -59,6 +60,18 @@ Boston, MA 02111-1307, USA.  */
 #define READ_BINARY "r"
 #endif /* not DOS_NT */
 
+#ifndef DIRECTORY_SEP
+#ifdef MAC_OS8
+#define DIRECTORY_SEP ':'
+#else  /* not MAC_OS8 */
+#define DIRECTORY_SEP '/'
+#endif /* not MAC_OS8 */
+#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 ();
@@ -99,16 +112,16 @@ fatal (s1, s2)
      char *s1, *s2;
 {
   error (s1, s2);
-  exit (1);
+  exit (EXIT_FAILURE);
 }
 
 /* Like malloc but get fatal error if memory is exhausted.  */
 
-long *
+void *
 xmalloc (size)
      unsigned int size;
 {
-  long *result = (long *) malloc (size);
+  void *result = (void *) malloc (size);
   if (result == NULL)
     fatal ("virtual memory exhausted", 0);
   return result;
@@ -174,10 +187,25 @@ main (argc, argv)
       if (j == i)
        err_count += scan_file (argv[i]);
     }
-#ifndef VMS
-  exit (err_count > 0);
-#endif /* VMS */
-  return err_count > 0;
+  return (err_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
+}
+
+/* Add a source file name boundary marker in the output file.  */
+void
+put_filename (filename)
+     char *filename;
+{
+  char *tmp;
+
+  for (tmp = filename; *tmp; tmp++)
+    {
+      if (IS_DIRECTORY_SEP(*tmp))
+       filename = tmp + 1;
+    }
+
+  putc (037, outfile);
+  putc ('S', outfile);
+  fprintf (outfile, "%s\n", filename);
 }
 
 /* Read file FILENAME and output its doc strings to outfile.  */
@@ -188,6 +216,8 @@ scan_file (filename)
      char *filename;
 {
   int len = strlen (filename);
+
+  put_filename (filename);
   if (len > 4 && !strcmp (filename + len - 4, ".elc"))
     return scan_lisp_file (filename, READ_BINARY);
   else if (len > 3 && !strcmp (filename + len - 3, ".el"))
@@ -290,7 +320,17 @@ scan_keyword_or_put_char (ch, state)
            ch = getc (state->in_file);
          while (ch == ' ' || ch == '\n');
 
-         /* Put back the non-whitespace character.  */
+         /* Output the open-paren we just read.  */
+         put_char (ch, state);
+
+         /* Skip the function name and replace it with `fn'.  */
+         do
+           ch = getc (state->in_file);
+         while (ch != ' ' && ch != ')');
+         put_char ('f', state);
+         put_char ('n', state);
+
+         /* Put back the last character.  */
          ungetc (ch, state->in_file);
        }
     }
@@ -328,6 +368,7 @@ read_c_string_or_comment (infile, printflag, comment, saw_usage)
      FILE *infile;
      int printflag;
      int *saw_usage;
+     int comment;
 {
   register int c;
   struct rcsoc_state state;
@@ -363,7 +404,7 @@ read_c_string_or_comment (infile, printflag, comment, saw_usage)
              if (c == 't')
                c = '\t';
            }
-         
+
          if (c == ' ')
            state.pending_spaces++;
          else if (c == '\n')
@@ -387,19 +428,19 @@ read_c_string_or_comment (infile, printflag, comment, saw_usage)
              c = getc (infile);
              break;
            }
-         
+
          scan_keyword_or_put_char ('*', &state);
        }
       else
        {
          if (c != '"')
            break;
-      
+
          /* If we had a "", concatenate the two strings.  */
          c = getc (infile);
        }
     }
-  
+
   if (printflag < 0)
     *state.buf_ptr = 0;
 
@@ -425,7 +466,7 @@ write_c_args (out, func, buf, minargs, maxargs)
   int just_spaced = 0;
   int need_space = 1;
 
-  fprintf (out, "(%s", func);
+  fprintf (out, "(fn");
 
   if (*buf == '(')
     ++buf;
@@ -584,6 +625,7 @@ scan_c_file (filename, mode)
          c = getc (infile);
          defunflag = c == 'U';
          defvarflag = 0;
+         defvarperbufferflag = 0;
        }
       else continue;
 
@@ -644,10 +686,10 @@ scan_c_file (filename, mode)
 
       while (c == ' ' || c == '\n' || c == '\r' || c == '\t')
        c = getc (infile);
-      
+
       if (c == '"')
        c = read_c_string_or_comment (infile, 0, 0, 0);
-      
+
       while (c != EOF && c != ',' && c != '/')
        c = getc (infile);
       if (c == ',')
@@ -674,7 +716,7 @@ scan_c_file (filename, mode)
        {
          int comment = c != '"';
          int saw_usage;
-         
+
          putc (037, outfile);
          putc (defvarflag ? 'V' : 'F', outfile);
          fprintf (outfile, "%s\n", buf);
@@ -704,7 +746,7 @@ scan_c_file (filename, mode)
                      goto eof;
                    c = getc (infile);
                  }
-             
+
              /* Skip into arguments.  */
              while (c != '(')
                {
@@ -722,6 +764,9 @@ scan_c_file (filename, mode)
              fprintf (outfile, "\n\n");
              write_c_args (outfile, buf, argbuf, minargs, maxargs);
            }
+         else if (defunflag && maxargs == -1 && !saw_usage)
+           /* The DOC should provide the usage form.  */
+           fprintf (stderr, "Missing `usage' for function `%s'.\n", buf);
        }
     }
  eof:
@@ -748,14 +793,14 @@ scan_c_file (filename, mode)
  When we find that, we save it for the following defining-form,
  and we use that instead of reading a doc string within that defining-form.
 
- For defvar, defconst, and fset we skip to the docstring with a kludgy 
+ For defvar, defconst, and fset we skip to the docstring with a kludgy
  formatting convention: all docstrings must appear on the same line as the
- initial open-paren (the one in column zero) and must contain a backslash 
+ initial open-paren (the one in column zero) and must contain a backslash
  and a newline immediately after the initial double-quote.  No newlines
  must appear between the beginning of the form and the first double-quote.
  For defun, defmacro, and autoload, we know how to skip over the
  arglist, but the doc string must still have a backslash and newline
- immediately after the double quote. 
+ immediately after the double quote.
  The only source files that must follow this convention are preloaded
  uncompiled ones like loaddefs.el and bindings.el; aside
  from that, it is always the .elc file that we look at, and they are no
@@ -801,7 +846,7 @@ read_lisp_symbol (infile, buffer)
 
   if (! buffer[0])
     fprintf (stderr, "## expected a symbol, got '%c'\n", c);
-  
+
   skip_white (infile);
 }
 
@@ -945,7 +990,7 @@ scan_lisp_file (filename, mode)
                  c1 = c;
                  c = getc (infile);
                }
-         
+
              /* If two previous characters were " and \,
                 this is a doc string.  Otherwise, there is none.  */
              if (c2 != '"' || c1 != '\\')
@@ -1004,7 +1049,7 @@ scan_lisp_file (filename, mode)
                  c1 = c;
                  c = getc (infile);
                }
-         
+
              /* If two previous characters were " and \,
                 this is a doc string.  Otherwise, there is none.  */
              if (c2 != '"' || c1 != '\\')
@@ -1061,7 +1106,7 @@ scan_lisp_file (filename, mode)
                  c1 = c;
                  c = getc (infile);
                }
-         
+
              /* If two previous characters were " and \,
                 this is a doc string.  Otherwise, there is none.  */
              if (c2 != '"' || c1 != '\\')
@@ -1171,3 +1216,8 @@ scan_lisp_file (filename, mode)
   fclose (infile);
   return 0;
 }
+
+/* arch-tag: f7203aaf-991a-4238-acb5-601db56f2894
+   (do not change this comment) */
+
+/* make-docfile.c ends here */