develooper Front page | perl.perl5.porters | Postings from February 2003

patch to use compressed module using gzip layer

Thread Next
From:
=?ISO-8859-1?Q?Fran=E7ois?= Pons
Date:
February 13, 2003 06:18
Subject:
patch to use compressed module using gzip layer
Message ID:
1045146355.3982.11.camel@ackbar.mandrakesoft.com
Hello,

Here is a patch wich allow using compressed module with PerlIO-gzip.

It sounds to work correctly and load automatically the gzip layer if
installed.

François.

--- perl-5.8.0/pp_ctl.c.fpons   2002-07-09 18:42:38.000000000 +0200
+++ perl-5.8.0/pp_ctl.c 2003-02-13 11:56:39.000000000 +0100
@@ -2882,6 +2882,19 @@
     else {
        fp = PerlIO_open(name, mode);
     }
+    if (!fp) {
+       SV *pmgzsv = Perl_newSVpvf(aTHX_ "%s%s", name, ".gz");
+       char *pmgz = SvPV_nolen(pmgzsv);
+       Stat_t pmgzstat;
+       if (PerlLIO_stat(pmgz, &pmgzstat) < 0) {
+           SvREFCNT_dec(pmgzsv);
+       }
+       else {
+           dTHX;
+           pmgzsv = sv_2mortal(pmgzsv);
+           fp = PerlIO_openn(aTHX_ ":gzip", mode, -1, 0, 0, NULL, 1,
&pmgzsv);
+       }
+    }
     return fp;
 }


Thread Next


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