[Python-checkins] CVS: python/dist/src/Python import.c,2.171,2.172

Guido van Rossum gvanrossum@users.sourceforge.net
Thu, 01 Mar 2001 22:34:16 -0800


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

Modified Files:
	import.c 
Log Message:
RISCOS changes by dschwertberger.


Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.171
retrieving revision 2.172
diff -C2 -r2.171 -r2.172
*** import.c	2001/03/02 03:28:03	2.171
--- import.c	2001/03/02 06:34:14	2.172
***************
*** 61,64 ****
--- 61,72 ----
  /* these tables define the module suffixes that Python recognizes */
  struct filedescr * _PyImport_Filetab = NULL;
+ 
+ #ifdef RISCOS
+ static const struct filedescr _PyImport_StandardFiletab[] = {
+ 	{"/py", "r", PY_SOURCE},
+ 	{"/pyc", "rb", PY_COMPILED},
+ 	{0, 0}
+ };
+ #else
  static const struct filedescr _PyImport_StandardFiletab[] = {
  	{".py", "r", PY_SOURCE},
***************
*** 66,69 ****
--- 74,78 ----
  	{0, 0}
  };
+ #endif
  
  /* Initialize things */
***************
*** 96,101 ****
--- 105,115 ----
  		/* Replace ".pyc" with ".pyo" in _PyImport_Filetab */
  		for (; filetab->suffix != NULL; filetab++) {
+ #ifndef RISCOS
  			if (strcmp(filetab->suffix, ".pyc") == 0)
  				filetab->suffix = ".pyo";
+ #else
+ 			if (strcmp(filetab->suffix, "/pyc") == 0)
+ 				filetab->suffix = "/pyo";
+ #endif
  		}
  	}
***************
*** 843,847 ****
--- 857,863 ----
  	struct filedescr *fdp = NULL;
  	FILE *fp = NULL;
+ #ifndef RISCOS
  	struct stat statbuf;
+ #endif
  	static struct filedescr fd_frozen = {"", "", PY_FROZEN};
  	static struct filedescr fd_builtin = {"", "", C_BUILTIN};
***************
*** 952,955 ****
--- 968,980 ----
  #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;
+ 			}
+ 		}
+ #endif
  #endif
  #ifdef macintosh
***************
*** 1197,1200 ****
--- 1222,1258 ----
  	return 0;
  }
+ 
+ #else
+ 
+ #ifdef RISCOS
+ static int
+ find_init_module(buf)
+ 	char *buf;
+ {
+ 	int save_len = strlen(buf);
+ 	int i = save_len;
+ 
+ 	if (save_len + 13 >= MAXPATHLEN)
+ 		return 0;
+ 	buf[i++] = SEP;
+ 	strcpy(buf+i, "__init__/py");
+ 	if (isfile(buf)) {
+ 		buf[save_len] = '\0';
+ 		return 1;
+ 	}
+ 
+ 	if (Py_OptimizeFlag)
+ 		strcpy(buf+i, "o");
+ 	else
+ 		strcpy(buf+i, "c");
+ 	if (isfile(buf)) {
+ 		buf[save_len] = '\0';
+ 		return 1;
+ 	}
+ 	buf[save_len] = '\0';
+ 	return 0;
+ }
+ #endif /*RISCOS*/
+ 
  #endif /* HAVE_STAT */