Change 17663: Count line numbers properly in MacPerl app

[email protected] (Chris Nandor) Mon, 29 Jul 2002 15:55:45 -0400
Newsgroups perl.perl5.changes.mac
Message-ID <p05111b0fb96b4e222e6b@[10.0.1.177]>
Change 17663 by pudge@pudge-mobile on 2002/07/29 18:25:57

	Count line numbers properly in MacPerl app

Affected files ...

.... //depot/maint-5.6/macperl/perl.c#10 edit

Differences ...

==== //depot/maint-5.6/macperl/perl.c#10 (text) ====
Index: macperl/perl.c
--- macperl/perl.c#9~17651~	Mon Jul 22 20:24:35 2002
+++ macperl/perl.c	Mon Jul 29 11:25:57 2002
@@ -3054,6 +3054,9 @@
 S_find_beginning(pTHX)
 {
     register char *s, *s2;
+#ifdef MACOS_TRADITIONAL
+    int maclines = 0;
+#endif
 
     /* skip forward in input to the real script? */
 
@@ -3064,7 +3067,7 @@
 	if ((s = sv_gets(PL_linestr, PL_rsfp, 0)) == Nullch) {
 	    if (!gMacPerl_AlwaysExtract)
 		Perl_croak(aTHX_ "No Perl script found in input\n");
-		
+
 	    if (PL_doextract)			/* require explicit override ? */
 		if (!OverrideExtract(PL_origfilename))
 		    Perl_croak(aTHX_ "User aborted script\n");
@@ -3095,7 +3098,18 @@
 			;
 	    }
 #ifdef MACOS_TRADITIONAL
+	    /* We are always searching for the #!perl line in MacPerl,
+	     * so if we find it, still keep the line count correct
+	     * by counting lines we already skipped over
+	     */
+	    for (; maclines > 0 ; maclines--)
+		PerlIO_ungetc(PL_rsfp, '\n');
+
 	    break;
+
+	/* gMacPerl_AlwaysExtract is false in MPW tool */
+	} else if (gMacPerl_AlwaysExtract) {
+	    ++maclines;
 #endif
 	}
     }
End of Patch.
-- 
Chris Nandor                      [email protected]    http://pudge.net/
Open Source Development Network    [email protected]     http://osdn.com/