mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
SF patch #474590 -- RISC OS support
This commit is contained in:
parent
c6ac8a78f6
commit
e2ae77b8b8
33 changed files with 256 additions and 188 deletions
|
@ -13,6 +13,10 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef RISCOS
|
||||
#include "unixstuff.h"
|
||||
#endif
|
||||
|
||||
/* The default encoding used by the platform file system APIs
|
||||
Can remain NULL for all platforms that don't have such a concept
|
||||
*/
|
||||
|
@ -536,7 +540,9 @@ builtin_execfile(PyObject *self, PyObject *args)
|
|||
FILE* fp = NULL;
|
||||
PyCompilerFlags cf;
|
||||
int exists;
|
||||
#ifndef RISCOS
|
||||
struct stat s;
|
||||
#endif
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|O!O!:execfile",
|
||||
&filename,
|
||||
|
@ -558,12 +564,21 @@ builtin_execfile(PyObject *self, PyObject *args)
|
|||
|
||||
exists = 0;
|
||||
/* Test for existence or directory. */
|
||||
#ifndef RISCOS
|
||||
if (!stat(filename, &s)) {
|
||||
if (S_ISDIR(s.st_mode))
|
||||
errno = EISDIR;
|
||||
else
|
||||
exists = 1;
|
||||
}
|
||||
#else
|
||||
if (object_exists(filename)) {
|
||||
if (isdir(filename))
|
||||
errno = EISDIR;
|
||||
else
|
||||
exists = 1;
|
||||
}
|
||||
#endif /* RISCOS */
|
||||
|
||||
if (exists) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
|
|
|
@ -983,13 +983,10 @@ find_module(char *realname, PyObject *path, char *buf, size_t buflen,
|
|||
#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 @@ find_module(char *realname, PyObject *path, char *buf, size_t buflen,
|
|||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#elif defined(RISCOS)
|
||||
#include "oslib/osfscontrol.h"
|
||||
#endif
|
||||
|
||||
static int
|
||||
|
@ -1198,6 +1197,31 @@ case_ok(char *buf, int len, int namelen, char *name)
|
|||
}
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue