Changeset 6283 for lang/perl/Encode
- Timestamp:
- 02/06/08 14:51:24 (5 years ago)
- Location:
- lang/perl/Encode/branches/callback-args
- Files:
-
- 2 modified
-
Encode.xs (modified) (4 diffs)
-
t/fallback.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Encode/branches/callback-args/Encode.xs
r1747 r6283 65 65 66 66 static SV * 67 do_fallback_cb(pTHX_ UV ch, SV *fallback_cb )67 do_fallback_cb(pTHX_ UV ch, SV *fallback_cb, const encode_t * enc, const method) 68 68 { 69 69 dSP; … … 74 74 PUSHMARK(sp); 75 75 XPUSHs(sv_2mortal(newSVnv((UV)ch))); 76 XPUSHs(sv_2mortal(newSVpv(enc->name[0], 0))); 77 XPUSHs(sv_2mortal(newSVpv(method, 0))); 76 78 PUTBACK; 77 79 argc = call_sv(fallback_cb, G_SCALAR); … … 196 198 SV* subchar = 197 199 (fallback_cb != &PL_sv_undef) 198 ? do_fallback_cb(aTHX_ ch, fallback_cb )200 ? do_fallback_cb(aTHX_ ch, fallback_cb, enc, "encode") 199 201 : newSVpvf(check & ENCODE_PERLQQ ? "\\x{%04"UVxf"}" : 200 202 check & ENCODE_HTMLCREF ? "&#%" UVuf ";" : … … 231 233 SV* subchar = 232 234 (fallback_cb != &PL_sv_undef) 233 ? do_fallback_cb(aTHX_ (UV)s[slen], fallback_cb )235 ? do_fallback_cb(aTHX_ (UV)s[slen], fallback_cb, enc, "decode") 234 236 : newSVpvf("\\x%02" UVXf, (UV)s[slen]); 235 237 sdone += slen + 1; -
lang/perl/Encode/branches/callback-args/t/fallback.t
r1747 r6283 18 18 use strict; 19 19 #use Test::More qw(no_plan); 20 use Test::More tests => 48;20 use Test::More tests => 50; 21 21 use Encode q(:all); 22 22 … … 176 176 $dst = decode("ascii", (pack "C*", 0xFF), sub{ $_[0] }); 177 177 is $dst, 0xFF."", qq{decode("ascii", (pack "C*", 0xFF), sub{ \$_[0] })}; 178 179 $src = "\x{3000}"; 180 $dst = $ascii->encode($src, sub{ join "-", @_ }); 181 is $dst, 0x3000."-ascii-encode", "encode fallback with encoding name"; 182 183 $src = pack "C*", 0xFF; 184 $dst = $ascii->decode($src, sub{ join "-", @_ }); 185 is $dst, 0xFF."-ascii-decode", "decode fallback with encoding name";
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)