/* Generate doc-string file for GNU Emacs from source files.
-Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2012
- Free Software Foundation, Inc.
+Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2014 Free Software
+Foundation, Inc.
This file is part of GNU Emacs.
#undef chdir
#define READ_TEXT "rt"
#define READ_BINARY "rb"
+#define IS_SLASH(c) ((c) == '/' || (c) == '\\' || (c) == ':')
#else /* not DOS_NT */
#define READ_TEXT "r"
#define READ_BINARY "r"
+#define IS_SLASH(c) ((c) == '/')
#endif /* not DOS_NT */
static int scan_file (char *filename);
/* Output CH to the file or buffer in STATE. Any pending newlines or
spaces are output first. */
-static inline void
+static void
put_char (int ch, struct rcsoc_state *state)
{
int out_ch;
LISP_OBJECT,
EMACS_INTEGER,
BOOLEAN,
- FUNCTION,
+ FUNCTION
};
/* A single global. */
qsort (globals, num_globals, sizeof (struct global), compare_globals);
for (i = 0; i < num_globals; ++i)
{
- char const *type;
+ char const *type = 0;
switch (globals[i].type)
{
fatal ("not a recognized DEFVAR_", 0);
}
- if (globals[i].type != FUNCTION)
+ if (type)
{
fprintf (outfile, " %s f_%s;\n", type, globals[i].name);
fprintf (outfile, "#define %s globals.f_%s\n",
|| strcmp (globals[i].name, "Fexit_recursive_edit") == 0
|| strcmp (globals[i].name, "Fabort_recursive_edit") == 0)
fprintf (outfile, "_Noreturn ");
+
fprintf (outfile, "EXFUN (%s, ", globals[i].name);
if (globals[i].value == -1)
fprintf (outfile, "MANY");
fprintf (outfile, "UNEVALLED");
else
fprintf (outfile, "%d", globals[i].value);
- fprintf (outfile, ");\n");
+ fprintf (outfile, ")");
+
+ /* It would be nice to have a cleaner way to deal with these
+ special hacks, too. */
+ if (strcmp (globals[i].name, "Fbyteorder") == 0
+ || strcmp (globals[i].name, "Ftool_bar_height") == 0
+ || strcmp (globals[i].name, "Fmax_char") == 0
+ || strcmp (globals[i].name, "Fidentity") == 0)
+ fprintf (outfile, " ATTRIBUTE_CONST");
+
+ fprintf (outfile, ";\n");
}
while (i + 1 < num_globals
static int
search_lisp_doc_at_eol (FILE *infile)
{
- char c = 0, c1 = 0, c2 = 0;
+ int c = 0, c1 = 0, c2 = 0;
/* Skip until the end of line; remember two previous chars. */
while (c != '\n' && c != '\r' && c != EOF)
if (c2 != '"' || c1 != '\\')
{
#ifdef DEBUG
- fprintf (stderr, "## non-docstring in %s (%s)\n",
- buffer, filename);
+ fprintf (stderr, "## non-docstring found\n");
#endif
if (c != EOF)
ungetc (c, infile);
return 1;
}
+#define DEF_ELISP_FILE(fn) { #fn, sizeof(#fn) - 1 }
+
static int
scan_lisp_file (const char *filename, const char *mode)
{
static struct {
const char *fn;
size_t fl;
- } uncompiled[] = {
- { "loaddefs.el", sizeof("loaddefs.el") - 1 },
- { "loadup.el", sizeof("loadup.el") - 1 },
- { "charprop.el", sizeof("charprop.el") - 1 }
+ } const uncompiled[] = {
+ DEF_ELISP_FILE (loaddefs.el),
+ DEF_ELISP_FILE (loadup.el),
+ DEF_ELISP_FILE (charprop.el),
+ DEF_ELISP_FILE (cp51932.el),
+ DEF_ELISP_FILE (eucjp-ms.el)
};
int i, match;
size_t flen = strlen (filename);
if (generate_globals)
fatal ("scanning lisp file when -g specified", 0);
- if (!strcmp (filename + flen - 3, ".el"))
+ if (flen > 3 && !strcmp (filename + flen - 3, ".el"))
{
- for (i = 0, match = 0; i < sizeof(uncompiled)/sizeof(uncompiled[0]); i++)
+ for (i = 0, match = 0; i < sizeof (uncompiled) / sizeof (uncompiled[0]);
+ i++)
{
- if (!strcmp (filename + flen - uncompiled[i].fl, uncompiled[i].fn))
+ if (uncompiled[i].fl <= flen
+ && !strcmp (filename + flen - uncompiled[i].fl, uncompiled[i].fn)
+ && (flen == uncompiled[i].fl
+ || IS_SLASH (filename[flen - uncompiled[i].fl - 1])))
{
match = 1;
break;