Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dbe6ebb

Browse files
committed
More fiddling w/ the new-fangled Mac import code.
1 parent 8a18e99 commit dbe6ebb

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Python/import.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,35 +1111,39 @@ case_ok(char *buf, int len, int namelen, char *name)
11111111
#elif defined(__MACH__) && defined(__APPLE__)
11121112
DIR *dirp;
11131113
struct dirent *dp;
1114-
char pathname[MAX_PATH + 1];
1114+
char pathname[MAXPATHLEN + 1];
11151115
const int pathlen = len - namelen - 1; /* don't want trailing SEP */
11161116

1117+
if (getenv("PYTHONCASEOK") != NULL)
1118+
return 1;
1119+
11171120
/* Copy the path component into pathname; substitute "." if empty */
11181121
if (pathlen <= 0) {
11191122
pathname[0] = '.';
11201123
pathname[1] = '\0';
11211124
}
11221125
else {
1123-
assert(pathlen <= MAX_PATH);
1126+
assert(pathlen <= MAXPATHLEN);
11241127
memcpy(pathname, buf, pathlen);
11251128
pathname[pathlen] = '\0';
11261129
}
11271130
/* Open the directory and search the entries for an exact match. */
11281131
dirp = opendir(pathname);
11291132
if (dirp) {
11301133
while ((dp = readdir(dirp)) != NULL) {
1134+
const int thislen =
11311135
#ifdef _DIRENT_HAVE_D_NAMELEN
1132-
const int thislen = dp->d_namlen;
1136+
dp->d_namlen;
11331137
#else
1134-
const int thislen = strlen(dp->d_name);
1138+
strlen(dp->d_name);
11351139
#endif
11361140
if (thislen == namelen && !strcmp(dp->d_name, name)) {
11371141
(void)closedir(dirp);
11381142
return 1; /* Found */
11391143
}
11401144
}
1145+
(void)closedir(dirp);
11411146
}
1142-
(void)closedir(dirp);
11431147
return 0 ; /* Not found */
11441148

11451149
/* assuming it's a case-sensitive filesystem, so there's nothing to do! */

0 commit comments

Comments
 (0)