diff Python/import.c @ 7305:067e4813c6d6 legacy-trunk

Added DJGPP version of check_case(), by Pit Scrorpion (Hans Nowak). (BTW, the Mac version was by Jack Jansen.)
author Guido van Rossum <guido@python.org>
date Fri, 13 Feb 1998 23:27:59 +0000
parents 72d531d54572
children 0c79cafec4bc
line wrap: on
line diff
--- a/Python/import.c	Fri Feb 13 22:22:36 1998 +0000
+++ b/Python/import.c	Fri Feb 13 23:27:59 1998 +0000
@@ -1005,6 +1005,34 @@
 }
 #endif /* macintosh */
 
+#ifdef DJGPP
+static int
+check_case(char *buf, int len, int namelen, char *name)
+{
+	struct ffblk ffblk;
+	int done;
+
+	if (getenv("PYTHONCASEOK") != NULL)
+		return 1;
+	done = findfirst(buf, &ffblk, FA_ARCH|FA_RDONLY|FA_HIDDEN);
+	if (done) {
+		PyErr_Format(PyExc_NameError,
+		  "Can't find file for module %.100s\n(filename %.300s)",
+		  name, buf);
+		return 0;
+	}
+
+	if (strncmp(ffblk.ff_name, name, namelen) != 0) {
+		strcpy(buf+len-namelen, ffblk.ff_name);
+		PyErr_Format(PyExc_NameError,
+		  "Case mismatch for module name %.100s\n(filename %.300s)",
+		  name, buf);
+		return 0;
+	}
+	return 1;
+}
+#endif
+
 #endif CHECK_IMPORT_CASE
 
 #ifdef HAVE_STAT