[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.241,2.242 import.c,2.188,2.189

Guido van Rossum gvanrossum@users.sourceforge.net
Wed, 24 Oct 2001 13:42:57 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv19612

Modified Files:
	bltinmodule.c import.c 
Log Message:
SF patch #474590 -- RISC OS support

Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.241
retrieving revision 2.242
diff -C2 -d -r2.241 -r2.242
*** bltinmodule.c	2001/10/16 21:31:32	2.241
--- bltinmodule.c	2001/10/24 20:42:55	2.242
***************
*** 14,17 ****
--- 14,21 ----
  #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
***************
*** 537,541 ****
--- 541,547 ----
  	PyCompilerFlags cf;
  	int exists;
+ #ifndef RISCOS
  	struct stat s;
+ #endif
  
  	if (!PyArg_ParseTuple(args, "s|O!O!:execfile",
***************
*** 559,562 ****
--- 565,569 ----
  	exists = 0;
  	/* Test for existence or directory. */
+ #ifndef RISCOS
  	if (!stat(filename, &s)) {
  		if (S_ISDIR(s.st_mode))
***************
*** 565,568 ****
--- 572,583 ----
  			exists = 1;
  	}
+ #else
+ 	if (object_exists(filename)) {
+ 		if (isdir(filename))
+ 			errno = EISDIR;
+ 		else
+ 			exists = 1;
+ 	}
+ #endif /* RISCOS */
  
          if (exists) {

Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.188
retrieving revision 2.189
diff -C2 -d -r2.188 -r2.189
*** import.c	2001/10/18 18:54:11	2.188
--- import.c	2001/10/24 20:42:55	2.189
***************
*** 984,994 ****
  		/* 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;
! 			}
! 		}
  #endif
  #endif
--- 984,991 ----
  		/* XXX How are you going to test for directories? */
  #ifdef RISCOS
! 		if (isdir(buf) &&
! 		    find_init_module(buf) &&
! 		    case_ok(buf, len, namelen, name))
! 			return &fd_package;
  #endif
  #endif
***************
*** 1070,1073 ****
--- 1067,1072 ----
  #include <dirent.h>
  
+ #elif defined(RISCOS)
+ #include "oslib/osfscontrol.h"
  #endif
  
***************
*** 1198,1201 ****
--- 1197,1225 ----
  	}
  	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! */