From: Jarkko Hietaniemi Date: Thu, 2 May 2002 14:02:51 +0000 (+0000) Subject: Upgrade to Encode 1.67. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2fc614e01c5e692def72089696c0a1da4f6f3833;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Encode 1.67. p4raw-id: //depot/perl@16344 --- diff --git a/ext/Encode/Changes b/ext/Encode/Changes index a83e914..a4279ef 100644 --- a/ext/Encode/Changes +++ b/ext/Encode/Changes @@ -1,9 +1,17 @@ # Revision history for Perl extension Encode. # -# $Id: Changes,v 1.66 2002/05/01 05:41:06 dankogai Exp dankogai $ +# $Id: Changes,v 1.67 2002/05/02 07:33:09 dankogai Exp $ # -$Revision: 1.66 $ $Date: 2002/05/01 05:41:06 $ +$Revision: 1.67 $ $Date: 2002/05/02 07:33:09 $ +! Encode.xs + Error message now consistent w/ perlqq (\N{U+} -> \x{}) + done in perl@16308 but Philip linted me further. Now the error + messages are macronized as ERR_ENCODE_NOMAP and ERR_DECODE_NOMAP +! lib/Encode/Guess.pm + Sanity check for happier -w by Autrijus + +1.66 2002/05/01 05:41:06 ! Encode.xs t/fallback.t WARN_ON_ERR no longer assumes RETURN_ON_ERR so you can issue a warning while fallback is in effect. This even came with a welcome side-effect @@ -566,7 +574,7 @@ $Revision: 1.66 $ $Date: 2002/05/01 05:41:06 $ Typo fixes and improvements by jhi Message-Id: <200204010201.FAA03564@alpha.hut.fi>, et al. -1.11 $Date: 2002/05/01 05:41:06 $ +1.11 $Date: 2002/05/02 07:33:09 $ + t/encoding.t + t/jperl.t ! MANIFEST diff --git a/ext/Encode/Encode.pm b/ext/Encode/Encode.pm index 80358ee..9686494 100644 --- a/ext/Encode/Encode.pm +++ b/ext/Encode/Encode.pm @@ -1,9 +1,9 @@ # -# $Id: Encode.pm,v 1.66 2002/05/01 05:41:06 dankogai Exp dankogai $ +# $Id: Encode.pm,v 1.67 2002/05/02 07:33:34 dankogai Exp $ # package Encode; use strict; -our $VERSION = do { my @r = (q$Revision: 1.66 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = do { my @r = (q$Revision: 1.67 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our $DEBUG = 0; use XSLoader (); XSLoader::load(__PACKAGE__, $VERSION); diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index 79b2833..dc2ab42 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -1,5 +1,5 @@ /* - $Id: Encode.xs,v 1.43 2002/05/01 05:41:06 dankogai Exp dankogai $ + $Id: Encode.xs,v 1.44 2002/05/02 07:33:09 dankogai Exp $ */ #define PERL_NO_GET_CONTEXT @@ -54,6 +54,9 @@ call_failure(SV * routine, U8 * done, U8 * dest, U8 * orig) } +#define ERR_ENCODE_NOMAP "\"\\x{%04" UVxf "}\" does not map to %s" +#define ERR_DECODE_NOMAP "%s \"\\x%02" UVXf "\" does not map to Unicode" + static SV * encode_method(pTHX_ encode_t * enc, encpage_t * dir, SV * src, int check) @@ -129,15 +132,13 @@ encode_method(pTHX_ encode_t * enc, encpage_t * dir, SV * src, utf8n_to_uvuni(s+slen, (SvCUR(src)-slen), &clen, UTF8_ALLOW_ANY|UTF8_CHECK_ONLY); if (check & ENCODE_DIE_ON_ERR) { - Perl_croak( - aTHX_ "\"\\x{%04" UVxf "}\" does not map to %s", - (UV)ch, enc->name[0]); + Perl_croak(aTHX_ ERR_ENCODE_NOMAP, + (UV)ch, enc->name[0]); return &PL_sv_undef; /* never reaches but be safe */ } if (check & ENCODE_WARN_ON_ERR){ Perl_warner(aTHX_ packWARN(WARN_UTF8), - "\"\\x{%" UVxf "}\" does not map to %s", - (UV)ch, enc->name[0]); + ERR_ENCODE_NOMAP, (UV)ch, enc->name[0]); } if (check & ENCODE_RETURN_ON_ERR){ goto ENCODE_SET_SRC; @@ -170,18 +171,15 @@ encode_method(pTHX_ encode_t * enc, encpage_t * dir, SV * src, /* decoding */ else { if (check & ENCODE_DIE_ON_ERR){ - Perl_croak( - aTHX_ "%s \"\\x%02" UVXf - "\" does not map to Unicode (%d)", - (UV)enc->name[0], (U8)s[slen], code); + Perl_croak(aTHX_ ERR_DECODE_NOMAP, + (UV)enc->name[0], (U8)s[slen]); return &PL_sv_undef; /* never reaches but be safe */ } if (check & ENCODE_WARN_ON_ERR){ Perl_warner( aTHX_ packWARN(WARN_UTF8), - "%s \"\\x%02" UVXf - "\" does not map to Unicode (%d)", - (UV)enc->name[0], (U8)s[slen], code); + ERR_DECODE_NOMAP, + (UV)enc->name[0], (U8)s[slen]); } if (check & ENCODE_RETURN_ON_ERR){ goto ENCODE_SET_SRC; diff --git a/ext/Encode/lib/Encode/Guess.pm b/ext/Encode/lib/Encode/Guess.pm index 35cc1e1..2a84cc4 100644 --- a/ext/Encode/lib/Encode/Guess.pm +++ b/ext/Encode/lib/Encode/Guess.pm @@ -2,7 +2,7 @@ package Encode::Guess; use strict; use Encode qw(:fallbacks find_encoding); -our $VERSION = do { my @r = (q$Revision: 1.4 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = do { my @r = (q$Revision: 1.5 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; my $Canon = 'Guess'; our $DEBUG = 0; @@ -65,16 +65,20 @@ sub guess { my $class = shift; my $obj = ref($class) ? $class : $Encode::Encoding{$Canon}; my $octet = shift; + + # sanity check + return unless defined $octet and length $octet; + # cheat 0: utf8 flag; Encode::is_utf8($octet) and return find_encoding('utf8'); # cheat 1: BOM use Encode::Unicode; my $BOM = unpack('n', $octet); return find_encoding('UTF-16') - if ($BOM == 0xFeFF or $BOM == 0xFFFe); + if (defined $BOM and ($BOM == 0xFeFF or $BOM == 0xFFFe)); $BOM = unpack('N', $octet); return find_encoding('UTF-32') - if ($BOM == 0xFeFF or $BOM == 0xFFFe0000); + if (defined $BOM and ($BOM == 0xFeFF or $BOM == 0xFFFe0000)); my %try = %{$obj->{Suspects}}; for my $c (@_){