Change 14156 by jhi@alpha on 2002/01/09 19:46:27
Subject: [Patch @14129] fixes Unicode::Normalize
From: SADAHIRO Tomoyuki <[EMAIL PROTECTED]>
Date: Thu, 10 Jan 2002 01:08:56 +0900
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/MANIFEST#700 edit
.... //depot/perl/ext/Unicode/Normalize/Makefile.PL#2 edit
.... //depot/perl/ext/Unicode/Normalize/Normalize.pm#4 edit
.... //depot/perl/ext/Unicode/Normalize/Normalize.pod#2 delete
.... //depot/perl/ext/Unicode/Normalize/Normalize.xs#5 edit
.... //depot/perl/ext/Unicode/Normalize/mkheader#5 edit
Differences ...
==== //depot/perl/MANIFEST#700 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST.~1~ Wed Jan 9 13:00:05 2002
+++ perl/MANIFEST Wed Jan 9 13:00:05 2002
@@ -625,7 +625,6 @@
ext/Unicode/Normalize/Makefile.PL Unicode::Normalize
ext/Unicode/Normalize/mkheader Unicode::Normalize
ext/Unicode/Normalize/Normalize.pm Unicode::Normalize
-ext/Unicode/Normalize/Normalize.pod Unicode::Normalize
ext/Unicode/Normalize/Normalize.xs Unicode::Normalize
ext/Unicode/Normalize/README Unicode::Normalize
ext/Unicode/Normalize/t/func.t Unicode::Normalize
==== //depot/perl/ext/Unicode/Normalize/Makefile.PL#2 (text) ====
Index: perl/ext/Unicode/Normalize/Makefile.PL
--- perl/ext/Unicode/Normalize/Makefile.PL.~1~ Wed Jan 9 13:00:05 2002
+++ perl/ext/Unicode/Normalize/Makefile.PL Wed Jan 9 13:00:05 2002
@@ -9,7 +9,7 @@
'NAME' => 'Unicode::Normalize',
'VERSION_FROM' => 'Normalize.pm', # finds $VERSION
($] >= 5.005 ? ## Add these new keywords supported since 5.005
- (ABSTRACT_FROM => 'Normalize.pod', # retrieve abstract from module
+ (ABSTRACT_FROM => 'Normalize.pm', # retrieve abstract from module
AUTHOR => 'SADAHIRO Tomoyuki <[EMAIL PROTECTED]>') : ()),
clean => {FILES=> 'unfcan.h unfcmb.h unfcmp.h unfcpt.h unfexc.h'},
);
==== //depot/perl/ext/Unicode/Normalize/Normalize.pm#4 (text) ====
Index: perl/ext/Unicode/Normalize/Normalize.pm
--- perl/ext/Unicode/Normalize/Normalize.pm.~1~ Wed Jan 9 13:00:05 2002
+++ perl/ext/Unicode/Normalize/Normalize.pm Wed Jan 9 13:00:05 2002
@@ -5,7 +5,7 @@
use warnings;
use Carp;
-our $VERSION = '0.12';
+our $VERSION = '0.13';
our $PACKAGE = __PACKAGE__;
require Exporter;
@@ -22,24 +22,24 @@
bootstrap Unicode::Normalize $VERSION;
-use constant CANON => 0;
use constant COMPAT => 1;
-sub NFD ($) { reorder(decompose($_[0], CANON )) }
+sub NFD ($) { reorder(decompose($_[0])) }
sub NFKD ($) { reorder(decompose($_[0], COMPAT)) }
-sub NFC ($) { compose(reorder(decompose($_[0], CANON ))) }
+sub NFC ($) { compose(reorder(decompose($_[0]))) }
sub NFKC ($) { compose(reorder(decompose($_[0], COMPAT))) }
sub normalize($$)
{
- my $form = shift;
- $form =~ s/^NF//;
- $form eq 'D' ? NFD ($_[0]) :
- $form eq 'C' ? NFC ($_[0]) :
- $form eq 'KD' ? NFKD($_[0]) :
- $form eq 'KC' ? NFKC($_[0]) :
- croak $PACKAGE."::normalize: invalid form name: $form";
+ my $form = shift;
+ $form =~ s/^NF//;
+ return
+ $form eq 'D' ? NFD ($_[0]) :
+ $form eq 'C' ? NFC ($_[0]) :
+ $form eq 'KD' ? NFKD($_[0]) :
+ $form eq 'KC' ? NFKC($_[0]) :
+ croak $PACKAGE."::normalize: invalid form name: $form";
}
1;
@@ -69,7 +69,7 @@
=head1 DESCRIPTION
-=head2 Normalization
+=head2 Normalization Forms
=over 4
@@ -107,7 +107,7 @@
These functions are interface of character data used internally.
If you want only to get unicode normalization forms,
-you need not to call them by yourself.
+you doesn't need call them by yourself.
=over 4
@@ -123,7 +123,7 @@
=item C<$uv_composite = getComposite($uv_here, $uv_next)>
-If the couple of two characters here and next (as codepoints) is composable
+If two characters here and next (as codepoints) are composable
(including Hangul Jamo/Syllables and Exclusions),
returns the codepoint of the composite.
==== //depot/perl/ext/Unicode/Normalize/Normalize.xs#5 (text) ====
Index: perl/ext/Unicode/Normalize/Normalize.xs
--- perl/ext/Unicode/Normalize/Normalize.xs.~1~ Wed Jan 9 13:00:05 2002
+++ perl/ext/Unicode/Normalize/Normalize.xs Wed Jan 9 13:00:05 2002
@@ -146,10 +146,10 @@
MODULE = Unicode::Normalize PACKAGE = Unicode::Normalize
SV*
-decompose(arg, compat)
+decompose(arg, compat = &PL_sv_no)
SV * arg
SV * compat
- PROTOTYPE: $
+ PROTOTYPE: $;$
PREINIT:
UV uv;
SV *src, *dst;
@@ -275,7 +275,7 @@
s = (U8*)SvPV(src, srclen);
e = s + srclen;
- dstlen = srclen + 1; /* equal or shorter, XXX */
+ dstlen = srclen + 1;
dst = newSV(dstlen);
(void)SvPOK_only(dst);
SvUTF8_on(dst);
@@ -317,6 +317,16 @@
/* S + C + S => S-S + C would be also blocked. */
if( uvComp && ! isExclusion(uvComp) && preCC <= curCC)
{
+ STRLEN leftcur, rightcur, dstcur;
+ leftcur = UNISKIP(uvComp);
+ rightcur = UNISKIP(uvS) + UNISKIP(uv);
+
+ if (leftcur > rightcur) {
+ dstcur = d - (U8*)SvPVX(dst);
+ dstlen += leftcur - rightcur;
+ d = (U8*)SvGROW(dst,dstlen) + dstcur;
+ }
+
/* preCC not changed to curCC */
uvS = uvComp;
} else if (! curCC && p < e) { /* blocked */
@@ -328,15 +338,15 @@
}
}
d = uvuni_to_utf8(d, uvS); /* starter (composed or not) */
- if((tmplen = t - tmp_start)) { /* uncomposed combining char */
+ tmplen = t - tmp_start;
+ if (tmplen) { /* uncomposed combining char */
t = (U8*)SvPVX(tmp);
while(tmplen--) *d++ = *t++;
}
uvS = uv;
} /* for */
- e = d; /* end of dst */
- d = (U8*)SvPVX(dst);
- SvCUR_set(dst, e - d);
+
+ SvCUR_set(dst, d - (U8*)SvPVX(dst));
RETVAL = dst;
OUTPUT:
RETVAL
==== //depot/perl/ext/Unicode/Normalize/mkheader#5 (text) ====
Index: perl/ext/Unicode/Normalize/mkheader
--- perl/ext/Unicode/Normalize/mkheader.~1~ Wed Jan 9 13:00:05 2002
+++ perl/ext/Unicode/Normalize/mkheader Wed Jan 9 13:00:05 2002
@@ -111,7 +111,7 @@
sub _U_stringify {
sprintf '"%s"', join '',
- map sprintf("\\x%2x", $_), unpack 'C*', pack 'U*', @_;
+ map sprintf("\\x%02x", $_), unpack 'C*', pack 'U*', @_;
}
foreach my $hash (\%Canon, \%Compat) {
@@ -120,48 +120,18 @@
}
}
-sub utf8len {
- my $uv = shift;
- return $uv < 0x80 ? 1 :
- $uv < 0x800 ? 2 :
- $uv < 0x10000 ? 3 :
- $uv < 0x110000 ? 4 :
- croak "$PACKAGE: illegal char in the composite. utf-8 max is 0x10ffff.";
-}
-
-sub utfebcdiclen {
- my $uv = shift;
- return $uv < 0xA0 ? 1 :
- $uv < 0x400 ? 2 :
- $uv < 0x4000 ? 3 :
- $uv < 0x40000 ? 4 :
- $uv < 0x110000 ? 5 :
- croak "$PACKAGE: illegal char in the composite. utf-8 max is 0x10ffff.";
-}
-
my $prefix = "UNF_";
my $structname = "${prefix}complist";
our (%Comp1st, %CompList);
-my $errExpand = "$PACKAGE: A composable pair in %s "
- . "is longer than the composite in bytes!\n"
- . "%d + %d => %d\nQuit. Please inform the author...";
-
foreach(sort keys %Compos) {
my @a = unpack('U*', $_);
my $val = $Compos{$_};
my $name = sprintf "${structname}_%06x", $a[0];
$Comp1st{ $a[0] } = $name;
$CompList{ $name }{ $a[1] } = $val;
-
- if( utf8len($a[0]) + utf8len($a[1]) < utf8len($val) ) {
- croak sprintf($errExpand, "utf-8", $a[0], $a[1], $val);
- }
- if( utfebcdiclen($a[0]) + utfebcdiclen($a[1]) < utfebcdiclen($val)) {
- croak sprintf($errExpand, "utf-ebcdic", $a[0], $a[1], $val);
- }
}
my $compinit =
End of Patch.