From: Nick Ing-Simmons Date: Sun, 25 Mar 2001 20:49:11 +0000 (+0000) Subject: Avoid at leasy one of undefined warnings in Encode. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8040349a05f5a3f1e93bde55d8359e415c47bf01;p=p5sagit%2Fp5-mst-13.2.git Avoid at leasy one of undefined warnings in Encode. p4raw-id: //depot/perlio@9345 --- diff --git a/ext/Encode/Encode.pm b/ext/Encode/Encode.pm index fd85520..6501806 100644 --- a/ext/Encode/Encode.pm +++ b/ext/Encode/Encode.pm @@ -273,7 +273,7 @@ use base 'Encode::Encoding'; # Encoding is 16-bit network order Unicode (no surogates) # Used for X font encodings -__PACKAGE__->Define(qw(UCS-2 iso10646-1)); +__PACKAGE__->Define(qw(UCS-2 iso-10646-1)); sub decode { @@ -285,7 +285,7 @@ sub decode $uni .= chr($code); } $_[1] = $str if $chk; - Encode::utf8_upgrade($uni); + utf8::upgrade($uni); return $uni; } @@ -586,7 +586,7 @@ UTF-16 is similar to UCS-2, 16 bit or 2-byte chunks. UCS-2 can only represent 0..0xFFFF, while UTF-16 has a "surogate pair" scheme which allows it to cover the whole Unicode range. -Encode implements big-endian UCS-2 aliased to "iso10646-1" as that +Encode implements big-endian UCS-2 aliased to "iso-10646-1" as that happens to be the name used by that representation when used with X11 fonts. UTF-32 or UCS-4 is 32-bit or 4-byte chunks. Perl's logical characters diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index 74303c9..13ba704 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -219,9 +219,11 @@ PerlIOEncode_flush(PerlIO *f) { PerlIOEncode *e = PerlIOSelf(f,PerlIOEncode); IV code = 0; - dTHX; - if (e->bufsv && (PerlIOBase(f)->flags & (PERLIO_F_RDBUF|PERLIO_F_WRBUF))) + if (e->bufsv && (PerlIOBase(f)->flags & (PERLIO_F_RDBUF|PERLIO_F_WRBUF)) + &&(e->base.ptr > e->base.buf) + ) { + dTHX; dSP; SV *str; char *s; @@ -452,6 +454,11 @@ encode_method(pTHX_ encode_t *enc, encpage_t *dir, SV *src, int check) SvCUR_set(src,SvCUR(src)-slen); } } + else + { + SvCUR_set(dst,slen); + SvPOK_on(dst); + } return dst; }