chiark / gitweb /
Commit 2.4.5-5 as unpacked
[inn-innduct.git] / debian / patches / fix_body_regexps
1 Fix the correct handling of bodies (Perl regexps were sometimes
2 not properly working on SV * bodies).  We now use a shared string.
3 For Perl < 5.7.1, fall back to a copy of such bodies.  At least,
4 that method is reliable, even though it were 17% slower.
5
6 http://inn.eyrie.org/viewcvs/branches/2.4/include/ppport.h?r1=7237&r2=7951&pathrev=7951&view=patch
7 http://inn.eyrie.org/viewcvs/branches/2.4/innd/perl.c?r1=7815&r2=7951&pathrev=7951&view=patch
8
9 --- 2.4/innd/perl.c     2008/05/05 08:43:58     7815
10 +++ 2.4/innd/perl.c     2008/08/05 19:41:17     7951
11 @@ -69,7 +69,6 @@
12      CV *        filter;
13      int         i, rc;
14      char *      p;
15 -    static SV * body = NULL;
16      static char buf[256];
17  
18      if (!PerlFilterActive) return NULL;
19 @@ -87,23 +86,19 @@
20      }
21  
22      /* Store the article body.  We don't want to make another copy of it,
23 -       since it could potentially be quite large.  Instead, stash the
24 -       pointer in the static SV * body.  We set LEN to 0 and inc the
25 -       refcount to tell Perl not to free it (either one should be enough).
26 -       Requires 5.004.  In testing, this produced a 17% speed improvement
27 -       over making a copy of the article body for a fairly heavy filter. */
28 +     * since it could potentially be quite large.  In testing, this produced
29 +     * a 17% speed improvement over making a copy of the article body
30 +     * for a fairly heavy filter.
31 +     * Available since Perl 5.7.1, newSVpvn_share allows to avoid such
32 +     * a copy (getting round its use for older versions of Perl leads
33 +     * to unreliable SV * bodies as for regexps).  And for Perl not to
34 +     * compute a hash for artBody, we give it "42". */
35      if (artBody) {
36 -        if (!body) {
37 -            body = newSV(0);
38 -            (void) SvUPGRADE(body, SVt_PV);
39 -        }
40 -        SvPVX(body) = artBody;
41 -        SvCUR_set(body, artLen);
42 -        SvLEN_set(body, 0);
43 -        SvPOK_on(body);
44 -        (void) SvREADONLY_on(body);
45 -        (void) SvREFCNT_inc(body);
46 -        hv_store(hdr, "__BODY__", 8, body, 0);
47 +#if (PERL_REVISION == 5) && ((PERL_VERSION < 7) || ((PERL_VERSION == 7) && (PERL_SUBVERSION < 1)))
48 +        hv_store(hdr, "__BODY__", 8, newSVpv(artBody, artLen), 0);
49 +#else
50 +        hv_store(hdr, "__BODY__", 8, newSVpvn_share(artBody, artLen, 42), 0);
51 +#endif /* Perl < 5.7.1 */
52      }
53  
54      hv_store(hdr, "__LINES__", 9, newSViv(lines), 0);
55 --- 2.4/include/ppport.h        2005/06/05 21:57:50     7237
56 +++ 2.4/include/ppport.h        2008/08/05 19:41:17     7951
57 @@ -150,6 +150,7 @@
58  #      endif
59  #endif
60  #ifndef PERL_VERSION
61 +#       define PERL_REVISION (5)
62  #       ifdef PERL_PATCHLEVEL
63  #               define PERL_VERSION    PERL_PATCHLEVEL
64  #       else
65 @@ -162,7 +163,7 @@
66  #      define ERRSV perl_get_sv("@",false)
67  #endif
68  
69 -#if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 4))
70 +#if (PERL_REVISION == 5) && ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 4)))
71  #      define PL_sv_undef      sv_undef
72  #      define PL_sv_yes        sv_yes
73  #      define PL_sv_no         sv_no
74 @@ -174,7 +175,7 @@
75  #      define PL_copline       copline
76  #endif
77  
78 -#if (PERL_VERSION < 5)
79 +#if (PERL_REVISION == 5) && (PERL_VERSION < 5)
80  #      undef dTHR
81  #      ifdef WIN32
82  #              define dTHR extern int Perl___notused