diff options
author | David Mitchell <davem@iabyn.com> | 2014-05-08 13:30:16 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-05-08 13:30:16 +0100 |
commit | 89c2544cd319141dbdce6c8408aa52896c2549f1 (patch) | |
tree | fc1fb838597e216abd09e798fa557b57f714fccc /cpan | |
parent | c7981a06d5acac597f1bcbdd7664eb04ee6ad5bd (diff) | |
download | perl-89c2544cd319141dbdce6c8408aa52896c2549f1.tar.gz |
Fix Encode 2.60 with g++
The recently added Encode 2.60 won't compile with g++, due to assigning
a const char * const pointer to a char* struct field.
The intent of the code itself is a bit unclear, but it appears to be
to set SvPVX as a read-only alias of a const string, using the SvLEN()=0
trick to avoid it being freed.
Fix the g++ builds by casting away the constness, and add some asserts and
comments to make it less unclear what's going on.
Diffstat (limited to 'cpan')
-rw-r--r-- | cpan/Encode/Byte/Makefile.PL | 5 | ||||
-rw-r--r-- | cpan/Encode/CN/Makefile.PL | 5 | ||||
-rw-r--r-- | cpan/Encode/EBCDIC/Makefile.PL | 5 | ||||
-rw-r--r-- | cpan/Encode/Encode.pm | 2 | ||||
-rw-r--r-- | cpan/Encode/Encode.xs | 5 | ||||
-rw-r--r-- | cpan/Encode/Encode/Makefile_PL.e2x | 5 | ||||
-rw-r--r-- | cpan/Encode/JP/Makefile.PL | 5 | ||||
-rw-r--r-- | cpan/Encode/KR/Makefile.PL | 5 | ||||
-rw-r--r-- | cpan/Encode/Symbol/Makefile.PL | 5 | ||||
-rw-r--r-- | cpan/Encode/TW/Makefile.PL | 5 | ||||
-rw-r--r-- | cpan/Encode/bin/enc2xs | 5 |
11 files changed, 41 insertions, 11 deletions
diff --git a/cpan/Encode/Byte/Makefile.PL b/cpan/Encode/Byte/Makefile.PL index 58deaf39a6..0cc5ece4fb 100644 --- a/cpan/Encode/Byte/Makefile.PL +++ b/cpan/Encode/Byte/Makefile.PL @@ -120,8 +120,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) diff --git a/cpan/Encode/CN/Makefile.PL b/cpan/Encode/CN/Makefile.PL index efd2edb90f..5e689cb75b 100644 --- a/cpan/Encode/CN/Makefile.PL +++ b/cpan/Encode/CN/Makefile.PL @@ -96,8 +96,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) diff --git a/cpan/Encode/EBCDIC/Makefile.PL b/cpan/Encode/EBCDIC/Makefile.PL index 7a3a4cb89c..50ae0df257 100644 --- a/cpan/Encode/EBCDIC/Makefile.PL +++ b/cpan/Encode/EBCDIC/Makefile.PL @@ -77,8 +77,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) diff --git a/cpan/Encode/Encode.pm b/cpan/Encode/Encode.pm index 9dc970b299..5d477f6bde 100644 --- a/cpan/Encode/Encode.pm +++ b/cpan/Encode/Encode.pm @@ -4,7 +4,7 @@ package Encode; use strict; use warnings; -our $VERSION = sprintf "%d.%02d", q$Revision: 2.60 $ =~ /(\d+)/g; +our $VERSION = sprintf "%d.%02d", q$Revision: 2.60_01 $ =~ /(\d+)/g; use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG}; use XSLoader (); XSLoader::load( __PACKAGE__, $VERSION ); diff --git a/cpan/Encode/Encode.xs b/cpan/Encode/Encode.xs index 18c982ac47..e08101add5 100644 --- a/cpan/Encode/Encode.xs +++ b/cpan/Encode/Encode.xs @@ -47,8 +47,11 @@ Encode_XSEncoding(pTHX_ encode_t * enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) { diff --git a/cpan/Encode/Encode/Makefile_PL.e2x b/cpan/Encode/Encode/Makefile_PL.e2x index b78656769d..c17a5096f7 100644 --- a/cpan/Encode/Encode/Makefile_PL.e2x +++ b/cpan/Encode/Encode/Makefile_PL.e2x @@ -113,8 +113,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) diff --git a/cpan/Encode/JP/Makefile.PL b/cpan/Encode/JP/Makefile.PL index cb671b60d4..6ec73eac35 100644 --- a/cpan/Encode/JP/Makefile.PL +++ b/cpan/Encode/JP/Makefile.PL @@ -96,8 +96,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) diff --git a/cpan/Encode/KR/Makefile.PL b/cpan/Encode/KR/Makefile.PL index fa6f0d8042..0790ed08b4 100644 --- a/cpan/Encode/KR/Makefile.PL +++ b/cpan/Encode/KR/Makefile.PL @@ -94,8 +94,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) diff --git a/cpan/Encode/Symbol/Makefile.PL b/cpan/Encode/Symbol/Makefile.PL index b525610369..2dec60d53f 100644 --- a/cpan/Encode/Symbol/Makefile.PL +++ b/cpan/Encode/Symbol/Makefile.PL @@ -82,8 +82,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) diff --git a/cpan/Encode/TW/Makefile.PL b/cpan/Encode/TW/Makefile.PL index c7711d9655..69b3e96242 100644 --- a/cpan/Encode/TW/Makefile.PL +++ b/cpan/Encode/TW/Makefile.PL @@ -92,8 +92,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) diff --git a/cpan/Encode/bin/enc2xs b/cpan/Encode/bin/enc2xs index 966c456765..c44487d0c2 100644 --- a/cpan/Encode/bin/enc2xs +++ b/cpan/Encode/bin/enc2xs @@ -316,8 +316,11 @@ Encode_XSEncoding(pTHX_ encode_t *enc) SV *iv = newSViv(PTR2IV(enc)); SV *sv = sv_bless(newRV_noinc(iv),stash); int i = 0; + /* with the SvLEN() == 0 hack, PVX won't be freed. We cast away name's + constness, in the hope that perl won't mess with it. */ + assert(SvTYPE(iv) >= SVt_PV); assert(SvLEN(iv) == 0); SvFLAGS(iv) |= SVp_POK; - SvPVX(iv) = enc->name[0]; + SvPVX(iv) = (char*) enc->name[0]; PUSHMARK(sp); XPUSHs(sv); while (enc->name[i]) |