develooper Front page | perl.perl5.porters | Postings from March 2000

Source filters

From:
Moore, Paul
Date:
March 24, 2000 03:59
Subject:
Source filters
Message ID:
714DFA46B9BBD0119CD000805FC1F53BDC3A69@UKRUX002.rundc.uk.origin-it.com
Hi,
I notice that source filters are documented in Perl 5.6.0 (perldoc
perlfilter) but that the Filter module (which the documentation refers to)
does not seem to be included in the core. Am I right in assuming that there
is still a need to get Filter (1.17 is the latest version I've seen) from
CPAN?

If so, there are some problems with Filter-1.17 when used with a Perl built
with MULTI/ITHREADS/IMP_SYS on Win32. Specifically, the filter callback
functions seem to be missing the appropriate scattering of pTHXo_ in the
declarations. I've attached a patch for this.

However there are still test failures. 

t/call fails with errors which look related to binmode scripts (test 24 is
failing and it uses filter_read_exact, which may be going wrong because each
line has an extra character (CR) beyond what is expected.
t/decrypt, t/order and t/tee fail as well, which may be similar.
Worse are t/cpp, t/exec and t/sh, which crash Perl. I can't see why.

I think the binmode scripts thing is going to be a nasty portability
problem. IMHO, the user of the Filter module should not have to worry about
line ending conventions in scripts. Of course, if the filter is slurping in
binary data and translating it, binmode is necessary (that's why it was
introduced, for byteloader). Maybe the filter module needs something in the
API to request binmode or textmode input of the script (with textmode the
default, as I expect the majority of filters will be text-based).

This is starting to look hard...
Paul.

I'll do some more investigation on the test crashes tonight.

---- Patch to add pTHXo_ ----

diff -u Call\Call.xs.orig Call\Call.xs
--- Call\Call.xs.orig	Tue May 25 20:09:28 1999
+++ Call\Call.xs	Fri Mar 24 11:28:36 2000
@@ -33,10 +33,7 @@
 static int current_idx ;
 
 static I32
-filter_call(idx, buf_sv, maxlen)
-    int idx;
-    SV *buf_sv;
-    int maxlen;
+filter_call(pTHXo_ int idx, SV* buf_sv, int maxlen)
 {
     SV   *my_sv = FILTER_DATA(idx);
     char *nl = "\n";
diff -u decrypt\decrypt.xs.orig decrypt\decrypt.xs
--- decrypt\decrypt.xs.orig	Tue May 25 20:09:28 1999
+++ decrypt\decrypt.xs	Fri Mar 24 11:29:46 2000
@@ -146,10 +146,7 @@
 }
 
 static I32
-filter_decrypt(idx, buf_sv, maxlen)
-    int idx;
-    SV *buf_sv;
-    int maxlen;
+filter_decrypt(pTHXo_ int idx, SV* buf_sv, int maxlen)
 {
     SV   *my_sv = FILTER_DATA(idx);
     char *nl = "\n";
diff -u Exec\Exec.xs.orig Exec\Exec.xs
--- Exec\Exec.xs.orig	Tue May 25 20:09:28 1999
+++ Exec\Exec.xs	Fri Mar 24 11:29:06 2000
@@ -457,10 +457,7 @@
 
 
 static I32
-filter_exec(idx, buf_sv, maxlen)
-    int idx;
-    SV *buf_sv;
-    int maxlen;
+filter_exec(pTHXo_ int idx, SV* buf_sv, int maxlen)
 {
     I32 len;
     SV   *buffer = FILTER_DATA(idx);
diff -u tee\tee.xs.orig tee\tee.xs
--- tee\tee.xs.orig	Tue May 25 20:09:28 1999
+++ tee\tee.xs	Fri Mar 24 11:29:27 2000
@@ -12,10 +12,7 @@
 #include "XSUB.h"
 
 static I32
-filter_tee(idx, buf_sv, maxlen)
-    int idx;
-    SV * buf_sv ;
-    int maxlen;
+filter_tee(pTHXo_ int idx, SV* buf_sv, int maxlen)
 {
     I32 len;
     FILE * fil = (FILE*) SvIV(FILTER_DATA(idx)) ;



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