perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@cpan.org>
Subject [mp1 Patch] $r->print() handling of $\
Date Thu, 22 May 2003 08:35:24 GMT
For the original report, see:
http://marc.theaimsgroup.com/?l=apache-modperl&m=102874705105904&w=2

Basically, perlvar says that $\ (awk-ish) gets appended to the end of
each call to print().

Following patch attempts to implement this:

$/ is either

char *PL_ors and STRLEN PL_orslen (Perl < 5.8)
or
SV *PL_ors_sv (Perl >5.8)

So that's what those #ifdef are for.

All tests pass OK for me with this.


? t/conf/dev-null
Index: Changes
===================================================================
RCS file: /home/cvs/modperl/Changes,v
retrieving revision 1.666
diff -u -I$Id -r1.666 Changes
--- Changes	7 Apr 2003 23:16:23 -0000	1.666
+++ Changes	22 May 2003 08:34:52 -0000
@@ -10,6 +10,9 @@
 
 =item 1.27_01-dev
 
+$r->print() now honors $\, the output record separator 
+[Philippe M. Chiasson <gozer@cpan.org>]
+
 Tweak mod_perl.h to defined _INCLUDE_APACHE_FIRST only after apache
 headers were included [Stas Bekman]
 
Index: STATUS
===================================================================
RCS file: /home/cvs/modperl/STATUS,v
retrieving revision 1.21
diff -u -I$Id -r1.21 STATUS
--- STATUS	7 Aug 2002 19:39:00 -0000	1.21
+++ STATUS	22 May 2003 08:34:52 -0000
@@ -21,13 +21,6 @@
 
 Needs Patch or Further Investigation
 
-    * $r->print() ignores $\
-        Report: http://marc.theaimsgroup.com/?l=apache-modperl&m=102874705105904&w=2
-        Status:
-          not sure what to do with this, just sv_catpvn(sv, $\, 1) in Apache.xs's print()?
-          does that handle everything? (assuming I can figure out how to dig out 
-          what's in $\)  is this really important? --Geoff
-
     * make test fails when a wrong combination of URI and LWP are
       installed. (e.g. lwp 5.64 and URI 1.09). LWP's Makefile.PL
       requires the right URI version, but certain binary distributors
Index: src/modules/perl/Apache.xs
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.127
diff -u -I$Id -r1.127 Apache.xs
--- src/modules/perl/Apache.xs	14 Mar 2003 06:05:06 -0000	1.127
+++ src/modules/perl/Apache.xs	22 May 2003 08:34:52 -0000
@@ -1137,6 +1137,15 @@
 	CV *cv = GvCV(gv_fetchpv("Apache::write_client", FALSE, SVt_PVCV));
 	soft_timeout("mod_perl: Apache->print", r);
 	PUSHMARK(mark);
+#ifdef PL_ors_sv
+    if(PL_ors_sv && SvOK(PL_ors_sv))
+        XPUSHs(PL_ors_sv);
+#endif
+#ifdef PL_orslen
+    if(PL_orslen)
+        XPUSHp(PL_ors, PL_orslen);
+#endif
+    PUTBACK;
 #ifdef PERL_OBJECT
 	(void)(*CvXSUB(cv))(cv, pPerl); /* &Apache::write_client; */
 #else
Index: t/internal/ors.t
===================================================================
RCS file: t/internal/ors.t
diff -N t/internal/ors.t
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ t/internal/ors.t	22 May 2003 08:34:52 -0000
@@ -0,0 +1,9 @@
+use Apache::test;
+
+my $sent = fetch "/perl/ors.pl";
+my $i = 0;
+
+print "1..1\n";
+
+my $string = "ABC\nD\nE_ORS_F_ORS_G";
+test ++$i, $sent eq $string;
Index: t/net/perl/ors.pl
===================================================================
RCS file: t/net/perl/ors.pl
diff -N t/net/perl/ors.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ t/net/perl/ors.pl	22 May 2003 08:34:52 -0000
@@ -0,0 +1,22 @@
+#!perl
+my $r = Apache->request;
+$r->content_type("text/plain");
+$r->send_http_header;
+
+$r->print('A');
+$r->print('B');
+{
+	local $\ = "\n";
+	$r->print('C');
+	$r->print('D');
+}
+
+{
+	local $\ = "_ORS_";
+	$r->print('E');
+	$r->print('F');
+}
+
+$r->print('G');
+
+



-- 
-- -----------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'

Mime
View raw message