use strict;
use Getopt::Std;
my @orig_ARGV = @ARGV;
-our $VERSION = do { my @r = (q$Revision: 1.21 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.22 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
# These may get re-ordered.
# RAW is a do_now as inserted by &enter
my ($e2u,$u2e,$erep,$min_el,$max_el) = @{$encoding{$name}};
output(\*C,$name.'_utf8',$e2u);
output(\*C,'utf8_'.$name,$u2e);
- push(@{$encoding{$name}},outstring(\*C,$e2u->{Cname}.'_def',$erep));
+ # push(@{$encoding{$name}},outstring(\*C,$e2u->{Cname}.'_def',$erep));
}
foreach my $enc (sort cmp_name keys %encoding)
{
- my ($e2u,$u2e,$rep,$min_el,$max_el,$rsym) = @{$encoding{$enc}};
- my @info = ($e2u->{Cname},$u2e->{Cname},$rsym,length($rep),$min_el,$max_el);
+ # my ($e2u,$u2e,$rep,$min_el,$max_el,$rsym) = @{$encoding{$enc}};
+ my ($e2u,$u2e,$rep,$min_el,$max_el) = @{$encoding{$enc}};
+ #my @info = ($e2u->{Cname},$u2e->{Cname},$rsym,length($rep),$min_el,$max_el);
+ my $replen = 0;
+ $replen++ while($rep =~ /\G\\x[0-9A-Fa-f]/g);
+ my @info = ($e2u->{Cname},$u2e->{Cname},qq("$rep"),$replen,$min_el,$max_el);
my $sym = "${enc}_encoding";
$sym =~ s/\W+/_/g;
print C "encode_t $sym = \n";
my $min_el;
if (exists $attr{'subchar'})
{
- my @byte;
- $attr{'subchar'} =~ /^\s*/cg;
- push(@byte,$1) while $attr{'subchar'} =~ /\G\\x([0-9a-f]+)/icg;
- $erep = join('',map(chr(hex($_)),@byte));
+ #my @byte;
+ #$attr{'subchar'} =~ /^\s*/cg;
+ #push(@byte,$1) while $attr{'subchar'} =~ /\G\\x([0-9a-f]+)/icg;
+ #$erep = join('',map(chr(hex($_)),@byte));
+ $erep = $attr{'subchar'};
+ $erep =~ s/^\s+//; $erep =~ s/\s+$//;
}
print "Reading $name ($cs)\n";
my $nfb = 0;
$_Enc2xs
$_Version
$_Inc
+ $_E2X
$_Name
$_TableFiles
$_Now
);
+sub find_e2x{
+ eval { require File::Find };
+ my (@inc, %e2x_dir);
+ for my $inc (@INC){
+ push @inc, $inc unless $inc eq '.'; #skip current dir
+ }
+ File::Find::find(
+ sub {
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks)
+ = lstat($_) or return;
+ -f _ or return;
+ if (/^.*\.e2x$/o){
+ $e2x_dir{$File::Find::dir} ||= $mtime;
+ }
+ return;
+ }, @inc);
+ warn join("\n", keys %e2x_dir), "\n";
+ for my $d (sort {$e2x_dir{$a} <=> $e2x_dir{$b}} keys %e2x_dir){
+ $_E2X = $d;
+ # warn "$_E2X => ", scalar localtime($e2x_dir{$d});
+ return $_E2X;
+ }
+}
+
sub make_makefile_pl
{
eval { require Encode; };
# our used for variable expanstion
$_Enc2xs = $0;
$_Version = $VERSION;
- $_Inc = $INC{"Encode.pm"}; $_Inc =~ s/\.pm$//o;
+ $_E2X = find_e2x();
$_Name = shift;
$_TableFiles = join(",", map {qq('$_')} @_);
$_Now = scalar localtime();
+
eval { require File::Spec; };
warn "Generating Makefile.PL\n";
- _print_expand(File::Spec->catfile($_Inc,"Makefile_PL.e2x"),"Makefile.PL");
+ _print_expand(File::Spec->catfile($_E2X,"Makefile_PL.e2x"),"Makefile.PL");
warn "Generating $_Name.pm\n";
- _print_expand(File::Spec->catfile($_Inc,"_PM.e2x"), "$_Name.pm");
+ _print_expand(File::Spec->catfile($_E2X,"_PM.e2x"), "$_Name.pm");
warn "Generating t/$_Name.t\n";
- _print_expand(File::Spec->catfile($_Inc,"_T.e2x"), "t/$_Name.t");
+ _print_expand(File::Spec->catfile($_E2X,"_T.e2x"), "t/$_Name.t");
warn "Generating README\n";
- _print_expand(File::Spec->catfile($_Inc,"README.e2x"), "README");
+ _print_expand(File::Spec->catfile($_E2X,"README.e2x"), "README");
warn "Generating t/$_Name.t\n";
- _print_expand(File::Spec->catfile($_Inc,"Changes.e2x"), "Changes");
+ _print_expand(File::Spec->catfile($_E2X,"Changes.e2x"), "Changes");
exit;
}
$Encode::Config::ExtModule{$enc} and next;
my $mod = "Encode/$f";
$mod =~ s/\.pm$//o; $mod =~ s,/,::,og;
- warn "$enc => $mod\n";
- $LocalMod{$enc} = $mod;
+ $LocalMod{$enc} ||= $mod;
}
}
}
$_ModLines .=
qq(\$Encode::ExtModule{'$enc'} =\t"$LocalMod{$enc}";\n);
}
+ warn $_ModLines;
$_LocalVer = _mkversion();
+ $_E2X = find_e2x();
$_Inc = $INC{"Encode.pm"}; $_Inc =~ s/\.pm$//o;
- warn "Writing Encode::ConfigLocal\n";
- _print_expand(File::Spec->catfile($_Inc,"ConfigLocal_PM.e2x"),
+ warn "Writing ", File::Spec->catfile($_Inc,"ConfigLocal.pm"), "\n";
+ _print_expand(File::Spec->catfile($_E2X,"ConfigLocal_PM.e2x"),
File::Spec->catfile($_Inc,"ConfigLocal.pm"));
exit;
}