Kaydet (Commit) 677898a3 authored tarafından Tim Peters's avatar Tim Peters

Thanks to Steven Majewski, finally putting MacOS X imports to bed for 2.1b1.

üst fd85a4e6
...@@ -1118,14 +1118,7 @@ case_ok(char *buf, int len, int namelen, char *name) ...@@ -1118,14 +1118,7 @@ case_ok(char *buf, int len, int namelen, char *name)
return fss.name[0] >= namelen && return fss.name[0] >= namelen &&
strncmp(name, (char *)fss.name+1, namelen) == 0; strncmp(name, (char *)fss.name+1, namelen) == 0;
/* new-fangled macintosh (macosx) /* new-fangled macintosh (macosx) */
*
* XXX This seems prone to obscure errors, like suppose someone does
* XXX "import xyz", and in some directory there's both "XYZ.py" and
* XXX "xyz.txt". fopen("xyz.py") will open XYZ.py, but when marching thru
* XXX the directory we'll eventually "succeed" on "xyz.txt" because the
* XXX extension is never checked.
*/
#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H) #elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H)
DIR *dirp; DIR *dirp;
struct dirent *dp; struct dirent *dp;
...@@ -1148,6 +1141,7 @@ case_ok(char *buf, int len, int namelen, char *name) ...@@ -1148,6 +1141,7 @@ case_ok(char *buf, int len, int namelen, char *name)
/* Open the directory and search the entries for an exact match. */ /* Open the directory and search the entries for an exact match. */
dirp = opendir(dirname); dirp = opendir(dirname);
if (dirp) { if (dirp) {
char *nameWithExt = buf + len - namelen;
while ((dp = readdir(dirp)) != NULL) { while ((dp = readdir(dirp)) != NULL) {
const int thislen = const int thislen =
#ifdef _DIRENT_HAVE_D_NAMELEN #ifdef _DIRENT_HAVE_D_NAMELEN
...@@ -1156,7 +1150,7 @@ case_ok(char *buf, int len, int namelen, char *name) ...@@ -1156,7 +1150,7 @@ case_ok(char *buf, int len, int namelen, char *name)
strlen(dp->d_name); strlen(dp->d_name);
#endif #endif
if (thislen >= namelen && if (thislen >= namelen &&
strncmp(dp->d_name, name, namelen) == 0) { strcmp(dp->d_name, nameWithExt) == 0) {
(void)closedir(dirp); (void)closedir(dirp);
return 1; /* Found */ return 1; /* Found */
} }
......
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