Here is my second attempt at $r->print(), notice I removed the MP_USE_AP_RWRITE
since it wasn't needed anymore.
All test still pass with my patch applied.
Here is the patch #2 and I even think it's proprely indented ;-)
Index: todo/api.txt
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/todo/api.txt,v
retrieving revision 1.2
diff -u -I'$Id' -I'$Revision' -r1.2 api.txt
--- todo/api.txt 2001/09/08 18:26:46 1.2
+++ todo/api.txt 2001/09/11 03:13:19
@@ -68,9 +68,6 @@
however, $r->sendfile is a new function that opens the file for you
and calls ap_send_fd() underneath.
-$r->print:
-does not yet honor $|
-
$r->{hard,reset,soft,kill}_timeout:
do not exist in 2.0. should be deprecated. consider adding noops in
Apache::compat
Index: xs/Apache/RequestIO/Apache__RequestIO.h
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/xs/Apache/RequestIO/Apache__RequestIO.h,v
retrieving revision 1.12
diff -u -I'$Id' -I'$Revision' -r1.12 Apache__RequestIO.h
--- xs/Apache/RequestIO/Apache__RequestIO.h 2001/06/20 23:59:37 1.12
+++ xs/Apache/RequestIO/Apache__RequestIO.h 2001/09/11 03:13:19
@@ -1,17 +1,8 @@
#define mpxs_Apache__RequestRec_TIEHANDLE(stashsv, sv) \
modperl_newSVsv_obj(aTHX_ stashsv, sv)
-#define mpxs_Apache__RequestRec_PRINT mpxs_ap_rvputs
+#define mpxs_Apache__RequestRec_PRINT mpxs_ap_rvprint
-#if 0
-#define MP_USE_AP_RWRITE
-#endif
-
-#ifdef MP_USE_AP_RWRITE
-
-#define mpxs_call_rwrite(r,buf,len) \
-ap_rwrite(buf, len, r)
-
#define mpxs_rwrite_loop(func,obj) \
while (MARK <= SP) { \
STRLEN len; \
@@ -20,9 +11,34 @@
bytes += wlen; \
MARK++; \
}
-
-#endif
+static MP_INLINE apr_size_t mpxs_ap_rvprint(pTHX_ I32 items,
+ SV ** MARK, SV ** SP)
+{
+ modperl_config_srv_t *scfg;
+ modperl_config_req_t *rcfg;
+ request_rec *r;
+
+ /* bytes must be called bytes */
+ apr_size_t bytes = 0;
+
+ /* this also magically assings to r ;-) */
+ mpxs_usage_va_1(r, "$r->print(...)");
+
+ rcfg = modperl_config_req_get(r);
+ scfg = modperl_config_srv_get(r->server);
+
+ mpxs_write_loop(modperl_wbucket_write, &rcfg->wbucket);
+
+ /* if ($|) */
+ if(IoFLUSH(PL_defoutgv)){
+ modperl_wbucket_flush(&rcfg->wbucket);
+ ap_rflush(r);
+ }
+
+ return bytes;
+}
+
static MP_INLINE apr_size_t mpxs_ap_rvputs(pTHX_ I32 items,
SV **MARK, SV **SP)
{
@@ -39,11 +55,7 @@
MP_START_TIMES();
-#ifdef MP_USE_AP_RWRITE
- mpxs_rwrite_loop(mpxs_call_rwrite, r);
-#else
mpxs_write_loop(modperl_wbucket_write, &rcfg->wbucket);
-#endif
MP_END_TIMES();
MP_PRINT_TIMES("r->puts");
Index: xs/maps/apache_functions.map
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/xs/maps/apache_functions.map,v
retrieving revision 1.29
diff -u -I'$Id' -I'$Revision' -r1.29 apache_functions.map
--- xs/maps/apache_functions.map 2001/09/10 04:56:13 1.29
+++ xs/maps/apache_functions.map 2001/09/11 03:13:19
@@ -95,6 +95,7 @@
~ap_rprintf
!ap_rputc
~ap_rputs
+ ap_rvprint | mpxs_ | ... | print
ap_rvputs | mpxs_ | ... | puts
-ap_vrprintf
Index: lib/Apache/compat.pm
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/lib/Apache/compat.pm,v
retrieving revision 1.10
diff -u -I'$Id' -I'$Revision' -r1.10 compat.pm
--- lib/Apache/compat.pm 2001/05/08 18:22:43 1.10
+++ lib/Apache/compat.pm 2001/09/11 03:13:19
@@ -118,8 +118,6 @@
#XXX resolve '.' in @INC to basename $r->filename
}
-*print = \&puts;
-
sub finfo {
my $r = shift;
stat $r->filename;
Index: xs/tables/current/Apache/FunctionTable.pm
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/xs/tables/current/Apache/FunctionTable.pm,v
retrieving revision 1.17
diff -u -I'$Id' -I'$Revision' -r1.17 FunctionTable.pm
--- xs/tables/current/Apache/FunctionTable.pm 2001/09/06 16:41:29 1.17
+++ xs/tables/current/Apache/FunctionTable.pm 2001/09/11 03:13:19
@@ -4093,6 +4093,20 @@
},
{
'return_type' => 'int',
+ 'name' => 'ap_rvprint',
+ 'args' => [
+ {
+ 'type' => 'request_rec *',
+ 'name' => 'r'
+ },
+ {
+ 'type' => '...',
+ 'name' => 'arg1'
+ }
+ ]
+ },
+ {
+ 'return_type' => 'int',
'name' => 'ap_rwrite',
'args' => [
{
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.23
diff -u -I'$Id' -I'$Revision' -r1.23 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm 2001/09/08 18:26:46 1.23
+++ xs/tables/current/ModPerl/FunctionTable.pm 2001/09/11 03:13:19
@@ -3712,6 +3712,28 @@
]
},
{
+ 'return_type' => 'apr_size_t',
+ 'name' => 'mpxs_ap_rvprint',
+ 'args' => [
+ {
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
+ 'type' => 'I32',
+ 'name' => 'items'
+ },
+ {
+ 'type' => 'SV **',
+ 'name' => 'mark'
+ },
+ {
+ 'type' => 'SV **',
+ 'name' => 'sp'
+ }
+ ]
+ },
+ {
'return_type' => 'int',
'name' => 'mpxs_ap_unescape_url',
'args' => [
Index: t/response/TestAPI/request_rec.pm
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/t/response/TestAPI/request_rec.pm,v
retrieving revision 1.5
diff -u -I'$Id' -I'$Revision' -r1.5 request_rec.pm
--- t/response/TestAPI/request_rec.pm 2001/09/08 18:26:46 1.5
+++ t/response/TestAPI/request_rec.pm 2001/09/11 03:13:19
@@ -8,7 +8,7 @@
sub handler {
my $r = shift;
- plan $r, tests => 37;
+ plan $r, tests => 40;
#Apache->request($r); #PerlOptions +GlobalRequest takes care
my $gr = Apache->request;
@@ -88,6 +88,15 @@
#no_cache
ok $r->no_cache || 1;
+
+ {
+ local $| = 0;
+ ok 6 == $r->print("gozer\n");
+ ok 0 == $r->print();
+ local $| = 1;
+ ok 11 == $r->print('g','o','z','e','r',"gozer","\n");
+ }
+
#no_local_copy
--
Philippe M. Chiasson <[EMAIL PROTECTED]>
Extropia's Resident System Guru
http://www.eXtropia.com/
Tonight I just can't face the Muzak.
-- Larry Wall
perl -e '$$=\${gozer};{$_=unpack(P26,pack(L,$$));/^Just Another Perl
Hacker!\n$/&&print||$$++&&redo}'
PGP signature