develooper Front page | perl.unicode | Postings from September 2006

Re: utf8::encode causes can't find SWASHNEW error

Thread Previous
From:
SADAHIRO Tomoyuki
Date:
September 8, 2006 07:13
Subject:
Re: utf8::encode causes can't find SWASHNEW error
Message ID:
20060908230147.A74B.BQW10602@nifty.com

On Fri, 08 Sep 2006 08:55:15 +0200, Andreas J. Koenig wrote

> I cannot explain, so I'm tempted to call it a bug.
> 
> Apparently some code looks up the symbol table and if utf8:: is there,
> then it does something that usually is only available when utf8 is
> loaded. So by actually making sure utf8 is loaded, you give that code
> what it needs.

Right. The old assumption was that if the stash for utf8:: exists
then utf8->SWASHNEW can be called. That's obviously wrong.

Unfortunately the fix against utf8.c included in the change 9200
(see below) was not integrated into the 5.6 maintenance track,
though the fix had been integrated into the 5.7 development track
before the release of 5.6.1.

[A part of change 9200]
==== //depot/perl/utf8.c#93 (text) ====

@@ -1282,8 +1282,9 @@
     SV* retval;
     SV* tokenbufsv = sv_2mortal(NEWSV(0,0));
     dSP;
+    HV *stash = gv_stashpvn(pkg, strlen(pkg), FALSE);
 
-    if (!gv_stashpv(pkg, 0)) {	/* demand load utf8 */
+    if (!gv_fetchmeth(stash, "SWASHNEW", 8, -1)) {	/* demand load utf8 */
 	ENTER;
 	Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpv(pkg,0), Nullsv);
 	LEAVE;

Regards,
SADAHIRO Tomoyuki



Thread Previous


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