/* Generate doc-string file for XEmacs from source files.
Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
- Copyright (C) 1995 Board of Trustees, University of Illinois
+ Copyright (C) 1995 Board of Trustees, University of Illinois.
+ Copyright (C) 1998, 1999 J. Kean Johnston.
This file is part of XEmacs.
*/
#define NO_SHORTNAMES /* Tell config not to load remap.h */
-#include <../src/config.h>
+#include <config.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#endif
-#include <sys/param.h>
-
#if defined(MSDOS) || defined(__CYGWIN32__)
#include <fcntl.h>
#endif /* MSDOS */
#include <stdlib.h>
#endif /* WINDOWSNT */
+#include <sys/param.h>
+
#if defined(DOS_NT) || defined(__CYGWIN32__)
#define READ_TEXT "rt"
#define READ_BINARY "rb"
/* Name this program was invoked with. */
char *progname;
+/* Set to 1 if this was invoked by ellcc */
+int ellcc = 0;
+
/* Print error message. `s1' is printf control string, `s2' is arg for it. */
static void
outfile = fopen (argv[i + 1], APPEND_BINARY);
i += 2;
}
+ if (argc > i + 1 && !strcmp (argv[i], "-E"))
+ {
+ outfile = fopen (argv[i + 1], APPEND_BINARY);
+ i += 2;
+ ellcc = 1;
+ }
if (argc > i + 1 && !strcmp (argv[i], "-d"))
{
chdir (argv[i + 1]);
if (outfile == 0)
fatal ("No output file specified", "");
+ if (ellcc)
+ fprintf (outfile, "{\n");
+
first_infile = i;
for (; i < argc; i++)
{
}
putc ('\n', outfile);
+ if (ellcc)
+ fprintf (outfile, "}\n\n");
#ifndef VMS
exit (err_count > 0);
#endif /* VMS */
scan_file (CONST char *filename)
{
int len = strlen (filename);
- if (len > 4 && !strcmp (filename + len - 4, ".elc"))
+ if (ellcc == 0 && len > 4 && !strcmp (filename + len - 4, ".elc"))
{
Current_file_type = elc_file;
return scan_lisp_file (filename, READ_BINARY);
}
- else if (len > 3 && !strcmp (filename + len - 3, ".el"))
+ else if (ellcc == 0 && len > 3 && !strcmp (filename + len - 3, ".el"))
{
Current_file_type = el_file;
return scan_lisp_file (filename, READ_TEXT);
if (start != -1)
{
if (printflag > 0)
- putc ('\n', outfile);
+ {
+ if (ellcc)
+ fprintf (outfile, "\\n\\");
+ putc ('\n', outfile);
+ }
else if (printflag < 0)
*p++ = '\n';
}
else
{
start = 0;
- if (printflag > 0)
+ if (printflag > 0) {
+ if (ellcc && c == '"')
+ putc ('\\', outfile);
putc (c, outfile);
+ }
else if (printflag < 0)
*p++ = c;
}
static char lo[] = "Lisp_Object";
if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident &&
(strncmp (p, lo, sizeof (lo) - 1) == 0) &&
- isspace(*(p + sizeof (lo) - 1)))
+ isspace((unsigned char) (* (p + sizeof (lo) - 1))))
{
p += (sizeof (lo) - 1);
- while (isspace (*p))
+ while (isspace ((unsigned char) (*p)))
p++;
c = *p;
}
need_space = 0;
#endif
}
- putc ('\n', out); /* XEmacs addition */
+ if (!ellcc)
+ putc ('\n', out); /* XEmacs addition */
}
\f
/* Read through a c file. If a .o file is named,
if (defunflag || defvarflag || c == '"')
{
- putc (037, outfile);
- putc (defvarflag ? 'V' : 'F', outfile);
- fprintf (outfile, "%s\n", buf);
+ if (ellcc)
+ fprintf (outfile, " CDOC%s(\"%s\", \"\\\n",
+ defvarflag ? "SYM" : "SUBR", buf);
+ else
+ {
+ putc (037, outfile);
+ putc (defvarflag ? 'V' : 'F', outfile);
+ fprintf (outfile, "%s\n", buf);
+ }
c = read_c_string (infile, 1, (defunflag || defvarflag));
/* If this is a defun, find the arguments and print them. If
while (c != ')');
*p = '\0';
/* Output them. */
- fprintf (outfile, "\n\n");
+ if (ellcc)
+ fprintf (outfile, "\\n\\\n\\n\\\n");
+ else
+ fprintf (outfile, "\n\n");
write_c_args (outfile, buf, argbuf, minargs, maxargs);
}
+ if (ellcc)
+ fprintf (outfile, "\\n\");\n\n");
}
}
eof:
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;