From: Gurusamy Sarathy <gsar@cpan.org>
Date: Fri, 24 Sep 1999 18:19:54 +0000 (+0000)
Subject: avoid infinite recursive exec()s of perl.exe when shebang
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=84e30d1a3b7cc368d7f93dd2b009e9fd64756759;p=p5sagit%2Fp5-mst-13.2.git

avoid infinite recursive exec()s of perl.exe when shebang
contains "Perl" rather than "perl" on DOSISH platforms

p4raw-id: //depot/perl@4225
---

diff --git a/toke.c b/toke.c
index 5280054..1691542 100644
--- a/toke.c
+++ b/toke.c
@@ -2425,8 +2425,24 @@ Perl_yylex(pTHX)
 		 * Look for options.
 		 */
 		d = instr(s,"perl -");
-		if (!d)
+		if (!d) {
 		    d = instr(s,"perl");
+#if defined(DOSISH)
+		    /* avoid getting into infinite loops when shebang
+		     * line contains "Perl" rather than "perl" */
+		    if (!d) {
+			for (d = ipathend-4; d >= ipath; --d) {
+			    if ((*d == 'p' || *d == 'P')
+				&& !ibcmp(d, "perl", 4))
+			    {
+				break;
+			    }
+			}
+			if (d < ipath)
+			    d = Nullch;
+		    }
+#endif
+		}
 #ifdef ALTERNATE_SHEBANG
 		/*
 		 * If the ALTERNATE_SHEBANG on this system starts with a