From: Eli Zaretskii Date: Sat, 20 Oct 2012 15:26:10 +0000 (+0200) Subject: Fix last changes in make-docfile.c. X-Git-Tag: emacs-24.2.90~211^2~24 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=83c85d8e2e6c1e1cb309f554555e1aebc1dcb44f;p=emacs.git 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. --- diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 40da102620b..bcb71daca5d 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,9 @@ +2012-10-20 Eli Zaretskii + + * 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 * make-docfile.c (scan_lisp_file): Add bounds checking. diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 2f04f1c96f3..b6cd1530a4c 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -58,9 +58,11 @@ along with GNU Emacs. If not, see . */ #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); @@ -1098,6 +1100,8 @@ search_lisp_doc_at_eol (FILE *infile) return 1; } +#define DEF_ELISP_FILE(fn) { #fn, sizeof(#fn) - 1 } + static int 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 function. These conventions are automatically followed by the byte compiler when it produces the .elc files. */ - static const char *const uncompiled[] = - { - "loaddefs.el", - "loadup.el", - "charprop.el" - }; + static struct { + const char *fn; + size_t fl; + } const uncompiled[] = { + DEF_ELISP_FILE (loaddefs.el), + DEF_ELISP_FILE (loadup.el), + DEF_ELISP_FILE (charprop.el) + }; int i, match; size_t flen = strlen (filename); @@ -1124,9 +1130,10 @@ scan_lisp_file (const char *filename, const char *mode) for (i = 0, match = 0; i < sizeof (uncompiled) / sizeof (uncompiled[0]); i++) { - if (strlen (uncompiled[i]) <= flen - && !strcmp (filename + flen - strlen (uncompiled[i]), - uncompiled[i])) + 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;