summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorDan Kogai <dankogai@dan.co.jp>2002-10-22 02:36:02 +0900
committerhv <hv@crypt.org>2002-10-24 23:36:48 +0000
commitd0063567ae6829f18fa94be9ac4f0b3986e32f5a (patch)
tree63f390c01e731f401d0f2b5085864df3a6757bc4 /mg.c
parentab3374e4b7f0adca0bcf6e7b71aaacbfd7df7b07 (diff)
downloadperl-d0063567ae6829f18fa94be9ac4f0b3986e32f5a.tar.gz
The Inaba patch for tr/// vs. use encoding
Message-Id: <218B4434-E4D0-11D6-A668-0003939A104C@dan.co.jp> p4raw-id: //depot/perl@18058
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/mg.c b/mg.c
index 8881f10f79..64f64978a2 100644
--- a/mg.c
+++ b/mg.c
@@ -1846,32 +1846,37 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
DEBUG_x(dump_all());
break;
case '\005': /* ^E */
- if (*(mg->mg_ptr+1) == '\0') {
+ if (*(mg->mg_ptr+1) == '\0') {
#ifdef MACOS_TRADITIONAL
- gMacPerl_OSErr = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
+ gMacPerl_OSErr = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
#else
# ifdef VMS
- set_vaxc_errno(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
+ set_vaxc_errno(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
# else
# ifdef WIN32
- SetLastError( SvIV(sv) );
+ SetLastError( SvIV(sv) );
# else
# ifdef OS2
- os2_setsyserrno(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
+ os2_setsyserrno(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
# else
- /* will anyone ever use this? */
- SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv), 4);
+ /* will anyone ever use this? */
+ SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv), 4);
# endif
# endif
# endif
#endif
- }
- else if (strEQ(mg->mg_ptr+1, "NCODING")) {
- if (PL_encoding)
- sv_setsv(PL_encoding, sv);
- else
- PL_encoding = newSVsv(sv);
- }
+ }
+ else if (strEQ(mg->mg_ptr+1, "NCODING")) {
+ if (PL_encoding)
+ SvREFCNT_dec(PL_encoding);
+ if (SvOK(sv) || SvGMAGICAL(sv)) {
+ PL_encoding = newSVsv(sv);
+ }
+ else {
+ PL_encoding = Nullsv;
+ }
+ }
+ break;
case '\006': /* ^F */
PL_maxsysfd = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
break;