develooper Front page | perl.perl5.porters | Postings from July 2001

[PATCH pp_ctl.c] proposed Windows safe-guard

Thread Next
From:
Jeff 'japhy/Marillion' Pinyan
Date:
July 30, 2001 14:49
Subject:
[PATCH pp_ctl.c] proposed Windows safe-guard
Message ID:
Pine.GSO.4.21.0107301739390.28213-200000@crusoe.crusoe.net
--- pp_ctl.c.old	Mon Jul 30 15:15:07 2001
+++ pp_ctl.c	Mon Jul 30 17:48:25 2001
@@ -3043,6 +3043,7 @@
     GV *filter_child_proc = 0;
     SV *filter_state = 0;
     SV *filter_sub = 0;
+    OP *eval_result;  /* japhy (07/30/01) for no package test at bottom */
 
     sv = POPs;
     if (SvNIOKp(sv)) {
@@ -3104,6 +3105,7 @@
 	}
     }
     name = SvPV(sv, len);
+
     if (!(name && len > 0 && *name))
 	DIE(aTHX_ "Null filename used");
     TAINT_PROPER("require");
@@ -3374,7 +3376,48 @@
     PL_eval_owner = thr;
     MUTEX_UNLOCK(&PL_eval_mutex);
 #endif /* USE_THREADS */
-    return DOCATCH(doeval(gimme, NULL));
+
+    /*
+	japhy (07/30/2001)
+	test to see if a stash of the name of the file has been created
+	if the require()d file was a module -- 'use Strict' works on Windows
+    */
+
+    eval_result = doeval(gimme, NULL);
+
+#ifdef WIN32
+    if (strcmp(name + len - 3, ".pm")) {
+	char *pkg;
+	int slash_count = 0, i = 0;
+
+	for (i = 0; i < len - 3; i++) {
+	    if (name[i] == '/') slash_count++;
+	}
+
+	/* "Foo/Bar.pm" + 1 (slash) - 3 (".pm") + 1 ("\0") */
+	pkg = malloc(sizeof(char) * (len + slash_count - 3 + 1));
+
+	slash_count = 0;
+
+	for (i = 0; i < len - 3; i++) {
+	    if (name[i] == '/') {
+		pkg[i + slash_count] = ':';
+		pkg[i + ++slash_count] = ':';
+	    }
+	    else pkg[i + slash_count] = name[i];
+	}
+	pkg[i + slash_count] = '\0';
+
+	if (!gv_stashpv(pkg, FALSE))
+	    Perl_warner(
+		aTHX_ WARN_MISC,
+		"Package `%s' not found (did you use the incorrect case?)",
+		pkg
+	    );
+    }
+#endif
+
+    return DOCATCH(eval_result);
 }
 
 PP(pp_dofile)

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About