Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 20654:edd9d0b3c47e legacy-trunk
SF patch #474590 -- RISC OS support
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 24 Oct 2001 20:42:55 +0000 |
| parents | 3d3b6b4cb79f |
| children | 3fb403eaede1 |
line wrap: on
line diff
--- a/Python/import.c Wed Oct 24 20:22:40 2001 +0000 +++ b/Python/import.c Wed Oct 24 20:42:55 2001 +0000 @@ -983,13 +983,10 @@ #else /* XXX How are you going to test for directories? */ #ifdef RISCOS - { - static struct filedescr fd = {"", "", PKG_DIRECTORY}; - if (isdir(buf)) { - if (find_init_module(buf)) - return &fd; - } - } + if (isdir(buf) && + find_init_module(buf) && + case_ok(buf, len, namelen, name)) + return &fd_package; #endif #endif #ifdef macintosh @@ -1069,6 +1066,8 @@ #include <sys/types.h> #include <dirent.h> +#elif defined(RISCOS) +#include "oslib/osfscontrol.h" #endif static int @@ -1198,6 +1197,31 @@ } return 0 ; /* Not found */ +/* RISC OS */ +#elif defined(RISCOS) + char canon[MAXPATHLEN+1]; /* buffer for the canonical form of the path */ + char buf2[MAXPATHLEN+2]; + char *nameWithExt = buf+len-namelen; + int canonlen; + os_error *e; + + if (Py_GETENV("PYTHONCASEOK") != NULL) + return 1; + + /* workaround: + append wildcard, otherwise case of filename wouldn't be touched */ + strcpy(buf2, buf); + strcat(buf2, "*"); + + e = xosfscontrol_canonicalise_path(buf2,canon,0,0,MAXPATHLEN+1,&canonlen); + canonlen = MAXPATHLEN+1-canonlen; + if (e || canonlen<=0 || canonlen>(MAXPATHLEN+1) ) + return 0; + if (strcmp(nameWithExt, canon+canonlen-strlen(nameWithExt))==0) + return 1; /* match */ + + return 0; + /* assuming it's a case-sensitive filesystem, so there's nothing to do! */ #else return 1;
