Skip Menu |
 

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 8736
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: DANKOGAI [...] cpan.org
Requestors: GAAS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Attachments


MIME-Version: 1.0
X-Mailer: MIME-tools 5.411 (Entity 5.404)
Subject: encode(..., Encode::LEAVE_SRC) does not work
Content-Type: multipart/mixed; boundary="----------=_1102158214-5330-0"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 742
Download (untitled) / with headers
text/plain 742b
There is code in the XS implementation that tries to make specifying Encode::LEAVE_SRC in CHECK to work, but the perl wrapper destroys the attempt. The attached patch fixes this problem. BTW, shouldn't FB_PERLQQ, FB_HTMLCREF, FB_XMLCREF all imply LEAVE_SRC? That seems more logial. Demo: bash-2.05b$ perl -MEncode -le 'print decode("utf8", "foo", Encode::FB_PERLQQ)' Modification of a read-only value attempted at /opt/perl/ap811-a118878/lib/5.8.6/i686-linux-thread-multi/Encode.pm line 167. bash-2.05b$ perl -MEncode -le 'print decode("utf8", "foo", Encode::FB_PERLQQ | Encode::LEAVE_SRC)' Modification of a read-only value attempted at /opt/perl/ap811-a118878/lib/5.8.6/i686-linux-thread-multi/Encode.pm line 167.
Content-Type: text/x-diff; name="encode-leave_src.patch"
Content-Disposition: inline; filename="encode-leave_src.patch"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 766
==== //depot/users/gisle/hacks/Encode/Encode.pm#3 - /home/gisle/hacks/Encode/Encode.pm ==== Index: users/gisle/hacks/Encode/Encode.pm --- users/gisle/hacks/Encode/Encode.pm.~1~ Sat Dec 4 12:00:49 2004 +++ users/gisle/hacks/Encode/Encode.pm Sat Dec 4 12:00:49 2004 @@ -148,7 +148,7 @@ Carp::croak("Unknown encoding '$name'"); } my $octets = $enc->encode($string,$check); - $_[1] = $string if $check; + $_[1] = $string if $check && !($check & Encode::LEAVE_SRC()); return $octets; } @@ -164,7 +164,7 @@ Carp::croak("Unknown encoding '$name'"); } my $string = $enc->decode($octets,$check); - $_[1] = $octets if $check; + $_[1] = $octets if $check && !($check & Encode::LEAVE_SRC()); return $string; } End of Patch.
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.411 (Entity 5.404)
X-RT-Original-Encoding: iso-8859-1
Content-Length: 2074
[GAAS - Sat Dec 4 06:03:35 2004]: Show quoted text
> There is code in the XS implementation that tries to > make specifying Encode::LEAVE_SRC in CHECK to work, but > the perl wrapper destroys the attempt. The attached > patch fixes this problem.
In addition to your patch, the patch against Encode/encode.h also makes... Show quoted text
> BTW, shouldn't FB_PERLQQ, FB_HTMLCREF, FB_XMLCREF all > imply LEAVE_SRC? That seems more logial.
FB_* imply LEAVE_SRC. Show quoted text
> Demo: > > bash-2.05b$ perl -MEncode -le 'print decode("utf8", "foo", > Encode::FB_PERLQQ)' > Modification of a read-only value attempted > at /opt/perl/ap811-a118878/lib/5.8.6/i686-linux-thread-multi/Encode.pm > line 167. > bash-2.05b$ perl -MEncode -le 'print decode("utf8", "foo", > Encode::FB_PERLQQ | Encode::LEAVE_SRC)' > Modification of a read-only value attempted > at /opt/perl/ap811-a118878/lib/5.8.6/i686-linux-thread-multi/Encode.pm > line 167.
Now: % perl -Mblib -MEncode -le 'print decode("utf8", "foo",Encode::FB_PERLQQ)' foo Dan the Encode Maintainer ========================================================= ========== RCS file: Encode/encode.h,v retrieving revision 2.0 diff -u -r2.0 Encode/encode.h --- Encode/encode.h 2004/05/16 20:55:15 2.0 +++ Encode/encode.h 2004/12/05 13:33:48 @@ -95,9 +95,9 @@ #define ENCODE_WARN_ON_ERR 0x0002 /* warn on error; may proceed */ #define ENCODE_RETURN_ON_ERR 0x0004 /* immediately returns on NOREP */ #define ENCODE_LEAVE_SRC 0x0008 /* $src updated unless set */ -#define ENCODE_PERLQQ 0x0100 /* perlqq fallback string */ -#define ENCODE_HTMLCREF 0x0200 /* HTML character ref. fb mode */ -#define ENCODE_XMLCREF 0x0400 /* XML character ref. fb mode */ +#define ENCODE_PERLQQ (0x0100|ENCODE_LEAVE_SRC) /* perlqq fallback string */ +#define ENCODE_HTMLCREF (0x0200|ENCODE_LEAVE_SRC) /* HTML character ref. fb mode */ +#define ENCODE_XMLCREF (0x0400|ENCODE_LEAVE_SRC) /* XML character ref. fb mode */ #define ENCODE_FB_DEFAULT 0x0000 #define ENCODE_FB_CROAK 0x0001
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.411 (Entity 5.404)
X-RT-Original-Encoding: iso-8859-1
Content-Length: 954
Download (untitled) / with headers
text/plain 954b
Show quoted text
> In addition to your patch, the patch against Encode/encode.h also > makes...
Oops. Forget the patch above. Use the one below. Dan the Encode Maintainer ========================================================= ==========RCS file: Encode/encode.h,v retrieving revision 2.0 diff -u -r2.0 Encode/encode.h --- Encode/encode.h 2004/05/16 20:55:15 2.0 +++ Encode/encode.h 2004/12/05 13:44:38 @@ -103,8 +103,8 @@ #define ENCODE_FB_CROAK 0x0001 #define ENCODE_FB_QUIET ENCODE_RETURN_ON_ERR #define ENCODE_FB_WARN (ENCODE_RETURN_ON_ERR|ENCODE_WARN_ON_ERR) -#define ENCODE_FB_PERLQQ ENCODE_PERLQQ -#define ENCODE_FB_HTMLCREF ENCODE_HTMLCREF -#define ENCODE_FB_XMLCREF ENCODE_XMLCREF +#define ENCODE_FB_PERLQQ (ENCODE_PERLQQ|ENCODE_LEAVE_SRC) +#define ENCODE_FB_HTMLCREF (ENCODE_HTMLCREF|ENCODE_LEAVE_SRC) +#define ENCODE_FB_XMLCREF (ENCODE_XMLCREF|ENCODE_LEAVE_SRC) #endif /* ENCODE_H */


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.