Commit 83c85d8e authored by Eli Zaretskii's avatar Eli Zaretskii

Fix last changes in make-docfile.c.

 lib-src/make-docfile.c (IS_SLASH, DEF_ELISP_FILE): New macros.
 (scan_lisp_file): Only pass a .el file if its basename matches a
 known file in its entirety.  Use IS_SLASH and DEF_ELISP_FILE.
parent 71aa63da
2012-10-20 Eli Zaretskii <eliz@gnu.org>
* make-docfile.c (IS_SLASH, DEF_ELISP_FILE): New macros.
(scan_lisp_file): Only pass a .el file if its basename matches a
known file in its entirety. Use IS_SLASH and DEF_ELISP_FILE.
2012-10-20 Andreas Schwab <schwab@linux-m68k.org> 2012-10-20 Andreas Schwab <schwab@linux-m68k.org>
* make-docfile.c (scan_lisp_file): Add bounds checking. * make-docfile.c (scan_lisp_file): Add bounds checking.
......
...@@ -58,9 +58,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -58,9 +58,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#undef chdir #undef chdir
#define READ_TEXT "rt" #define READ_TEXT "rt"
#define READ_BINARY "rb" #define READ_BINARY "rb"
#define IS_SLASH(c) ((c) == '/' || (c) == '\\' || (c) == ':')
#else /* not DOS_NT */ #else /* not DOS_NT */
#define READ_TEXT "r" #define READ_TEXT "r"
#define READ_BINARY "r" #define READ_BINARY "r"
#define IS_SLASH(c) ((c) == '/')
#endif /* not DOS_NT */ #endif /* not DOS_NT */
static int scan_file (char *filename); static int scan_file (char *filename);
...@@ -1098,6 +1100,8 @@ search_lisp_doc_at_eol (FILE *infile) ...@@ -1098,6 +1100,8 @@ search_lisp_doc_at_eol (FILE *infile)
return 1; return 1;
} }
#define DEF_ELISP_FILE(fn) { #fn, sizeof(#fn) - 1 }
static int static int
scan_lisp_file (const char *filename, const char *mode) scan_lisp_file (const char *filename, const char *mode)
{ {
...@@ -1108,12 +1112,14 @@ scan_lisp_file (const char *filename, const char *mode) ...@@ -1108,12 +1112,14 @@ scan_lisp_file (const char *filename, const char *mode)
follow the conventions of the doc strings expected by this follow the conventions of the doc strings expected by this
function. These conventions are automatically followed by the function. These conventions are automatically followed by the
byte compiler when it produces the .elc files. */ byte compiler when it produces the .elc files. */
static const char *const uncompiled[] = static struct {
{ const char *fn;
"loaddefs.el", size_t fl;
"loadup.el", } const uncompiled[] = {
"charprop.el" DEF_ELISP_FILE (loaddefs.el),
}; DEF_ELISP_FILE (loadup.el),
DEF_ELISP_FILE (charprop.el)
};
int i, match; int i, match;
size_t flen = strlen (filename); size_t flen = strlen (filename);
...@@ -1124,9 +1130,10 @@ scan_lisp_file (const char *filename, const char *mode) ...@@ -1124,9 +1130,10 @@ scan_lisp_file (const char *filename, const char *mode)
for (i = 0, match = 0; i < sizeof (uncompiled) / sizeof (uncompiled[0]); for (i = 0, match = 0; i < sizeof (uncompiled) / sizeof (uncompiled[0]);
i++) i++)
{ {
if (strlen (uncompiled[i]) <= flen if (uncompiled[i].fl <= flen
&& !strcmp (filename + flen - strlen (uncompiled[i]), && !strcmp (filename + flen - uncompiled[i].fl, uncompiled[i].fn)
uncompiled[i])) && (flen == uncompiled[i].fl
|| IS_SLASH (filename[flen - uncompiled[i].fl - 1])))
{ {
match = 1; match = 1;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment