Fresco/Babylon/utils/UnicodePluginGenerator CompExclude.pm,NONE,1.1 Bidir.pm,1.5,1.6 Block.pm,1.3,1.4 Category.pm,1.4,1.5 CombClass.pm,1.4,1.5 Compositions.pm,1.6,1.7 DecDigitVal.pm,1.4,1.5 DecompClass.pm,1.5,1.6 DecompString.pm,1.5,1.6 Defined.pm,1.5,1.6 DigitVal.pm,1.4,1.5 EAWidth.pm,1.5,1.6 Linebreak.pm,1.5,1.6 Lower.pm,1.4,1.5 Mirror.pm,1.5,1.6 NumericVal.pm,1.4,1.5 Prop.pm,1.5,1.6 Title.pm,1.4,1.5 Upper.pm,1.4,1.5
Tobias Hunger <[email protected]> Fri, 01 Aug 2003 11:47:55 -0500
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator
In directory purcel:/tmp/cvs-serv24256/Babylon/utils/UnicodePluginGenerator
Modified Files:
Bidir.pm Block.pm Category.pm CombClass.pm Compositions.pm
DecDigitVal.pm DecompClass.pm DecompString.pm Defined.pm
DigitVal.pm EAWidth.pm Linebreak.pm Lower.pm Mirror.pm
NumericVal.pm Prop.pm Title.pm Upper.pm
Added Files:
CompExclude.pm
Log Message:
Babylon work over:
* Use iconv to convert characters to/from Babylon
* Updtae to Unicode Version 4.0
* Added unit tests (some fail for now, still need to work on that)
* Removed the VisualTextBuffer from the CommandKit: I still like the idea,
unfortunately it won't work out in the real world:-|
* Updated code to the changed Babylon interfaces whereever needed.
--- NEW FILE: CompExclude.pm ---
package UnicodePluginGenerator::CompExclude;
# Only encode those characters whos composition exclusion cannot
# be derived from other Properties!
use strict;
sub new
{
my $self = {};
my $excl_file = $_[1];
open(EXCL, $excl_file) or die "Can't open ".$excl_file."\n";
while(<EXCL>)
{
chop;
(my $info, my $rest) = split /#/, $_, 2;
next unless ($info);
$info =~ s/^\s*//;
$info =~ s/\s*$//;
next unless ($info);
if ($info =~ /^([A-F0-9]+)\.\.([A-F0-9]+)/)
{
for (my $i = hex($1); $i <= hex($2); $i++)
{
$self->{$i} = 1;
}
}
elsif ($info =~ /^([A-F0-9]+)/)
{
$self->{hex($1)} = 1;
}
}
close(EXCL);
$self->{_BL_START} = -1;
$self->{_BL_END} = -1;
$self->{_SPECIAL_NEEDED} = 0;
$self->{_VAR_NEEDED} = 0;
bless($self);
return $self;
}
sub data
{
my $self = shift;
my $pos = $_[0];
if(exists($self->{$pos}))
{
return $self->{$pos};
}
else
{
return "undef";
}
}
sub setup_for
{
my $self = shift;
my $bl_start = $_[0];
my $bl_end = $_[1];
if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
{
$self->{_BL_START} = $bl_start;
$self->{_BL_END} = $bl_end;
$self->{_SPECIAL_NEEDED} = 0;
$self->{_VAR_NEEDED} = 0;
for (my $i = $bl_start; $i <= $bl_end; $i++)
{
$self->{_VAR_NEEDED} = 1 if ($self->data($i) ne "undef");
}
}
}
sub include
{
return "";
}
sub init
{
return "";
}
sub function
{
my $self = shift;
$self->setup_for($_[0], $_[1]);
my $bl_name = $_[2];
my $tmp = "";
$tmp = " bool exclude_from_composition(const UCS4 uc) const\n {\n";
$tmp .= " if (my_comp_exclude.test(uc - my_first_letter)) return 1;\n" if ($self->{_VAR_NEEDED});
$tmp .= " return 0;\n";
$tmp .= " }\n\n";
return $tmp;
}
sub var_def
{
my $self = shift;
$self->setup_for($_[0], $_[1]);
my $bl_length = $_[1] - $_[0] + 1;
return " static const std::bitset<$bl_length> my_comp_exclude;\n"
if ($self->{_VAR_NEEDED});
return "";
}
sub var
{
my $self = shift;
$self->setup_for($_[0], $_[1]);
my $bl_name = $_[2];
my $bl_start = $_[0];
my $bl_end = $_[1];
my $bl_length = $bl_end - $bl_start + 1;
if ($self->{_VAR_NEEDED})
{
my $tmp = " const std::bitset<$bl_length> $bl_name\:\:my_comp_exclude(std::string(\"";
my $str = "";
for (my $i= $bl_start; $i <= $bl_end; $i++)
{
$str = "0".$str if ($self->data($i) eq "undef");
$str = "1".$str if ($self->data($i) ne "undef");
}
$tmp .= $str."\"));\n\n";
return $tmp;
}
return "";
}
1; # for use to succeed...
Index: Bidir.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Bidir.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Bidir.pm 11 May 2001 01:38:40 -0000 1.5
+++ Bidir.pm 1 Aug 2003 16:47:17 -0000 1.6
@@ -1,75 +1,65 @@
package UnicodePluginGenerator::Bidir;
use strict;
-sub new {
- my $self = {};
-
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
-
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
-
- next if ($info eq "");
-
- my @list = split /;/, $info, 15;
-
- $self->{hex($list[0])} = "BIDIR_".$list[4];
- }
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
+
+ open(UCD, $ucd_file);
+
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- close(UCD);
+ next if ($info eq "");
+
+ my @list = split /;/, $info, 15;
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- $self->{_ELEM} = "";
+ $self->{hex($list[0])} = "BIDIR_".$list[4];
+ }
+
+ close(UCD);
- bless($self);
- return $self;
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+ $self->{_ELEM} = "";
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if(exists($self->{$pos}));
return "undef";
- }
-}
-
-sub include {
- return "";
-}
-
-sub init {
- return "";
}
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
$self->{_BL_START} = $bl_start;
$self->{_BL_END} = $bl_end;
$self->{_ELEM} = "";
@@ -86,101 +76,83 @@
$self->{_ATTENTION_NEEDED} = 0;
}
}
-
- my $tmp = " Bidir_Props bidir_props(const UCS4 uc) const {\n";
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return BIDIR_INVALID;\n";
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return $bl_name\:\:m_bidir\[uc - m_first_letter\];\n";
- $tmp .= " }\n\n";
- return $tmp;
- } else {
- $tmp .= sprintf " return %s;\n }\n\n",
- $self->{_ELEM};
- return $tmp;
- }
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
+sub include
+{
+ return "";
+}
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
+sub init
+{
+ return "";
+}
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
+
+ my $tmp = " Bidir_Props bidir_props(const UCS4 uc) const\n {\n";
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return BIDIR_INVALID;\n";
+
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " return $bl_name\:\:my_bidir\[uc - my_first_letter\];\n";
+ $tmp .= " }\n\n";
+ return $tmp;
+ } else {
+ $tmp .= sprintf " return %s;\n }\n\n",
+ $self->{_ELEM};
+ return $tmp;
}
- }
+}
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const Babylon::Bidir_Props m_bidir\[$bl_length\];\n";
- } else {
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+
+ my $bl_length = $_[1] - $_[0] + 1;
+
+ return " static const Babylon::Bidir_Props my_bidir\[$bl_length\];\n" if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
+ my $bl_length = $bl_end - $bl_start;
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const Babylon::Bidir_Props $bl_name\:\:my_bidir\[\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= "\n " if (($i - $bl_start) % 4 == 0);
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ if ($self->data($i) eq "undef")
+ {
+ $tmp .= $self->{_ELEM};
+ }
+ else
+ {
+ $tmp .= $self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+ $tmp .= "\n };\n\n";
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const Babylon::Bidir_Props $bl_name\:\:m_bidir\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= $self->{_ELEM};
- } else {
- $tmp .= $self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ return $tmp;
}
- $tmp .= "\n };\n\n";
-
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...
Index: Block.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Block.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Block.pm 6 May 2001 12:18:46 -0000 1.3
+++ Block.pm 1 Aug 2003 16:47:17 -0000 1.4
@@ -1,57 +1,63 @@
package UnicodePluginGenerator::Block;
use strict;
-sub new {
- my $self = {};
-
- $self->{_START} = hex($_[1]);
- $self->{_END} = hex($_[2]);
- $self->{_NAME} = $_[3];
+sub new
+{
+ my $self = {};
+ $self->{_START} = hex($_[1]);
+ $self->{_END} = hex($_[2]);
+ $self->{_NAME} = $_[3];
- bless($self);
- return $self;
+ bless($self);
+ return $self;
}
-sub start {
- my $self = shift;
- return $self->{_START};
+sub start
+{
+ my $self = shift;
+ return $self->{_START};
}
-sub start_string {
- my $self = shift;
- return sprintf "0x%X", $self->{_START};
+sub start_string
+{
+ my $self = shift;
+ return sprintf "0x%X", $self->{_START};
}
-sub end {
- my $self = shift;
- return $self->{_END};
+sub end
+{
+ my $self = shift;
+ return $self->{_END};
}
-sub end_string {
- my $self = shift;
- return sprintf "0x%X", $self->{_END};
+sub end_string
+{
+ my $self = shift;
+ return sprintf "0x%X", $self->{_END};
}
-sub name {
- my $self = shift;
- return $self->{_NAME};
+sub name
+{
+ my $self = shift;
+ return $self->{_NAME};
}
-sub filename {
- my $self = shift;
-
- my $tmp = join '_', split / /, $self->{_NAME};
+sub filename
+{
+ my $self = shift;
+ my $tmp = join '_', split / /, $self->{_NAME};
- return sprintf "%X-%X.cc", $self->start(), , $self->end();
+ return sprintf "%X-%X.cc", $self->start(), , $self->end();
}
-sub classname {
- my $self = shift;
+sub classname
+{
+ my $self = shift;
- my $tmp = join '', split /-/, join '_', split / /, $self->{_NAME};
- $tmp = sprintf "%s%X", $tmp, $self->{_START};
- return $tmp;
+ my $tmp = join '', split /-/, join '_', split / /, $self->{_NAME};
+ $tmp = sprintf "%s%X", $tmp, $self->{_START};
+ return $tmp;
}
1; # for use to succeed...
Index: Category.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Category.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Category.pm 6 May 2001 12:18:46 -0000 1.4
+++ Category.pm 1 Aug 2003 16:47:17 -0000 1.5
@@ -2,101 +2,113 @@
use strict;
sub new {
- my $self = {};
-
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file) or die "Can't open Character Database.\n";
-
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
-
- next if ($info eq "");
+ my $self = {};
+ my $ucd_file = $_[1];
+
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- my @list = split /;/, $info, 15;
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- $self->{hex($list[0])} = "CAT_".$list[2];
- }
+ next if ($info eq "");
- close(UCD);
+ my @list = split /;/, $info, 15;
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- $self->{_ELEM} = "";
+ $self->{hex($list[0])} = "CAT_".$list[2];
+ }
+
+ close(UCD);
- bless($self);
- return $self;
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+ $self->{_ELEM} = "";
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if(exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
+sub include
+{
+ return "";
}
-sub init {
- return "";
+sub init
+{
+ return "";
}
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- $self->{_ELEM} = "";
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ $self->{_ELEM} = "";
+
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ if ($self->{_ELEM} eq "")
+ {
+ $self->{_ELEM} = $self->data($i);
+ }
+ elsif ($self->{_ELEM} ne $self->data($i))
+ {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
}
- }
+}
- my $tmp = " Gen_Cat category(const UCS4 uc) const {\n";
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return CAT_MAX;\n";
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
+
+ my $tmp = " Gen_Cat category(const UCS4 uc) const\n {\n";
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return CAT_MAX;\n";
if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return Babylon\:\:Gen_Cat($bl_name\:\:_cat\[uc - m_first_letter\]);\n";
- $tmp .= " }\n\n";
+ $tmp .= " return Babylon\:\:Gen_Cat($bl_name\:\:my_cat\[uc - my_first_letter\]);\n";
+ $tmp .= " }\n\n";
} else {
- $tmp .= sprintf " return Babylon\:\:Gen_Cat(%s);\n }\n\n",
+ $tmp .= sprintf " return Babylon\:\:Gen_Cat(%s);\n }\n\n",
$self->{_ELEM};
}
@@ -105,84 +117,43 @@
sub var_def {
my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
-
- $self->{_ELEM} = "";
-
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
-
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const unsigned char _cat\[$bl_length\];\n";
- } else {
- return "";
- }
+ return " static const unsigned char my_cat\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED});
+ return "";
}
sub var {
my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
+ $self->setup_for($_[0], $_[1]);
my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
-
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_length = $_[1] - $_[0] + 1;
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const unsigned char $bl_name\:\:_cat\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= $self->{_ELEM};
- } else {
- $tmp .= $self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const unsigned char $bl_name\:\:my_cat\[\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= "\n " if (($i - $bl_start) % 8 == 0);
+ if ($self->data($i) eq "undef")
+ {
+ $tmp .= $self->{_ELEM};
+ }
+ else
+ {
+ $tmp .= $self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
}
- }
- $tmp .= "\n };\n\n";
+ $tmp .= "\n };\n\n";
- return $tmp;
- } else {
- return "";
+ return $tmp;
}
+ return "";
}
1; # for use to succeed...
Index: CombClass.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/CombClass.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CombClass.pm 6 May 2001 12:18:46 -0000 1.4
+++ CombClass.pm 1 Aug 2003 16:47:17 -0000 1.5
@@ -1,183 +1,158 @@
package UnicodePluginGenerator::CombClass;
use strict;
-sub new {
- my $self = {};
-
- my $ucd_file = $_[1];
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- open(UCD, $ucd_file);
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- next if ($info eq "");
+ next if ($info eq "");
- my @list = split /;/, $info, 15;
+ my @list = split /;/, $info, 15;
+
+ $self->{hex($list[0])} = $list[3];
+ }
- $self->{hex($list[0])} = $list[3];
- }
+ close(UCD);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+ $self->{_ELEM} = "";
+
+ bless($self);
+ return $self;
+}
- close(UCD);
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- $self->{_ELEM} = "";
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- bless($self);
- return $self;
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if(exists($self->{$pos}));
+ return "undef";
}
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
- return "undef";
- }
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ if ($self->{_ELEM} eq "")
+ {
+ $self->{_ELEM} = $self->data($i);
+ }
+ elsif ($self->{_ELEM} ne $self->data($i))
+ {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
+ }
}
-sub include {
- return "";
+sub include
+{
+ return "";
}
-sub init {
- return "";
+sub init
+{
+ return "";
}
sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
-
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
+
+ my $tmp = " Can_Comb_Class comb_class(const UCS4 uc) const\n {\n";
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return CC_MAX;\n";
+
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ $tmp .= " return Can_Comb_Class($bl_name\:\:my_comb_cl\[uc - my_first_letter\]);\n";
+ $tmp .= " }\n\n";
+ return $tmp;
}
- }
-
- my $tmp = " Can_Comb_Class comb_class(const UCS4 uc) const {\n";
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return CC_MAX;\n";
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return Can_Comb_Class($bl_name\:\:_comb_cl\[uc - m_first_letter\]);\n";
- $tmp .= " }\n\n";
- return $tmp;
- } else {
- $tmp .= sprintf " return Babylon\:\:Can_Comb_Class(%s);\n }\n\n",
- $self->{_ELEM};
+ $tmp .= sprintf " return Babylon\:\:Can_Comb_Class(%s);\n }\n\n", $self->{_ELEM};
return $tmp;
- }
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
-
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const unsigned char _comb_cl\[$bl_length\];\n";
- } else {
+ return " static const unsigned char my_comb_cl\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
-
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
+
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const unsigned char $bl_name\:\:my_comb_cl\[\] = {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= "\n " if (($i - $bl_start) % 8 == 0);
+ if ($self->data($i) eq "undef")
+ {
+ $tmp .= $self->{_ELEM};
+ }
+ else
+ {
+ $tmp .= $self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
-
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const unsigned char $bl_name\:\:_comb_cl\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= $self->{_ELEM};
- } else {
- $tmp .= $self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ $tmp .= "\n };\n\n";
+
+ return $tmp;
}
- $tmp .= "\n };\n\n";
-
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...
Index: Compositions.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Compositions.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Compositions.pm 31 May 2002 23:42:14 -0000 1.6
+++ Compositions.pm 1 Aug 2003 16:47:17 -0000 1.7
@@ -1,274 +1,211 @@
package UnicodePluginGenerator::Compositions;
use strict;
-sub new {
- my $self = {};
-
- my $ucd_file = $_[1];
- my $excl_file= $_[2];
-
- my @excl;
-
- open(EXCL, $excl_file) or die "Can't open ".$excl_file."\n";
-
- while(<EXCL>) {
- my $line = chop;
- if ($line eq "") { next; }
- (my $info, my $rest) = split /#/, 2;
- if ($info eq "") { next; }
-
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
-
- next if ($info eq "");
-
- push @excl, $info;
- }
-
- close(EXCL);
-
- open(UCD, $ucd_file);
-
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
-
- next if ($info eq "");
-
- my @list = split /;/, $info, 15;
-
- my $decomp = $list[5];
- my $dType = "";
- my $tmp = "";
-
- if ($decomp =~ /^<(\w+)>$/) {
- $tmp = "";
- } elsif ($decomp =~ /^<(\w+)> ([A-F0-9 ]*)$/) {
- $tmp = "";
- } else {
- $tmp = $decomp;
- }
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
+
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
+
+ while(<UCD>)
+ {
+ my $line = chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+
+ next if ($info eq "");
+
+ my @list = split /;/, $info, 15;
+
+ my $decomp = $list[5];
+
+ next if ($decomp =~ /^<(\w+)>/);
- if (($tmp =~ tr/ / /) == 1) {
- if (!(grep {$_ eq $list[0]} @excl)) {
- my @chars = split / /, $tmp;
- $tmp = sprintf "%08X%08X", hex($chars[0]), hex($chars[1]);
- $self->{$tmp} = $list[0];
- }
+ if (($decomp =~ tr/ / /) == 1)
+ {
+ my @chars = split / /, $decomp;
+ $decomp = sprintf "%08X%08X", hex($chars[0]), hex($chars[1]);
+ $self->{$decomp} = $list[0];
+ }
}
- }
-
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
-
- bless($self);
- return $self;
+
+ close(UCD);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
- my $result = "";
-
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
- return "undef";
- }
+sub data
+{
+ my $self = shift;
+
+ my $pos = $_[0];
+
+ if(exists($self->{$pos}))
+ {
+ return $self->{$pos};
+ }
+ else
+ {
+ return "undef";
+ }
}
-sub include {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if((sprintf "%04X", $bl_start) eq "AC00") { # hangul
- return "";
- }
+ my @blockkeys = sort grep {$_ ne "_ATTENTION_NEEDED" and
+ $_ ne "_BL_START" and
+ $_ ne "_BL_END" and
+ $_ ne "_INPUT_MAX_LENGTH" and
+ $_ ne "_RES_MAX_LENGTH" and
+ hex(substr $_, 0, 8) >= $bl_start and
+ hex(substr $_, 0, 8) <= $bl_end}
+ keys %$self;
- my @blockkeys = sort grep {$_ ne "_ATTENTION_NEEDED" and
- $_ ne "_BL_START" and
- $_ ne "_BL_END" and
- $_ ne "_INPUT_MAX_LENGTH" and
- $_ ne "_RES_MAX_LENGTH" and
- hex(substr $_, 0, 8) >= $bl_start and
- hex(substr $_, 0, 8) <= $bl_end}
- keys %$self;
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
+ if ($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
- if ($#blockkeys > 0) {
- $self->{_ATTENTION_NEEDED} = 1;
- } else {
- $self->{_ATTENTION_NEEDED} = 0;
+ @blockkeys = sort grep {$_ ne "_ATTENTION_NEEDED" and
+ $_ ne "_BL_START" and
+ $_ ne "_BL_END" and
+ $_ ne "_INPUT_MAX_LENGTH" and
+ $_ ne "_RES_MAX_LENGTH" and
+ hex(substr $_, 0, 8) >= $bl_start and
+ hex(substr $_, 0, 8) <= $bl_end} keys %$self;
+ my $keysize = scalar(@blockkeys);
+
+ $self->{_ATTENTION_NEEDED} = 1 if ($keysize > 0);
+ $self->{_ATTENTION_NEEDED} = 0 if ($keysize == 0);
}
- }
- if ($self->{_ATTENTION_NEEDED} == 1) {
- return "#include <map>\n";
- }
-
- return "";
+ return @blockkeys;
}
-sub init {
- my $self = shift;
- my $bl_start = $_[0];
- my $bl_end = $_[1];
+sub include
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if((sprintf "%04X", $bl_start) eq "AC00") { # hangul
+ return "" if ((sprintf "%04X", $bl_start) eq "AC00");
+ return "#include <map>\n" if ($self->{_ATTENTION_NEEDED} == 1);
return "";
- }
+}
- my @blockkeys = sort grep {$_ ne "_ATTENTION_NEEDED" and
- $_ ne "_BL_START" and
- $_ ne "_BL_END" and
- $_ ne "_INPUT_MAX_LENGTH" and
- $_ ne "_RES_MAX_LENGTH" and
- hex(substr $_, 0, 8) >= $bl_start and
- hex(substr $_, 0, 8) <= $bl_end}
- keys %$self;
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
+sub init
+{
+ my $self = shift;
+ my @blockkeys = $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if ($#blockkeys > 0) {
- $self->{_ATTENTION_NEEDED} = 1;
- } else {
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+ return "" if ((sprintf "%04X", $bl_start) eq "AC00"); #hangul
- if ($self->{_ATTENTION_NEEDED} == 1) {
- my $tmp = "";
- foreach my $i (@blockkeys) {
- $tmp .= sprintf " m_composeMap\[std::make_pair(0x%s, 0x%s)\] = 0x%s;\n",
- substr($i, 0, 8), substr($i, 8, 8), $self->data($i);
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ my $tmp = " {\n";
+ foreach my $i (@blockkeys)
+ {
+ $tmp .= sprintf " my_composeMap\[std::make_pair(0x%s, 0x%s)\] = 0x%s;\n",
+ substr($i, 0, 8), substr($i, 8, 8), $self->data($i);
+ }
+ $tmp .= " }\n";
+ return $tmp;
}
- return $tmp;
- }
- return "";
+ return "";
}
-sub function {
- my $self = shift;
- my $bl_start = $_[0];
- my $bl_end = $_[1];
-
- if((sprintf "%04X", $bl_start) eq "AC00") { # hangul
- my $tmp = " UCS4 compose (const UCS4 starter, const UCS4 last) {\n";
- $tmp .= " const UCS4 sBase = 0xAC00;\n";
- $tmp .= " const UCS4 lBase = 0x1100;\n";
- $tmp .= " const UCS4 vBase = 0x1161;\n";
- $tmp .= " const UCS4 tBase = 0x11A7;\n\n";
- $tmp .= " const int lCount = 19;\n";
- $tmp .= " const int vCount = 21;\n";
- $tmp .= " const int tCount = 28;\n";
- $tmp .= " const int nCount = vCount * tCount;\n";
- $tmp .= " const int sCount = lCount * nCount;\n\n";
-
- $tmp .= " UCS4 result = 0;\n";
- $tmp .= " // check if the characters are L and V\n";
- $tmp .= " int lIndex = starter - vBase;\n";
- $tmp .= " if ( 0 <= lIndex && lIndex < lCount ) {\n";
- $tmp .= " int vIndex = last - vBase;\n";
- $tmp .= " if ( 0 <= vIndex && vIndex < vCount ) {\n";
- $tmp .= " // make syllable form LV\n";
- $tmp .= " result = UCS4(sBase + (lIndex * vCount + vIndex) * tCount);\n";
- $tmp .= " }\n";
- $tmp .= " }\n\n";
- $tmp .= " // check if the characters are LV and T\n";
- $tmp .= " int sIndex = starter - sBase;\n";
- $tmp .= " if (0 <= sIndex && sIndex < sCount && (sIndex % tCount) == 0) {\n";
- $tmp .= " int tIndex = last - tBase;\n";
- $tmp .= " if (0 <= tIndex && tIndex <= tCount)\n";
- $tmp .= " result = starter + tIndex;\n";
- $tmp .= " }\n\n";
- $tmp .= " return result;\n";
- $tmp .= " }\n\n";
-
- return $tmp;
- }
-
- my @blockkeys = sort grep {$_ ne "_ATTENTION_NEEDED" and
- $_ ne "_BL_START" and
- $_ ne "_BL_END" and
- $_ ne "_INPUT_MAX_LENGTH" and
- $_ ne "_RES_MAX_LENGTH" and
- hex(substr $_, 0, 8) >= $bl_start and
- hex(substr $_, 0, 8) <= $bl_end}
- keys %$self;
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
+ my $tmp = " UCS4 compose(const UCS4 starter, const UCS4 last)\n {\n";
- if ($#blockkeys > 0) {
- $self->{_ATTENTION_NEEDED} = 1;
- } else {
- $self->{_ATTENTION_NEEDED} = 0;
+ if($bl_start == 0x1100 || $bl_start == 0xAC00)
+ { # hangul
+ $tmp .= " const UCS4 sBase = 0xAC00;\n";
+ $tmp .= " const UCS4 lBase = 0x1100; const UCS4 vBase = 0x1161; const UCS4 tBase = 0x11A7;\n";
+ $tmp .= " const int lCount = 19; const int vCount = 21; const int tCount = 28;\n";
+ $tmp .= " const int nCount = vCount * tCount; const int sCount = lCount * nCount;\n";
+ if ($bl_start == 0x1100)
+ {
+ $tmp .= " // check if the characters are L and V\n";
+ $tmp .= " int lIndex = starter - lBase;\n";
+ $tmp .= " if ( 0 <= lIndex && lIndex < lCount )\n {\n";
+ $tmp .= " int vIndex = last - vBase;\n";
+ $tmp .= " if ( 0 <= vIndex && vIndex < vCount )\n {\n";
+ $tmp .= " // make syllable form LV\n";
+ $tmp .= " return UCS4(sBase + (lIndex * vCount + vIndex) * tCount);\n";
+ $tmp .= " }\n";
+ $tmp .= " }\n";
+ }
+ elsif ($bl_start == 0xAC00)
+ {
+ $tmp .= " // check if the characters are LV and T\n";
+ $tmp .= " int sIndex = starter - sBase;\n";
+ $tmp .= " if (0 <= sIndex && sIndex < sCount && (sIndex % tCount) == 0)\n {\n";
+ $tmp .= " int tIndex = last - tBase;\n";
+ $tmp .= " if (0 <= tIndex && tIndex <= tCount)\n";
+ $tmp .= " return UCS4(starter + tIndex);\n";
+ $tmp .= " }\n";
+ }
+ $tmp .= " return UC_NULL;\n";
+ $tmp .= " }\n\n";
+
+ return $tmp;
}
- }
-
- my $tmp = " UCS4 compose (const UCS4 start, const UCS4 last) {\n";
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return m_composeMap[std::make_pair(start, last)];\n";
- } else {
- $tmp .= " return 0;\n";
- }
- $tmp .= " }\n\n";
- return $tmp;
+ elsif ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " return my_composeMap[std::make_pair(starter, last)];\n";
+ }
+ else
+ {
+ $tmp .= " return 0;\n";
+ }
+ $tmp .= " }\n\n";
+ return $tmp;
}
sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
-
- if((sprintf "%04X", $bl_start) eq "AC00") { # hangul
- return "";
- }
-
- my @blockkeys = sort grep {$_ ne "_ATTENTION_NEEDED" and
- $_ ne "_BL_START" and
- $_ ne "_BL_END" and
- $_ ne "_INPUT_MAX_LENGTH" and
- $_ ne "_RES_MAX_LENGTH" and
- hex(substr $_, 0, 8) >= $bl_start and
- hex(substr $_, 0, 8) <= $bl_end}
- keys %$self;
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
-
- if ($#blockkeys > 0) {
- $self->{_ATTENTION_NEEDED} = 1;
- } else {
- $self->{_ATTENTION_NEEDED} = 0;
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+
+ if((sprintf "%04X", $bl_start) eq "AC00")
+ { # hangul
+ return "";
}
- }
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- my $inlength = $self->{_INPUT_MAX_LENGTH};
- my $outlength = $self->{_RES_MAX_LENGTH};
- my $tmp = " std::map<std::pair<UCS4, UCS4>, UCS4> m_composeMap;\n";
- return $tmp;
- }
-
- return "";
+
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ my $inlength = $self->{_INPUT_MAX_LENGTH};
+ my $outlength = $self->{_RES_MAX_LENGTH};
+ my $tmp = " std::map<std::pair<UCS4, UCS4>, UCS4> my_composeMap;\n";
+ return $tmp;
+ }
+
+ return "";
}
-sub var {
- return "";
+sub var
+{
+ return "";
}
1; # for use to succeed...
Index: DecDigitVal.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/DecDigitVal.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- DecDigitVal.pm 6 May 2001 12:18:46 -0000 1.4
+++ DecDigitVal.pm 1 Aug 2003 16:47:17 -0000 1.5
@@ -1,136 +1,146 @@
package UnicodePluginGenerator::DecDigitVal;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
-
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- next if ($info eq "");
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- my @list = split /;/, $info, 15;
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+
+ next if ($info eq "");
- if($list[6] ne "") {
- $self->{hex($list[0])} = $list[6];
+ my @list = split /;/, $info, 15;
+
+ $self->{hex($list[0])} = $list[6] if ($list[6] ne "");
}
- }
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
+ close(UCD);
- bless($self);
- return $self;
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+
+ bless($self);
+ return $self;
}
sub data {
- my $self = shift;
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+ my $self = shift;
+ my $pos = $_[0];
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D5) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
-}
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
-sub init {
- return "";
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
+ }
}
-sub function {
- my $self = shift;
+sub include
+{
+ return "";
+}
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub init
+{
+ return "";
+}
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
+sub function {
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
+
+ my $tmp = " int dec_digit_value(const UCS4 uc) const\n {\n";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " switch(uc)\n {\n";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= sprintf " case 0x%04Xu:\n return %d;\n", $i, $self->{$i} if($self->data($i) ne "undef");
+ }
+ $tmp .= " default:\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " }\n";
}
- }
-
- my $tmp = " int dec_digit_value(const UCS4 uc) const {\n";
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return 0;\n";
- $tmp .= " switch(uc) {\n";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if($self->data($i) ne "undef") {
- $tmp .= sprintf " case 0x%04Xu:\n return %d;\n",
- $i, $self->{$i};
- $tmp .= " break;\n";
- }
+ else
+ {
+ $tmp .= " return 0;\n";
}
- $tmp .= " default:\n";
- $tmp .= " return 0;\n";
- $tmp .= " }\n";
- } else {
- $tmp .= " return 0;\n";
- }
- $tmp .= " }\n\n";
+ $tmp .= " }\n\n";
- $tmp .= " bool is_Decimal_Digit(const UCS4 uc) const {\n";
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " switch(uc) {\n";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if($self->data($i) ne "undef") {
- $tmp .= sprintf " case 0x%04Xu:\n",
- $i;
- }
+ $tmp .= " bool is_Decimal_Digit(const UCS4 uc) const\n {\n";
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " switch(uc)\n {\n";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= sprintf " case 0x%04Xu:\n", $i
+ if ($self->data($i) ne "undef");
+ }
+ $tmp .= " return 1;\n";
+ $tmp .= " default:\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " }\n";
}
- $tmp .= " return 1;\n";
- $tmp .= " default:\n";
- $tmp .= " return 0;\n";
- $tmp .= " }\n";
- } else {
- $tmp .= " return 0;\n";
- }
- $tmp .= " }\n\n";
-
- return $tmp;
+ else
+ {
+ $tmp .= " return 0;\n";
+ }
+ $tmp .= " }\n\n";
+
+ return $tmp;
}
sub var_def {
- my $self = shift;
- return "";
+ return "";
}
sub var {
- my $self = shift;
- return "";
+ return "";
}
1; # for use to succeed...
Index: DecompClass.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/DecompClass.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- DecompClass.pm 6 May 2001 12:18:46 -0000 1.5
+++ DecompClass.pm 1 Aug 2003 16:47:17 -0000 1.6
@@ -1,196 +1,175 @@
package UnicodePluginGenerator::DecompClass;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- next if ($info eq "");
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- my @list = split /;/, $info, 15;
+ next if ($info eq "");
- my $decomp = $list[5];
- my $dType = "";
- my $tmp = "";
- if ($decomp =~ /^<(\w+)>$/) {
- $tmp = $1;
- $tmp =~ tr/a-z/A-Z/;
- $dType = "DECOMP_".$tmp;
- } elsif ($decomp =~ /^<(\w+)> ([A-F0-9 ]*)$/) {
- $tmp = $1;
- $tmp =~ tr/a-z/A-Z/;
- $dType = "DECOMP_".$tmp;
- } else {
- $dType = "DECOMP_CANONICAL";
- }
+ my @list = split /;/, $info, 15;
- $self->{hex($list[0])} = $dType;
- }
+ my $decomp = $list[5];
+ my $dType = "";
+ my $tmp = "";
+ if ($decomp =~ /^<(\w+)>$/)
+ {
+ $tmp = $1;
+ $tmp =~ tr/a-z/A-Z/;
+ $dType = "DECOMP_".$tmp;
+ }
+ elsif ($decomp =~ /^<(\w+)> ([A-F0-9 ]*)$/)
+ {
+ $tmp = $1;
+ $tmp =~ tr/a-z/A-Z/;
+ $dType = "DECOMP_".$tmp;
+ }
+ else
+ {
+ $dType = "DECOMP_CANONICAL";
+ }
- close(UCD);
+ $self->{hex($list[0])} = $dType;
+ }
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- $self->{_ELEM} = "";
+ close(UCD);
- bless($self);
- return $self;
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+ $self->{_ELEM} = "";
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
+sub include
+{
+ return "";
}
-sub init {
- return "";
+sub init
+{
+ return "";
}
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ if ($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ $self->{_ELEM} = $self->data($i) if ($self->{_ELEM} eq "");
+ if ($self->{_ELEM} ne $self->data($i))
+ {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
}
- }
-
- my $tmp = " Char_Decomp decomp_type(const UCS4 uc) const {\n";
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return DECOMP_MAX;\n";
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return Babylon::Char_Decomp($bl_name\:\:_decomp\[uc - m_first_letter\]);\n";
- $tmp .= " }\n\n";
- return $tmp;
- } else {
- $tmp .= sprintf " return Babylon\:\:Char_Decomp(%s);\n }\n\n",
- $self->{_ELEM};
- return $tmp;
- }
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ my $tmp = " Char_Decomp decomp_type(const UCS4 uc) const\n {\n";
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return DECOMP_MAX;\n";
+
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " return Babylon::Char_Decomp($bl_name\:\:my_decomp\[uc - my_first_letter\]);\n";
+ $tmp .= " }\n\n";
+ return $tmp;
}
- }
+ $tmp .= sprintf " return Babylon\:\:Char_Decomp(%s);\n }\n\n",
+ $self->{_ELEM};
+ return $tmp;
+}
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const unsigned char _decomp\[$bl_length\];\n";
- } else {
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+
+ return " static const unsigned char my_decomp\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const unsigned char $bl_name\:\:my_decomp\[\] = {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= "\n " if (($i - $bl_start) % 4 == 0);
+ if ($self->data($i) eq "undef")
+ {
+ $tmp .= $self->{_ELEM};
+ }
+ else
+ {
+ $tmp .= $self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
-
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const unsigned char $bl_name\:\:_decomp\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= $self->{_ELEM};
- } else {
- $tmp .= $self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ $tmp .= "\n };\n\n";
+ return $tmp;
}
- $tmp .= "\n };\n\n";
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...
Index: DecompString.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/DecompString.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- DecompString.pm 6 May 2001 12:18:46 -0000 1.5
+++ DecompString.pm 1 Aug 2003 16:47:17 -0000 1.6
@@ -1,309 +1,294 @@
package UnicodePluginGenerator::DecompString;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- next if ($info eq "");
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- my @list = split /;/, $info, 15;
+ next if ($info eq "");
- my $decomp = $list[5];
- my $dType = "";
- my $tmp = "";
- if ($decomp =~ /^<(\w+)>$/) {
- $tmp = "";
- } elsif ($decomp =~ /^<(\w+)> ([A-F0-9 ]*)$/) {
- $tmp = $2;
- } else {
- $tmp = $decomp;
- }
+ my @list = split /;/, $info, 15;
- if ($tmp ne "") {
- $self->{hex($list[0])} = $tmp;
+ my $decomp = $list[5];
+ my $dType = "";
+ my $tmp = "";
+ if ($decomp =~ /^<(\w+)>$/)
+ {
+ $tmp = "";
+ }
+ elsif ($decomp =~ /^<(\w+)> ([A-F0-9 ]*)$/)
+ {
+ $tmp = $2;
+ }
+ else
+ {
+ $tmp = $decomp;
+ }
+
+ $self->{hex($list[0])} = $tmp if ($tmp ne "");
}
- }
-
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- $self->{_MAX_LENGTH} = 2;
- bless($self);
- return $self;
+ close(UCD);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+ $self->{_MAX_LENGTH} = 2;
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
+ my $result = "";
- my $pos = $_[0];
- my $result = "";
+ if ($pos > 0x003400 and $pos < 0x004DB5) { return "undef"; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { return "undef"; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { return "undef"; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { return "undef"; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { return "undef"; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { return "undef"; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { return "undef"; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { return "undef"; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { return "undef"; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { return "undef"; }
+ elsif(exists($self->{$pos})) { return $self->{$pos}; }
- if ($pos > 0x003400 and $pos < 0x004DB5) {
- return "undef"; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) {
- return "undef"; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) {
- return "undef"; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) {
- return "undef"; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) {
- return "undef"; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) {
- return "undef"; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) {
- return "undef"; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) {
- return "undef"; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) {
- return "undef"; }
- elsif(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
return "undef";
- }
}
-sub include{
- return "";
-}
-
-sub init {
- return "";
-}
-
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
-
- my $tmp = " UTF32_string decompose(const UCS4 uc) const {\n";
-
- if((sprintf "%04X", $bl_start) eq "AC00") { # hangul
- $tmp .= " const UCS4 sBase = 0xAC00;\n";
- $tmp .= " const UCS4 lBase = 0x1100;\n";
- $tmp .= " const UCS4 vBase = 0x1161;\n";
- $tmp .= " const UCS4 tBase = 0x11A7;\n\n";
- $tmp .= " const int lCount = 19;\n";
- $tmp .= " const int vCount = 21;\n";
- $tmp .= " const int tCount = 28;\n";
- $tmp .= " const int nCount = vCount * tCount;\n";
- $tmp .= " const int sCount = lCount * nCount;\n\n";
- $tmp .= " int sIndex = uc - sBase;\n\n";
- $tmp .= " if (sIndex < 0 || sIndex >= sCount) {\n";
- $tmp .= " UTF32_string us; us.resize(1); us[0]=uc;\n";
- $tmp .= " return us;\n\n";
- $tmp .= " }\n";
- $tmp .= " UTF32_string res;\n";
- $tmp .= " UCS4 l = lBase + sIndex / nCount;\n";
- $tmp .= " UCS4 v = vBase + (sIndex % nCount) / tCount;\n";
- $tmp .= " UCS4 t = tBase + sIndex % tCount;\n\n";
- $tmp .= " res += l; res += v;\n";
- $tmp .= " if (t != tBase) res += t;\n\n";
- $tmp .= " return res;\n";
- $tmp .= " }\n\n";
- return $tmp;
- }
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
- $self->{_ATTENTION_NEEDED} = 0;
- $self->{_MAX_LENGTH} = 2;
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- my $tmpstr = $self->data($i);
- if (($tmpstr =~ tr/ / /) > $self->{_ATTENTION_NEEDED} - 1) {
- $self->{_ATTENTION_NEEDED} = ($tmpstr =~ tr/ / /) + 1;
- }
- if (hex($bl_end) > 0xFFFF) {
- $self->{_MAX_LENGTH} = 4;
- } else {
- my @datas = split / /, $self->data($i);
- foreach my $data (@datas) {
- if (hex($data) > 0xFFFF) {
- $self->{_MAX_LENGTH} = 4;
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ $self->{_ELEM} = "";
+ $self->{_ATTENTION_NEEDED} = 0;
+ $self->{_MAX_LENGTH} = 2;
+
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef") {
+ my $tmpstr = $self->data($i);
+ $self->{_ATTENTION_NEEDED} = ($tmpstr =~ tr/ / /) + 1
+ if (($tmpstr =~ tr/ / /) > $self->{_ATTENTION_NEEDED} - 1);
+ if (hex($bl_end) > 0xFFFF) {
+ $self->{_MAX_LENGTH} = 4;
+ }
+ else
+ {
+ my @datas = split / /, $self->data($i);
+ foreach my $data (@datas)
+ {
+ if (hex($data) > 0xFFFF)
+ {
+ $self->{_MAX_LENGTH} = 4;
+ }
+ }
+ }
}
- }
}
- }
}
- }
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " Babylon::UTF32_string us;\n";
- $tmp .= " us.resize(1);\n";
- $tmp .= " us\[0\] = $bl_name\:\:m_decompStr\[uc - m_first_letter\];\n";
- }
- elsif ($self->{_ATTENTION_NEEDED} >= 2) {
- $tmp .= " Babylon::UTF32_string us;\n";
- $tmp .= " us.resize(2);\n";
- $tmp .= " us\[0\] = $bl_name\:\:m_decompStr\[uc - m_first_letter\]\[0\];\n";
- $tmp .= " us\[1\] = $bl_name\:\:m_decompStr\[uc - m_first_letter\]\[1\];\n";
- if ($self->{_ATTENTION_NEEDED} >= 3) {
- $tmp .= "\n switch (uc) {\n";
+}
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- my @tmpstr = split / /, $self->data($i);
- my $data = $self->data($i);
- if(($data =~ tr/ / /) > 1) {
- $tmp .= sprintf "\n case 0x%04X:\n us.resize(%d);\n",
- $i, ($data =~ tr/ / /) + 1;
- for (my $j = 2; $j <= ($data =~ tr/ / /); $j++) {
- $tmp .= sprintf " us\[%du\] = 0x%su;\n", $j, $tmpstr[$j];
- }
- $tmp.= " break;\n";
- }
- }
- $tmp .= " }\n";
- }
- $tmp .= " if (us[1] == 0x0000u) {\n";
- $tmp .= " us.resize(1);\n";
- $tmp .= " }\n\n";
- } else {
- $tmp .= " UTF32_string us;\n";
- $tmp .= " us.resize(1); us[0] = uc;\n";
- }
- $tmp .= " return us;\n";
- $tmp .= " }\n\n";
- return $tmp;
+sub include
+{
+ return "";
}
-sub var_def {
- my $self = shift;
+sub init
+{
+ return "";
+}
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
+sub function {
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
+
+ my $tmp = " UTF32_string decompose(const UCS4 uc) const\n {\n";
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
- $self->{_ATTENTION_NEEDED} = 0;
- $self->{_MAX_LENGTH} = 2;
+ if ((sprintf "%04X", $bl_start) eq "AC00") { # hangul
+ $tmp .= " const UCS4 sBase = 0xAC00;\n";
+ $tmp .= " const UCS4 lBase = 0x1100;\n";
+ $tmp .= " const UCS4 vBase = 0x1161;\n";
+ $tmp .= " const UCS4 tBase = 0x11A7;\n\n";
+ $tmp .= " const int lCount = 19;\n";
+ $tmp .= " const int vCount = 21;\n";
+ $tmp .= " const int tCount = 28;\n";
+ $tmp .= " const int nCount = vCount * tCount;\n";
+ $tmp .= " const int sCount = lCount * nCount;\n\n";
+ $tmp .= " int sIndex = uc - sBase;\n\n";
+ $tmp .= " if (sIndex < 0 || sIndex >= sCount)\n {\n";
+ $tmp .= " UTF32_string us; us.resize(1); us[0]=uc;\n";
+ $tmp .= " return us;\n\n";
+ $tmp .= " }\n";
+ $tmp .= " UTF32_string res;\n";
+ $tmp .= " UCS4 l = lBase + sIndex / nCount;\n";
+ $tmp .= " UCS4 v = vBase + (sIndex % nCount) / tCount;\n";
+ $tmp .= " UCS4 t = tBase + sIndex % tCount;\n\n";
+ $tmp .= " res += l; res += v;\n";
+ $tmp .= " if (t != tBase) res += t;\n\n";
+ $tmp .= " return res;\n";
+ $tmp .= " }\n\n";
+ return $tmp;
+ }
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- my $tmpstr = $self->data($i);
- if (($tmpstr =~ tr/ / /) > $self->{_ATTENTION_NEEDED} - 1) {
- $self->{_ATTENTION_NEEDED} = ($tmpstr =~ tr/ / /) + 1;
- }
- if (hex($bl_end) > 0xFFFF) {
- $self->{_MAX_LENGTH} = 4;
- } else {
- my @datas = split / /, $self->data($i);
- foreach my $data (@datas) {
- if (hex($data) > 0xFFFF) {
- $self->{_MAX_LENGTH} = 4;
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " Babylon::UTF32_string us;\n";
+ $tmp .= " us.resize(1);\n";
+ $tmp .= " us\[0\] = $bl_name\:\:my_decompStr\[uc - my_first_letter\];\n";
+ }
+ elsif ($self->{_ATTENTION_NEEDED} >= 2)
+ {
+ $tmp .= " Babylon::UTF32_string us;\n";
+ $tmp .= " us.resize(2);\n";
+ $tmp .= " us\[0\] = $bl_name\:\:my_decompStr\[uc - my_first_letter\]\[0\];\n";
+ $tmp .= " us\[1\] = $bl_name\:\:my_decompStr\[uc - my_first_letter\]\[1\];\n";
+ if ($self->{_ATTENTION_NEEDED} >= 3)
+ {
+ $tmp .= "\n switch (uc)\n {\n";
+
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ my @tmpstr = split / /, $self->data($i);
+ my $data = $self->data($i);
+ if(($data =~ tr/ / /) > 1)
+ {
+ $tmp .= sprintf "\n case 0x%04X:\n us.resize(%d);\n",
+ $i, ($data =~ tr/ / /) + 1;
+ for (my $j = 2; $j <= ($data =~ tr/ / /); $j++)
+ {
+ $tmp .= sprintf " us\[%du\] = 0x%su;\n", $j, $tmpstr[$j];
+ }
+ $tmp.= " break;\n";
+ }
}
- }
+ $tmp .= " }\n";
}
- }
+ $tmp .= " if (0x0000u == us[1])\n";
+ $tmp .= " us.resize(1);\n";
}
- }
+ else
+ {
+ $tmp .= " UTF32_string us;\n";
+ $tmp .= " us.resize(1); us[0] = uc;\n";
+ }
+ $tmp .= " return us;\n";
+ $tmp .= " }\n\n";
+ return $tmp;
+}
- my $len = $self->{_MAX_LENGTH};
- if ($self->{_ATTENTION_NEEDED} == 1) {
- return " static const UCS$len m_decompStr\[$bl_length\];\n";
- } elsif ($self->{_ATTENTION_NEEDED} > 1) {
- return " static const UCS$len m_decompStr\[$bl_length\][2];\n";
- } else {
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+
+ my $len = $self->{_MAX_LENGTH};
+ return " static const UCS$len my_decompStr\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED} == 1);
+ return " static const UCS$len my_decompStr\[$bl_length\][2];\n"
+ if ($self->{_ATTENTION_NEEDED} > 1);
return "";
- }
}
sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
- $self->{_ATTENTION_NEEDED} = 0;
- $self->{_MAX_LENGTH} = 2;
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- my $tmpstr = $self->data($i);
- if (($tmpstr =~ tr/ / /) > $self->{_ATTENTION_NEEDED} - 1) {
- $self->{_ATTENTION_NEEDED} = ($tmpstr =~ tr/ / /) + 1;
- }
- if (hex($bl_end) > 0xFFFF) {
- $self->{_MAX_LENGTH} = 4;
- } else {
- my @datas = split / /, $self->data($i);
- foreach my $data (@datas) {
- if (hex($data) > 0xFFFF) {
- $self->{_MAX_LENGTH} = 4;
+ my $len = $self->{_MAX_LENGTH};
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ my $tmp = " const UCS$len $bl_name\:\:my_decompStr\[\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ my $data = $self->data($i);
+ if (($i - $bl_start) % 4 == 0)
+ {
+ if (($i - $bl_start) == 0)
+ {
+ $tmp .= "\n ";
+ }
+ else
+ {
+ $tmp .= sprintf " // %08X\n ", ($i - 4);
+ }
}
- }
+ if ($data eq "undef")
+ {
+ $tmp .= sprintf "0x%08Xu", $i;
+ }
+ elsif (($data =~ tr/ / /) == 0)
+ {
+ $tmp .= sprintf "0x%08Xu", hex($data);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
}
- }
- }
- }
-
- my $len = $self->{_MAX_LENGTH};
- if ($self->{_ATTENTION_NEEDED} == 1) {
- my $tmp = " const UCS$len $bl_name\:\:m_decompStr\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- my $data = $self->data($i);
- if (($i - $bl_start) % 4 == 0) {
- $tmp .= "\n ";
- }
- if ($data eq "undef") {
- $tmp .= sprintf "0x%04Xu", $i;
- } elsif (($data =~ tr/ / /) == 0) {
- $tmp .= "0x".$data."u";
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ $tmp .= "\n };\n\n";
+ return $tmp;
}
- $tmp .= "\n };\n\n";
- return $tmp;
- } elsif ($self->{_ATTENTION_NEEDED} > 1) {
- my $tmp = " const UCS$len $bl_name\:\:m_decompStr\[\]\[2\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- my $data = $self->data($i);
- if (($i - $bl_start) % 4 == 0) {
- $tmp .= "\n ";
- }
- if ($data eq "undef") {
- $tmp .= sprintf "{ 0x%04Xu, 0x0000u }", $i;
- } elsif (($data =~ tr/ / /) == 0) {
- $tmp .= "{ 0x".$data."u, 0x0000u }";
- } elsif (($data =~ tr/ / /) >= 1) {
- my @tmpstr = split / /, $data;
- $tmp .= "{ 0x".$tmpstr[0]."u, 0x".$tmpstr[1]."u }";
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ elsif ($self->{_ATTENTION_NEEDED} > 1)
+ {
+ my $tmp = " const UCS$len $bl_name\:\:my_decompStr\[\]\[2\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ my $data = $self->data($i);
+ if (($i - $bl_start) % 2 == 0)
+ {
+ if (($i - $bl_start) == 0)
+ {
+ $tmp .= "\n ";
+ }
+ else
+ {
+ $tmp .= sprintf " // %08X\n ", ($i - 2);
+ }
+ }
+ if ($data eq "undef")
+ {
+ $tmp .= sprintf "{ 0x%08Xu, 0x00000000u }", $i;
+ }
+ elsif (($data =~ tr/ / /) == 0)
+ {
+ $tmp .= sprintf "{ 0x%08Xu, 0x00000000u }", hex($data);
+ }
+ elsif (($data =~ tr/ / /) >= 1)
+ {
+ my @tmpstr = split / /, $data;
+ $tmp .= sprintf "{ 0x%08Xu, 0x%08Xu }",
+ hex($tmpstr[0]), hex($tmpstr[1]);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
+ }
+ $tmp .= "\n };\n\n";
+ return $tmp;
}
- $tmp .= "\n };\n\n";
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...
Index: Defined.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Defined.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Defined.pm 6 May 2001 12:18:46 -0000 1.5
+++ Defined.pm 1 Aug 2003 16:47:17 -0000 1.6
@@ -1,151 +1,138 @@
package UnicodePluginGenerator::Defined;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
-
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
-
- next if ($info eq "");
-
- my @list = split /;/, $info, 15;
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- $self->{hex($list[0])} = 1;
- }
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- close(UCD);
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
+ next if ($info eq "");
+
+ my @list = split /;/, $info, 15;
+
+ $self->{hex($list[0])} = 1;
+ }
- bless($self);
- return $self;
+ close(UCD);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if(exists($self->{$pos})) {
- return 1;
- } else {
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return 1 if(exists($self->{$pos}));
return 0;
- }
}
-sub include {
- return "";
-}
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
-sub init {
- return "";
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) == 0) {
+ $self->{_ATTENTION_NEEDED} = 1 ;
+ last;
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
+ }
}
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
-
- my $tmp = " bool is_defined(const UCS4 uc) const {\n";
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) == 0) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+sub include
+{
+ return "";
+}
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return (m_is_defined.test(uc - m_first_letter));\n";
- } else {
- $tmp .= " return 1;\n";
- }
- $tmp .= " }\n\n";
+sub init
+{
+ return "";
}
-sub var_def {
- my $self = shift;
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
+ my $tmp = " bool is_defined(const UCS4 uc) const\n {\n";
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) == 0) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " return (my_is_defined.test(uc - my_first_letter));\n";
}
- }
+ else
+ {
+ $tmp .= " return 1;\n";
+ }
+ $tmp .= " }\n\n";
+}
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " static const std::bitset<$bl_length> m_is_defined;\n";
- } else {
+ return " static const std::bitset<$bl_length> my_is_defined;\n"
+ if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start + 1;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) == 0) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
-
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const std::bitset<$bl_length> $bl_name\:\:m_is_defined(std::string(\"";
- my $str = "";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- $str = $self->data($i).$str;
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const std::bitset<$bl_length> $bl_name\:\:my_is_defined(std::string(\"";
+ my $str = "";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ $str = $self->data($i).$str;
+ }
+ $tmp .= $str."\"));\n\n";
+ return $tmp;
}
- $tmp .= $str."\"));\n\n";
- } else {
return "";
- }
}
1; # for use to succeed...
Index: DigitVal.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/DigitVal.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- DigitVal.pm 6 May 2001 12:18:46 -0000 1.4
+++ DigitVal.pm 1 Aug 2003 16:47:17 -0000 1.5
@@ -1,135 +1,147 @@
package UnicodePluginGenerator::DigitVal;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
-
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
-
- next if ($info eq "");
-
- my @list = split /;/, $info, 15;
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- if ($list[7] ne "") {
- $self->{hex($list[0])} = $list[7];
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
+
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+
+ next unless ($info);
+
+ my @list = split /;/, $info, 15;
+
+ $self->{hex($list[0])} = $list[7] if ($list[7] ne "");
}
- }
-
- close(UCD);
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
-
- bless($self);
- return $self;
+ close(UCD);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- my $pos = $_[0];
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if (exists($self->{$pos}));
+ return "undef";
+}
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
- return "undef";
- }
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
+ }
}
-sub include {
- return "";
+sub include
+{
+ return "";
}
-sub init {
- return "";
+sub init
+{
+ return "";
}
sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ my $tmp = " int digit_value(const UCS4 uc) const\n {\n";
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " switch(uc)\n {\n";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= sprintf " case 0x%04Xu:\n return %d;\n", $i, $self->{$i} if($self->data($i) ne "undef");
+ }
+ $tmp .= " default:\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " }\n";
}
- }
-
- my $tmp = " int digit_value(const UCS4 uc) const {\n";
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return 0;\n";
- $tmp .= " switch(uc) {\n";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if($self->data($i) ne "undef") {
- $tmp .= sprintf " case 0x%04Xu:\n return %d;\n",
- $i, $self->{$i};
- $tmp .= " break;\n";
- }
+ else
+ {
+ $tmp .= " return 0;\n";
}
- $tmp .= " default:\n";
- $tmp .= " return 0;\n";
- $tmp .= " }\n";
- } else {
- $tmp .= " return 0;\n";
- }
- $tmp .= " }\n\n";
+ $tmp .= " }\n\n";
- $tmp .= " bool is_Digit(const UCS4 uc) const {\n";
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " switch(uc) {\n";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if($self->data($i) ne "undef") {
- $tmp .= sprintf " case 0x%04Xu:\n",
- $i;
- }
+ $tmp .= " bool is_Digit(const UCS4 uc) const\n {\n";
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " switch(uc)\n {\n";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= sprintf " case 0x%04Xu:\n", $i
+ if($self->data($i) ne "undef");
+ }
+ $tmp .= " return 1;\n";
+ $tmp .= " default:\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " }\n";
}
- $tmp .= " return 1;\n";
- $tmp .= " default:\n";
- $tmp .= " return 0;\n";
- $tmp .= " }\n";
- } else {
- $tmp .= " return 0;\n";
- }
- $tmp .= " }\n\n";
+ else
+ {
+ $tmp .= " return 0;\n";
+ }
+ $tmp .= " }\n\n";
- return $tmp;
+ return $tmp;
}
-sub var_def {
- my $self = shift;
- return "";
+sub var_def
+{
+ return "";
}
-sub var {
- my $self = shift;
- return "";
+sub var
+{
+ return "";
}
1; # for use to succeed...
Index: EAWidth.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/EAWidth.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- EAWidth.pm 6 May 2001 12:18:46 -0000 1.5
+++ EAWidth.pm 1 Aug 2003 16:47:17 -0000 1.6
@@ -1,192 +1,162 @@
package UnicodePluginGenerator::EAWidth;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file) or die "Can't open ".$ucd_file.".\n";
+sub new
+{
+ my $self = {};
+ my $ea_file = $_[1];
+
+ open(EA, $ea_file) or die "Can't open ".$ea_file.".\n";
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ while(<EA>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- next if ($info eq "");
+ next unless ($info);
- my @list = split /;/, $info;
+ my @list = split /;/, $info;
+
+ if ($list[0] =~ /[A-F0-9]+\.\.[A-F0-9]+/)
+ {
+ (my $start, my $end) = split /\.\./, $list[0];
+ $self->{hex($start)} = "EA_WIDTH_".$list[1];
+ $list[0] = $end;
+ }
- if ($list[0] =~ /[A-F0-9]+\.\.[A-F0-9]+/) {
- (my $start, my $end) = split /\.\./, $list[0];
- $self->{hex($start)} = "EA_WIDTH_".$list[1];
- $list[0] = $end;
+ $self->{hex($list[0])} = "EA_WIDTH_".$list[1];
}
+
+ close(EA);
- $self->{hex($list[0])} = "EA_WIDTH_".$list[1];
- }
-
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- $self->{_ELEM} = "";
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+ $self->{_ELEM} = "";
- bless($self);
- return $self;
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D5) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ $self->{_ELEM} = "";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ $self->{_ELEM} = $self->data($i) if ($self->{_ELEM} eq "");
+ if ($self->{_ELEM} ne $self->data($i)) {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
+ }
}
-sub init {
- return "";
+sub include
+{
+ return "";
}
-sub function {
- my $self = shift;
+sub init
+{
+ return "";
+}
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ my $tmp = " EA_Width EA_width(const UCS4 uc) const\n {\n";
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return EA_WIDTH_MAX;\n";
+
+ if ($self->{_ATTENTION_NEEDED} == 1)
+ {
+ $tmp .= " return Babylon::EA_Width($bl_name\:\:my_ea\[uc - my_first_letter\]);\n";
+ $tmp .= " }\n\n";
+ return $tmp;
}
- }
-
- my $tmp = " EA_Width EA_width(const UCS4 uc) const {\n";
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return EA_WIDTH_MAX;\n";
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return Babylon::EA_Width($bl_name\:\:m_ea\[uc - m_first_letter\]);\n";
- $tmp .= " }\n\n";
- return $tmp;
- } else {
- $tmp .= sprintf " return Babylon::EA_Width(%s);\n }\n\n",
+ $tmp .= sprintf " return Babylon::EA_Width(%s);\n }\n\n",
$self->{_ELEM};
return $tmp;
- }
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
-
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const unsigned char m_ea\[$bl_length\];\n";
- } else {
+ return " static const unsigned char my_ea\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const unsigned char $bl_name\:\:my_ea\[\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= "\n " if (($i - $bl_start) % 4 == 0);
+ if ($self->data($i) eq "undef") {
+ $tmp .= $self->{_ELEM};
+ }
+ else
+ {
+ $tmp .= $self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
-
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const unsigned char $bl_name\:\:m_ea\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= $self->{_ELEM};
- } else {
- $tmp .= $self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ $tmp .= "\n };\n\n";
+ return $tmp;
}
- $tmp .= "\n };\n\n";
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...
Index: Linebreak.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Linebreak.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Linebreak.pm 6 May 2001 12:18:46 -0000 1.5
+++ Linebreak.pm 1 Aug 2003 16:47:17 -0000 1.6
@@ -1,188 +1,167 @@
package UnicodePluginGenerator::Linebreak;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
+sub new
+{
+ my $self = {};
+ my $lb_file = $_[1];
- open(UCD, $ucd_file) or die "Can't open ".$ucd_file.".\n";
+ open(LB, $lb_file) or die "Can't open ".$lb_file.".\n";
+
+ while(<LB>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ next unless ($info);
- next if ($info eq "");
+ my @list = split /;/, $info;
- my @list = split /;/, $info;
+ if ($list[0] =~ /[A-F0-9]+\.\.[A-F0-9]+/)
+ {
+ (my $start, my $end) = split /\.\./, $list[0];
+ $self->{hex($start)} = "LB_".$list[1];
+ $list[0] = $end;
+ }
- if ($list[0] =~ /[A-F0-9]+\.\.[A-F0-9]+/) {
- (my $start, my $end) = split /\.\./, $list[0];
- $self->{hex($start)} = "LB_".$list[1];
- $list[0] = $end;
+ $self->{hex($list[0])} = "LB_".$list[1];
}
- $self->{hex($list[0])} = "LB_".$list[1];
- }
-
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- $self->{_ELEM} = "";
-
- bless($self);
- return $self;
+ close(LB);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+ $self->{_ELEM} = "";
+
+ bless($self);
+ return $self;
}
sub data {
- my $self = shift;
-
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+ my $self = shift;
+ my $pos = $_[0];
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
-}
-
-sub init {
- return "";
-}
-
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ $self->{_ELEM} = "";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ if ($self->{_ELEM} eq "")
+ {
+ $self->{_ELEM} = $self->data($i);
+ }
+ elsif ($self->{_ELEM} ne $self->data($i))
+ {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
}
- }
+}
- my $tmp = " Line_Break linebreak(const UCS4 uc) const {\n";
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return LB_MAX;\n";
+sub include
+{
+ return "";
+}
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return Babylon::Line_Break($bl_name\:\:m_lb\[uc - m_first_letter\]);\n";
- $tmp .= " }\n\n";
- return $tmp;
- } else {
- $tmp .= sprintf " return Babylon::Line_Break(%s);\n }\n\n",
- $self->{_ELEM};
- return $tmp;
- }
+sub init
+{
+ return "";
}
-sub var_def {
- my $self = shift;
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
+ my $tmp = " Line_Break linebreak(const UCS4 uc) const\n {\n";
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return LB_MAX;\n";
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ $tmp .= " return Babylon::Line_Break($bl_name\:\:my_lb\[uc - my_first_letter\]);\n";
+ $tmp .= " }\n\n";
}
- }
+ else
+ {
+ $tmp .= sprintf " return Babylon::Line_Break(%s);\n }\n\n",
+ $self->{_ELEM};
+ }
+ return $tmp;
+}
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const unsigned char m_lb\[$bl_length\];\n";
- } else {
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+
+ return " static const unsigned char my_lb\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- $self->{_ELEM} = "";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- } elsif ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ if ($self->{_ATTENTION_NEEDED}) {
+ my $tmp = " const unsigned char $bl_name\:\:my_lb\[\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= "\n " if (($i - $bl_start) % 8 == 0);
+ if ($self->data($i) eq "undef")
+ {
+ $tmp .= $self->{_ELEM};
+ }
+ else
+ {
+ $tmp .= $self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
-
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const unsigned char $bl_name\:\:m_lb\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= $self->{_ELEM};
- } else {
- $tmp .= $self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ $tmp .= "\n };\n\n";
+
+ return $tmp;
}
- $tmp .= "\n };\n\n";
-
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...
Index: Lower.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Lower.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Lower.pm 6 May 2001 12:18:46 -0000 1.4
+++ Lower.pm 1 Aug 2003 16:47:17 -0000 1.5
@@ -1,164 +1,152 @@
package UnicodePluginGenerator::Lower;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
-
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
-
- next if ($info eq "");
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
+
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- my @list = split /;/, $info, 15;
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+
+ next unless ($info);
- if ($list[13] ne "") {
- $self->{hex($list[0])} = $list[13];
+ my @list = split /;/, $info, 15;
+
+ $self->{hex($list[0])} = $list[13] if ($list[13]);
}
- }
-
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
+
+ close(UCD);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
- bless($self);
- return $self;
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
+sub include
+{
+ return "";
}
-sub init {
- return "";
+sub init
+{
+ return "";
}
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
}
- }
-
- my $tmp = " UCS4 lowercase(const UCS4 uc) const {\n";
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return $bl_name\:\:m_lower\[uc - m_first_letter\];\n";
- } else {
- $tmp .= " return uc;\n";
- }
- $tmp .= " }\n\n";
-
- return $tmp;
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ my $tmp = " UCS4 lowercase(const UCS4 uc) const\n {\n";
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ $tmp .= " return $bl_name\:\:my_lower\[uc - my_first_letter\];\n";
}
- }
+ else
+ {
+ $tmp .= " return uc;\n";
+ }
+ $tmp .= " }\n\n";
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const UCS4 m_lower\[$bl_length\];\n";
- } else {
- return "";
- }
+ return $tmp;
}
-sub var {
- my $self = shift;
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
+ return " static const UCS4 my_lower\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED}) ;
+ return "";
+}
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const UCS4 $bl_name\:\:m_lower\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= sprintf "0x%04X", $i;
- } else {
- $tmp .= "0x".$self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const UCS4 $bl_name\:\:my_lower\[\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++) {
+ if (($i - $bl_start) % 8 == 0)
+ {
+ $tmp .= "\n ";
+ }
+ if ($self->data($i) eq "undef")
+ {
+ $tmp .= sprintf "0x%04X", $i;
+ }
+ else
+ {
+ $tmp .= "0x".$self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
+ }
+ $tmp .= "\n };\n\n";
+
+ return $tmp;
}
- $tmp .= "\n };\n\n";
-
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...
Index: Mirror.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Mirror.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Mirror.pm 6 May 2001 12:18:46 -0000 1.5
+++ Mirror.pm 1 Aug 2003 16:47:17 -0000 1.6
@@ -1,177 +1,157 @@
package UnicodePluginGenerator::Mirror;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- next if ($info eq "");
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- my @list = split /;/, $info, 15;
+ next unless ($info);
- if ($list[9] eq "Y") {
- $self->{hex($list[0])} = 1;
- } else {
- $self->{hex($list[0])} = 0;
+ my @list = split /;/, $info, 15;
+
+ if ($list[9] eq "Y") {
+ $self->{hex($list[0])} = 1;
+ } else {
+ $self->{hex($list[0])} = 0;
+ }
}
- }
-
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- $self->{_ELEM} = "";
+
+ close(UCD);
- bless($self);
- return $self;
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+ $self->{_ELEM} = "";
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
-
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D5) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
+sub include
+{
+ return "";
}
-sub init {
- return "";
+sub init
+{
+ return "";
}
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ $self->{_ELEM} = $self->data($i) if ($self->{_ELEM} eq "");
+ if ($self->{_ELEM} ne $self->data($i)) {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
}
- }
+}
- my $tmp = " bool must_mirror(const UCS4 uc) const {\n";
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return m_mirror.test(uc - m_first_letter);\n";
- $tmp .= " }\n\n";
- return $tmp;
- } else {
- $tmp .= sprintf " return %s;\n }\n\n", $self->{_ELEM};
+ my $tmp = " bool must_mirror(const UCS4 uc) const\n {\n";
+
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ $tmp .= " return my_mirror.test(uc - my_first_letter);\n";
+ $tmp .= " }\n\n";
+ }
+ else
+ {
+ $tmp .= sprintf " return %s;\n }\n\n", $self->{_ELEM};
+ }
return $tmp;
- }
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " static const std::bitset<$bl_length> m_mirror;\n";
- } else {
+ return " static const std::bitset<$bl_length> my_mirror;\n"
+ if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
-
- my $bl_length = $bl_end - $bl_start + 1;
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- if ($self->{_ELEM} eq "") {
- $self->{_ELEM} = $self->data($i);
- }
- if ($self->{_ELEM} ne $self->data($i)) {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const std::bitset<$bl_length> $bl_name\:\:my_mirror(std::string(\"";
+ my $str = "";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) eq "undef")
+ {
+ $str = $self->{_ELEM}.$str;
+ }
+ else
+ {
+ $str = $self->data($i).$str;
+ }
}
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
-
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const std::bitset<$bl_length> $bl_name\:\:m_mirror(std::string(\"";
- my $str = "";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) eq "undef") {
- $str = $self->{_ELEM}.$str;
- } else {
- $str = $self->data($i).$str;
- }
+ $tmp .= $str."\"));\n\n";
+ return $tmp;
}
- $tmp .= $str."\"));\n\n";
- } else {
return "";
- }
}
1; # for use to succeed...
Index: NumericVal.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/NumericVal.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- NumericVal.pm 6 May 2001 12:18:46 -0000 1.4
+++ NumericVal.pm 1 Aug 2003 16:47:17 -0000 1.5
@@ -1,135 +1,145 @@
package UnicodePluginGenerator::NumericVal;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- next if ($info eq "");
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- my @list = split /;/, $info, 15;
+ next unless ($info);
- if ($list[8] ne "") {
- $self->{hex($list[0])} = eval($list[8]);
+ my @list = split /;/, $info, 15;
+
+ $self->{hex($list[0])} = eval($list[8]) if ($list[8] ne "");
}
- }
-
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
- bless($self);
- return $self;
+ close(UCD);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D5) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include{
- return "";
-}
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
-sub init {
- return "";
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef") {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
+ }
}
-sub function {
- my $self = shift;
+sub include
+{
+ return "";
+}
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub init
+{
+ return "";
+}
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
+sub function {
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
+
+ my $tmp = " float numeric_value(const UCS4 uc) const\n {\n";
+
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ $tmp .= " if (!is_defined(uc))\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " switch(uc)\n {\n";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= sprintf " case 0x%04Xu:\n return %f;\n", $i, $self->{$i} if ($self->data($i) ne "undef");
+ }
+ $tmp .= " default:\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " }\n";
}
- }
-
- my $tmp = " float numeric_value(const UCS4 uc) const {\n";
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " if (!is_defined(uc))\n";
- $tmp .= " return 0;\n";
- $tmp .= " switch(uc) {\n";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if($self->data($i) ne "undef") {
- $tmp .= sprintf " case 0x%04Xu:\n return %f;\n",
- $i, $self->{$i};
- $tmp .= " break;\n";
- }
+ else
+ {
+ $tmp .= " return 0;\n";
}
- $tmp .= " default:\n";
- $tmp .= " return 0;\n";
- $tmp .= " }\n";
- } else {
- $tmp .= " return 0;\n";
- }
- $tmp .= " }\n\n";
+ $tmp .= " }\n\n";
- $tmp .= " bool is_Numeric(const UCS4 uc) const {\n";
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " switch(uc) {\n";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if($self->data($i) ne "undef") {
- $tmp .= sprintf " case 0x%04Xu:\n",
- $i;
- }
+ $tmp .= " bool is_Numeric(const UCS4 uc) const\n {\n";
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ $tmp .= " switch(uc)\n {\n";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= sprintf " case 0x%04Xu:\n", $i if($self->data($i) ne "undef");
+ }
+ $tmp .= " return 1;\n";
+ $tmp .= " default:\n";
+ $tmp .= " return 0;\n";
+ $tmp .= " }\n";
}
- $tmp .= " return 1;\n";
- $tmp .= " default:\n";
- $tmp .= " return 0;\n";
- $tmp .= " }\n";
- } else {
- $tmp .= " return 0;\n";
- }
- $tmp .= " }\n\n";
+ else
+ {
+ $tmp .= " return 0;\n";
+ }
+ $tmp .= " }\n\n";
- return $tmp;
+ return $tmp;
}
-sub var_def {
- my $self = shift;
+sub var_def
+{
return "";
}
-sub var {
- my $self = shift;
+sub var
+{
return "";
}
Index: Prop.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Prop.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Prop.pm 6 May 2001 12:18:46 -0000 1.5
+++ Prop.pm 1 Aug 2003 16:47:17 -0000 1.6
@@ -1,165 +1,177 @@
package UnicodePluginGenerator::Props;
use strict;
-sub new {
- my $self = {};
- my $prop_file = $_[1];
- my $currentProp = "";
- my %_props;
- my $skipThis = 1;
- my @propList;
+sub new
+{
+ my $self = {};
+ my $prop_file = $_[1];
+ my $currentProp = "";
+ my %_props;
+ my @propList;
- open(PROP, $prop_file) or die "Can't open Propertyfile (".$prop_file.")\n";
- while(<PROP>) {
- next if ($_ eq "\n"); # skip empty lines
+ open(PROP, $prop_file) or
+ die "Can't open Propertyfile (".$prop_file.")\n";
+ while(<PROP>)
+ {
+ chop;
+ next unless ($_); # skip empty lines
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ (my $info, my $rest) = split /#/;
+ $info =~ s/\s*$//; # remove trailing spaces
- next if ($info eq "");
+ next unless ($info);
- if ($info =~ /^([A-F0-9]+)\.\.([A-F0-9]+)\s*; ([\w\-]+)/) {
- if ($3 ne $currentProp) {
- $currentProp = $3;
- push @propList, $currentProp;
- }
- for (my $i = hex($1); $i <= hex($2); $i++) {
- $self->{$3}{$i} = 1;
- }
- } elsif ($info =~ /^([A-F0-9]+)(\s*); ([\w\-]+)/) {
- if ($3 ne $currentProp) {
- $currentProp = $3;
- push @propList, $currentProp;
- }
- $self->{$3}{hex($1)} = 1 if (!$skipThis);
+ if ($info =~ /^([A-F0-9]+)\.\.([A-F0-9]+)\s*; ([\w\-]+)/)
+ {
+ if ($3 ne $currentProp)
+ {
+ $currentProp = $3;
+ push @propList, $currentProp;
+ }
+ for (my $i = hex($1); $i <= hex($2); $i++)
+ {
+ $self->{$3}{$i} = 1;
+ }
+ }
+ elsif ($info =~ /^([A-F0-9]+)\s*; ([\w\-]+)/)
+ {
+ if ($2 ne $currentProp) {
+ $currentProp = $2;
+ push @propList, $currentProp;
+ }
+ $self->{$2}{hex($1)} = 1;
+ }
}
- }
- $self->{_PROP_LIST} = [ @propList ];
-
- close(PROP);
-
- bless($self);
- return $self;
+ $self->{_PROP_LIST} = [ @propList ];
+
+ close(PROP);
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $prop = $_[0];
- my $pos = $_[1];
+sub data
+{
+ my $self = shift;
+ my $prop = $_[0];
+ my $pos = $_[1];
- no strict 'refs';
+ no strict 'refs';
- if(exists($self->{$prop}{$pos})) {
- return 1;
- }
- return 0;
+ return 1 if(exists($self->{$prop}{$pos}));
+ return 0;
}
-sub include {
- return "";
+sub include
+{
+ return "";
}
-sub init {
- return "";
+sub init
+{
+ return "";
}
-sub function {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
-
- my @propList = @{ $self->{_PROP_LIST} };
- my $tmp = "";
+sub function
+{
+ my $self = shift;
- foreach my $prop (@propList) {
- my $func = $prop;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- my $retval = $self->data($prop, $bl_start);
- my $attention = 0;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($prop, $i) != $retval) {
- $attention = 1;
- }
- }
+ my @propList = @{ $self->{_PROP_LIST} };
+ my $tmp = "";
+
+ foreach my $prop (@propList)
+ {
+ my $func = $prop;
+
+ my $retval = $self->data($prop, $bl_start);
+ my $attention = 0;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $attention = 1 if ($self->data($prop, $i) != $retval);
+ }
- $tmp .= " bool is_".$func."(const UCS4 uc) const {\n";
- if ($attention) {
- $tmp .= " return m_".$func.".test(uc - m_first_letter);\n";
- } else {
- $tmp .= " return $retval;\n";
+ $tmp .= " bool is_".$func."(const UCS4 uc) const\n {\n";
+ if ($attention)
+ {
+ $tmp .= " return my_".$func.".test(uc - my_first_letter);\n";
+ }
+ else
+ {
+ $tmp .= " return $retval;\n";
+ }
+ $tmp .= " }\n\n";
}
- $tmp .= " }\n\n";
- }
- return $tmp;
+ return $tmp;
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
-
- my @propList = @{ $self->{_PROP_LIST} };
- my $tmp = "";
-
- foreach my $prop (@propList) {
- my $func = $prop;
-
- my $retval = $self->data($prop, $bl_start);
- my $attention = 0;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($prop, $i) != $retval) {
- $attention = 1;
- }
- }
+sub var_def
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_length = $bl_end - $bl_start + 1;
+
+ my @propList = @{ $self->{_PROP_LIST} };
+ my $tmp = "";
+
+ foreach my $prop (@propList)
+ {
+ my $func = $prop;
+
+ my $retval = $self->data($prop, $bl_start);
+ my $attention = 0;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $attention = 1 if ($self->data($prop, $i) != $retval);
+ }
- if ($attention) {
- $tmp .= " static const std::bitset<$bl_length> m_".$func.";\n";
+ $tmp .= " static const std::bitset<$bl_length> my_".$func.";\n" if ($attention);
}
- }
- return $tmp;
+ return $tmp;
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start + 1;
-
- my @propList = @{ $self->{_PROP_LIST} };
- my $tmp = "";
+sub var
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
+ my $bl_length = $bl_end - $bl_start + 1;
- foreach my $prop (@propList) {
- my $func = $prop;
+ my @propList = @{ $self->{_PROP_LIST} };
+ my $tmp = "";
- my $retval = $self->data($prop, $bl_start);
- my $attention = 0;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($prop, $i) != $retval) {
- $attention = 1;
- }
- }
+ foreach my $prop (@propList)
+ {
+ my $func = $prop;
+
+ my $retval = $self->data($prop, $bl_start);
+ my $attention = 0;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $attention = 1 if ($self->data($prop, $i) != $retval);
+ }
- if ($attention) {
- $tmp .= " const std::bitset<$bl_length> $bl_name\:\:m_$func(std::string(\"";
- my $str = "";
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- $str = $self->data($prop, $i).$str;
- }
- $tmp .= $str."\"));\n\n";
+ if ($attention)
+ {
+ $tmp .= " const std::bitset<$bl_length> $bl_name\:\:my_$func(std::string(\"";
+ my $str = "";
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ $str = $self->data($prop, $i).$str;
+ }
+ $tmp .= $str."\"));\n\n";
+ }
}
- }
- return $tmp;
+ return $tmp;
}
1; # for use to succeed...
Index: Title.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Title.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Title.pm 6 May 2001 12:18:46 -0000 1.4
+++ Title.pm 1 Aug 2003 16:47:17 -0000 1.5
@@ -1,163 +1,145 @@
package UnicodePluginGenerator::Title;
use strict;
-sub new {
- my $self = {};
- my $ucd_file = $_[1];
-
- open(UCD, $ucd_file);
-
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
+
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- next if ($info eq "");
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- my @list = split /;/, $info, 15;
+ next unless ($info);
- if ($list[14] ne "") {
- $self->{hex($list[0])} = $list[14];
+ my @list = split /;/, $info, 15;
+
+ $self->{hex($list[0])} = $list[14] if ($list[14] ne "");
}
- }
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
-
- close(UCD);
-
- bless($self);
- return $self;
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+
+ close(UCD);
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef") {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
+ }
}
-sub init {
- return "";
+sub include
+{
+ return "";
}
-sub function {
- my $self = shift;
+sub init
+{
+ return "";
+}
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub function {
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ my $tmp = " UCS4 titlecase(const UCS4 uc) const\n {\n";
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ $tmp .= " return $bl_name\:\:my_title\[uc - my_first_letter\];\n";
}
- }
-
- my $tmp = " UCS4 titlecase(const UCS4 uc) const {\n";
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return $bl_name\:\:m_title\[uc - m_first_letter\];\n";
- } else {
- $tmp .= " return uc;\n";
- }
- $tmp .= " }\n\n";
+ else
+ {
+ $tmp .= " return uc;\n";
+ }
+ $tmp .= " }\n\n";
- return $tmp;
+ return $tmp;
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const UCS4 m_title\[$bl_length\];\n";
- } else {
+ return " static const UCS4 my_title\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const UCS4 $bl_name\:\:m_title\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= sprintf "0x%04X", $i;
- } else {
- $tmp .= "0x".$self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ if ($self->{_ATTENTION_NEEDED}) {
+ my $tmp = " const UCS4 $bl_name\:\:my_title\[\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++)
+ {
+ $tmp .= "\n " if (($i - $bl_start) % 8 == 0);
+ if ($self->data($i) eq "undef")
+ {
+ $tmp .= sprintf "0x%04X", $i;
+ }
+ else
+ {
+ $tmp .= "0x".$self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
+ }
+ $tmp .= "\n };\n\n";
+ return $tmp;
}
- $tmp .= "\n };\n\n";
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...
Index: Upper.pm
===================================================================
RCS file: /cvs/fresco/Fresco/Babylon/utils/UnicodePluginGenerator/Upper.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Upper.pm 6 May 2001 12:18:46 -0000 1.4
+++ Upper.pm 1 Aug 2003 16:47:17 -0000 1.5
@@ -1,170 +1,152 @@
package UnicodePluginGenerator::Upper;
use strict;
-sub new {
- my $self = {};
-
- my $ucd_file = $_[1];
+sub new
+{
+ my $self = {};
+ my $ucd_file = $_[1];
- open(UCD, $ucd_file);
+ open(UCD, $ucd_file) or die "Can't open Character Database.\n";
- while(<UCD>) {
- my $line = chop;
- (my $info, my $rest) = split /#/;
- $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
+ while(<UCD>)
+ {
+ chop;
+ (my $info, my $rest) = split /#/;
+ $info =~ s/([a-zA-Z0-9]*)\s*$/$1/; # remove trailing spaces
- next if ($info eq "");
+ next unless ($info);
- my @list = split /;/, $info, 15;
+ my @list = split /;/, $info, 15;
- if ($list[12] ne "") {
- $self->{hex($list[0])} = $list[12];
+ $self->{hex($list[0])} = $list[12] if ($list[12] ne "");
}
- }
- close(UCD);
-
- $self->{_BL_START} = -1;
- $self->{_BL_END} = -1;
- $self->{_ATTENTION_NEEDED} = 1;
-
- bless($self);
- return $self;
+ close(UCD);
+
+ $self->{_BL_START} = -1;
+ $self->{_BL_END} = -1;
+ $self->{_ATTENTION_NEEDED} = 1;
+
+ bless($self);
+ return $self;
}
-sub data {
- my $self = shift;
-
- my $pos = $_[0];
+sub data
+{
+ my $self = shift;
+ my $pos = $_[0];
- if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
- elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
- elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
- elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
- elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
- elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
- elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
- elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
- elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
+ if ($pos > 0x003400 and $pos < 0x004DB5) { $pos = 0x003400; }
+ elsif ($pos > 0x004E00 and $pos < 0x009FA5) { $pos = 0x004E00; }
+ elsif ($pos > 0x00AC00 and $pos < 0x00D7A3) { $pos = 0x00AC00; }
+ elsif ($pos > 0x00D800 and $pos < 0x00DB7F) { $pos = 0x00D800; }
+ elsif ($pos > 0x00DB80 and $pos < 0x00DBFF) { $pos = 0x00DB80; }
+ elsif ($pos > 0x00DC00 and $pos < 0x00DFFF) { $pos = 0x00DC00; }
+ elsif ($pos > 0x00E000 and $pos < 0x00F8FF) { $pos = 0x00E000; }
+ elsif ($pos > 0x020000 and $pos < 0x02A6D6) { $pos = 0x020000; }
+ elsif ($pos > 0x0F0000 and $pos < 0x0FFFFD) { $pos = 0x0F0000; }
+ elsif ($pos > 0x100000 and $pos < 0x10FFFD) { $pos = 0x100000; }
- if(exists($self->{$pos})) {
- return $self->{$pos};
- } else {
+ return $self->{$pos} if (exists($self->{$pos}));
return "undef";
- }
}
-sub include {
- return "";
-}
+sub setup_for
+{
+ my $self = shift;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
-sub init {
- return "";
+ if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end)
+ {
+ $self->{_BL_START} = $bl_start;
+ $self->{_BL_END} = $bl_end;
+
+ for (my $i = $bl_start; $i <= $bl_end; $i++)
+ {
+ if ($self->data($i) ne "undef")
+ {
+ $self->{_ATTENTION_NEEDED} = 1;
+ last;
+ }
+ $self->{_ATTENTION_NEEDED} = 0;
+ }
+ }
}
-sub function {
- my $self = shift;
+sub include
+{
+ return "";
+}
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
+sub init
+{
+ return "";
+}
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
+sub function
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_name = $_[2];
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
+ my $tmp = " UCS4 uppercase(const UCS4 uc) const\n {\n";
+
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ $tmp .= " return $bl_name\:\:my_upper\[uc - my_first_letter\];\n";
+ }
+ else
+ {
+ $tmp .= " return uc;\n";
}
- }
-
- my $tmp = " UCS4 uppercase(const UCS4 uc) const {\n";
-
- if ($self->{_ATTENTION_NEEDED} == 1) {
- $tmp .= " return $bl_name\:\:m_upper\[uc - m_first_letter\];\n";
- } else {
- $tmp .= " return uc;\n";
- }
- $tmp .= " }\n\n";
+ $tmp .= " }\n\n";
- return $tmp;
+ return $tmp;
}
-sub var_def {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_length = $bl_end - $bl_start + 1;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
-
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+sub var_def
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
- if ($self->{_ATTENTION_NEEDED}) {
- return " static const UCS4 m_upper\[$bl_length\];\n";
- } else {
+ return " static const UCS4 my_upper\[$bl_length\];\n"
+ if ($self->{_ATTENTION_NEEDED});
return "";
- }
}
-sub var {
- my $self = shift;
-
- my $bl_start = $_[0];
- my $bl_end = $_[1];
- my $bl_name = $_[2];
- my $bl_length = $bl_end - $bl_start;
-
- if($self->{_BL_START} != $bl_start or $self->{_BL_END} != $bl_end) {
- $self->{_BL_START} = $bl_start;
- $self->{_BL_END} = $bl_end;
-
- for (my $i = $bl_start; $i <= $bl_end; $i++) {
- if ($self->data($i) ne "undef") {
- $self->{_ATTENTION_NEEDED} = 1;
- last;
- }
- $self->{_ATTENTION_NEEDED} = 0;
- }
- }
+sub var
+{
+ my $self = shift;
+ $self->setup_for($_[0], $_[1]);
+ my $bl_length = $_[1] - $_[0] + 1;
+ my $bl_start = $_[0];
+ my $bl_end = $_[1];
+ my $bl_name = $_[2];
- if ($self->{_ATTENTION_NEEDED}) {
- my $tmp = " const UCS4 $bl_name\:\:m_upper\[\] = {";
- for (my $i= $bl_start; $i <= $bl_end; $i++) {
- if (($i - $bl_start) % 8 == 0) {
- $tmp .= "\n ";
- }
- if ($self->data($i) eq "undef") {
- $tmp .= sprintf "0x%04X", $i;
- } else {
- $tmp .= "0x".$self->data($i);
- }
- if ( $i != $bl_end) {
- $tmp .= ", ";
- }
+ if ($self->{_ATTENTION_NEEDED})
+ {
+ my $tmp = " const UCS4 $bl_name\:\:my_upper\[\] =\n {";
+ for (my $i= $bl_start; $i <= $bl_end; $i++) {
+ $tmp .= "\n " if (($i - $bl_start) % 8 == 0);
+ if ($self->data($i) eq "undef")
+ {
+ $tmp .= sprintf "0x%04X", $i;
+ }
+ else
+ {
+ $tmp .= "0x".$self->data($i);
+ }
+ $tmp .= ", " if ( $i != $bl_end);
+ }
+ $tmp .= "\n };\n\n";
+
+ return $tmp;
}
- $tmp .= "\n };\n\n";
-
- return $tmp;
- } else {
return "";
- }
}
1; # for use to succeed...