Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various fixes #82

Merged
merged 8 commits into from
Nov 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,164 @@ nytprof.out
*.o
*.bs
/_eumm/
Byte/Byte.c
Byte/Byte.xs
Byte/MYMETA.json
Byte/MYMETA.yml
Byte/Makefile
Byte/Makefile.old
Byte/byte_t.c
Byte/byte_t.exh
Byte/byte_t.fnm
Byte/byte_t.h
Byte/pm_to_blib
CN/CN.c
CN/CN.xs
CN/MYMETA.json
CN/MYMETA.yml
CN/Makefile
CN/Makefile.old
CN/cp_00_t.c
CN/cp_00_t.exh
CN/cp_00_t.fnm
CN/cp_00_t.h
CN/eu_01_t.c
CN/eu_01_t.exh
CN/eu_01_t.fnm
CN/eu_01_t.h
CN/gb_02_t.c
CN/gb_02_t.exh
CN/gb_02_t.fnm
CN/gb_02_t.h
CN/gb_03_t.c
CN/gb_03_t.exh
CN/gb_03_t.fnm
CN/gb_03_t.h
CN/ir_04_t.c
CN/ir_04_t.exh
CN/ir_04_t.fnm
CN/ir_04_t.h
CN/ma_05_t.c
CN/ma_05_t.exh
CN/ma_05_t.fnm
CN/ma_05_t.h
CN/pm_to_blib
EBCDIC/EBCDIC.c
EBCDIC/EBCDIC.xs
EBCDIC/MYMETA.json
EBCDIC/MYMETA.yml
EBCDIC/Makefile
EBCDIC/Makefile.old
EBCDIC/ebcdic_t.c
EBCDIC/ebcdic_t.exh
EBCDIC/ebcdic_t.fnm
EBCDIC/ebcdic_t.h
EBCDIC/pm_to_blib
Encode.c
JP/JP.c
JP/JP.xs
JP/MYMETA.json
JP/MYMETA.yml
JP/Makefile
JP/Makefile.old
JP/cp_00_t.c
JP/cp_00_t.exh
JP/cp_00_t.fnm
JP/cp_00_t.h
JP/eu_01_t.c
JP/eu_01_t.exh
JP/eu_01_t.fnm
JP/eu_01_t.h
JP/ji_02_t.c
JP/ji_02_t.exh
JP/ji_02_t.fnm
JP/ji_02_t.h
JP/ji_03_t.c
JP/ji_03_t.exh
JP/ji_03_t.fnm
JP/ji_03_t.h
JP/ji_04_t.c
JP/ji_04_t.exh
JP/ji_04_t.fnm
JP/ji_04_t.h
JP/ma_05_t.c
JP/ma_05_t.exh
JP/ma_05_t.fnm
JP/ma_05_t.h
JP/pm_to_blib
JP/sh_06_t.c
JP/sh_06_t.exh
JP/sh_06_t.fnm
JP/sh_06_t.h
KR/KR.c
KR/KR.xs
KR/MYMETA.json
KR/MYMETA.yml
KR/Makefile
KR/Makefile.old
KR/cp_00_t.c
KR/cp_00_t.exh
KR/cp_00_t.fnm
KR/cp_00_t.h
KR/eu_01_t.c
KR/eu_01_t.exh
KR/eu_01_t.fnm
KR/eu_01_t.h
KR/jo_02_t.c
KR/jo_02_t.exh
KR/jo_02_t.fnm
KR/jo_02_t.h
KR/ks_03_t.c
KR/ks_03_t.exh
KR/ks_03_t.fnm
KR/ks_03_t.h
KR/ma_04_t.c
KR/ma_04_t.exh
KR/ma_04_t.fnm
KR/ma_04_t.h
KR/pm_to_blib
Makefile~
Symbol/MYMETA.json
Symbol/MYMETA.yml
Symbol/Makefile
Symbol/Makefile.old
Symbol/Symbol.c
Symbol/Symbol.xs
Symbol/pm_to_blib
Symbol/symbol_t.c
Symbol/symbol_t.exh
Symbol/symbol_t.fnm
Symbol/symbol_t.h
TW/MYMETA.json
TW/MYMETA.yml
TW/Makefile
TW/Makefile.old
TW/TW.c
TW/TW.xs
TW/bi_00_t.c
TW/bi_00_t.exh
TW/bi_00_t.fnm
TW/bi_00_t.h
TW/bi_01_t.c
TW/bi_01_t.exh
TW/bi_01_t.fnm
TW/bi_01_t.h
TW/cp_02_t.c
TW/cp_02_t.exh
TW/cp_02_t.fnm
TW/cp_02_t.h
TW/ma_03_t.c
TW/ma_03_t.exh
TW/ma_03_t.fnm
TW/ma_03_t.h
TW/pm_to_blib
Unicode/MYMETA.json
Unicode/MYMETA.yml
Unicode/Makefile
Unicode/Makefile.old
Unicode/Unicode.c
Unicode/pm_to_blib
def_t.c
def_t.exh
def_t.fnm
def_t.h
11 changes: 11 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ use strict;
use warnings;
use ExtUtils::MakeMaker;
use File::Spec;
use Config;

# Just for sure :)
my %ARGV = map { my @r = split /=/,$_; defined $r[1] or $r[1]=1; @r } @ARGV;
$ARGV{DEBUG} and warn "$_ => $ARGV{$_}\n" for sort keys %ARGV;
$ENV{PERL_CORE} ||= $ARGV{PERL_CORE} if $ARGV{PERL_CORE};
# similar strictness as in core
my $ccflags = $Config{ccflags};
if (!$ENV{PERL_CORE}) {
if ($Config{gccversion}) {
$ccflags .= ' -Werror=declaration-after-statement';
$ccflags .= ' -Wpointer-sign' unless $Config{d_cplusplus};
$ccflags .= ' -fpermissive' if $Config{d_cplusplus};
}
}

my %tables =
(
Expand Down Expand Up @@ -45,6 +55,7 @@ WriteMakefile(
SUFFIX => 'gz',
DIST_DEFAULT => 'all tardist',
},
CCFLAGS => $ccflags,
INC => '-I' . File::Spec->catfile( '.', 'Encode' ),
LICENSE => 'perl',
PREREQ_PM => {
Expand Down
2 changes: 1 addition & 1 deletion Unicode/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use strict;
use ExtUtils::MakeMaker;

WriteMakefile(
INC => "-I../Encode",
INC => "-I../Encode",
NAME => 'Encode::Unicode',
VERSION_FROM => "Unicode.pm",
MAN3PODS => {},
Expand Down
56 changes: 42 additions & 14 deletions bin/enc2xs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ my %encode_types = (U => \&encode_U,
);

# Win32 does not expand globs on command line
eval "\@ARGV = map(glob(\$_),\@ARGV)" if ($^O eq 'MSWin32');
if ($^O eq 'MSWin32' and !$ENV{PERL_CORE}) {
eval "\@ARGV = map(glob(\$_),\@ARGV)";
@ARGV = @orig_ARGV unless @ARGV;
}

my %opt;
# I think these are:
Expand All @@ -134,6 +137,8 @@ my %opt;
# -o <output> to specify the output file name (else it's the first arg)
# -f <inlist> to give a file with a list of input files (else use the args)
# -n <name> to name the encoding (else use the basename of the input file.
#Getopt::Long::Configure("bundling");
#GetOptions(\%opt, qw(C M=s S Q q O o=s f=s n=s v));
getopts('CM:SQqOo:f:n:v',\%opt);

$opt{M} and make_makefile_pl($opt{M}, @ARGV);
Expand Down Expand Up @@ -196,19 +201,25 @@ sub compiler_info {
# This really should go first, else the die here causes empty (non-erroneous)
# output files to be written.
my @encfiles;
if (exists $opt{'f'}) {
if (exists $opt{f}) {
# -F is followed by name of file containing list of filenames
my $flist = $opt{'f'};
my $flist = $opt{f};
open(FLIST,$flist) || die "Cannot open $flist:$!";
chomp(@encfiles = <FLIST>);
close(FLIST);
} else {
@encfiles = @ARGV;
}

my $cname = (exists $opt{'o'}) ? $opt{'o'} : shift(@ARGV);
my $cname = $opt{o} ? $opt{o} : shift(@ARGV);
unless ($cname) { #debuging a win32 nmake error-only. works via cmdline
print "\nARGV:";
print "$_ " for @ARGV;
print "\nopt:";
print " $_ => ",defined $opt{$_}?$opt{$_}:"undef","\n" for keys %opt;
}
chmod(0666,$cname) if -f $cname && !-w $cname;
open(C,">$cname") || die "Cannot open $cname:$!";
open(C,">", $cname) || die "Cannot open $cname:$!";

my $dname = $cname;
my $hname = $cname;
Expand All @@ -220,10 +231,10 @@ if ($cname =~ /\.(c|xs)$/i) # VMS may have upcased filenames with DECC$ARGV_PARS
$doC = 1;
$dname =~ s/(\.[^\.]*)?$/.exh/;
chmod(0666,$dname) if -f $cname && !-w $dname;
open(D,">$dname") || die "Cannot open $dname:$!";
open(D,">", $dname) || die "Cannot open $dname:$!";
$hname =~ s/(\.[^\.]*)?$/.h/;
chmod(0666,$hname) if -f $cname && !-w $hname;
open(H,">$hname") || die "Cannot open $hname:$!";
open(H,">", $hname) || die "Cannot open $hname:$!";

foreach my $fh (\*C,\*D,\*H)
{
Expand Down Expand Up @@ -469,7 +480,9 @@ sub compile_ucm
$erep = $attr{'subchar'};
$erep =~ s/^\s+//; $erep =~ s/\s+$//;
}
print "Reading $name ($cs)\n";
print "Reading $name ($cs)\n"
unless defined $ENV{MAKEFLAGS}
and $ENV{MAKEFLAGS} =~ /\b(s|silent|quiet)\b/;
my $nfb = 0;
my $hfb = 0;
while (<$fh>)
Expand Down Expand Up @@ -755,9 +768,17 @@ sub addstrings
if ($a->{'Forward'})
{
my ($cpp, $static, $sized) = compiler_info(1);
my $var = $static ? 'static const' : 'extern';
my $count = $sized ? scalar(@{$a->{'Entries'}}) : '';
print $fh "$var encpage_t $name\[$count];\n";
if ($static) {
# we cannot ask Config for d_plusplus since we can override CC=g++-6 on the cmdline
print $fh "#ifdef __cplusplus\n"; # -fpermissive since g++-6
print $fh "extern encpage_t $name\[$count];\n";
print $fh "#else\n";
print $fh "static const encpage_t $name\[$count];\n";
print $fh "#endif\n";
} else {
print $fh "extern encpage_t $name\[$count];\n";
}
}
$a->{'DoneStrings'} = 1;
foreach my $b (@{$a->{'Entries'}})
Expand Down Expand Up @@ -848,9 +869,16 @@ sub outtable
outtable($fh,$t,$bigname) unless $t->{'Done'};
}
my ($cpp, $static) = compiler_info(0);
my $var = $static ? 'static const ' : '';
print $fh "\n${var}encpage_t $name\[",
scalar(@{$a->{'Entries'}}), "] = {\n";
my $count = scalar(@{$a->{'Entries'}});
if ($static) {
print $fh "#ifdef __cplusplus\n"; # -fpermissive since g++-6
print $fh "encpage_t $name\[$count] = {\n";
print $fh "#else\n";
print $fh "static const encpage_t $name\[$count] = {\n";
print $fh "#endif\n";
} else {
print $fh "\nencpage_t $name\[$count] = {\n";
}
foreach my $b (@{$a->{'Entries'}})
{
my ($sc,$ec,$out,$t,$end,$l,$fb) = @$b;
Expand Down Expand Up @@ -1104,7 +1132,7 @@ sub _print_expand{
if ((my $d = dirname($dst)) ne '.'){
-d $d or mkdir $d, 0755 or die "mkdir $d : $!";
}
open my $out, ">$dst" or die "$!";
open my $out, ">", $dst or die "$!";
my $asis = 0;
while (<$in>){
if (/^#### END_OF_HEADER/){
Expand Down
12 changes: 9 additions & 3 deletions lib/Encode/Alias.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ sub find_alias {

sub define_alias {
while (@_) {
my ( $alias, $name ) = splice( @_, 0, 2 );
unshift( @Alias, $alias => $name ); # newer one has precedence
my $alias = shift;
my $name = shift;
unshift( @Alias, $alias => $name ) # newer one has precedence
if defined $alias;
if ( ref($alias) ) {

# clear %Alias cache to allow overrides
Expand All @@ -96,10 +98,14 @@ sub define_alias {
}
}
}
else {
elsif (defined $alias) {
DEBUG and warn "delete \$Alias\{$alias\}";
delete $Alias{$alias};
}
elsif (DEBUG) {
require Carp;
Carp::croak("undef \$alias");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion t/Aliases.t
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ define_alias( sub {
return "iso-8859-2" if $enc =~ /hebrew/i;
return "does-not-exist" if $enc =~ /arabic/i; # should then use other override alias
return "utf-8" if $enc =~ /eight/i;
return;
return "unknown";
});

print "# alias test with alias overrides\n";
Expand Down
2 changes: 1 addition & 1 deletion t/enc_data.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BEGIN {
print "1..0 # Skip: encoding pragma does not support EBCDIC platforms\n";
exit(0);
}
if ("$]" >= 5.025) {
if ($] >= 5.025 and !$Config{usecperl}) {
print "1..0 # Skip: encoding pragma not supported in Perl 5.26\n";
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion t/enc_module.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BEGIN {
print "1..0 # Skip: encoding pragma does not support EBCDIC platforms\n";
exit(0);
}
if ("$]" >= 5.025) {
if ($] >= 5.025 and !$Config{usecperl}) {
print "1..0 # Skip: encoding pragma not supported in Perl 5.26\n";
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion t/encoding.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BEGIN {
print "1..0 # Skip: encoding pragma does not support EBCDIC platforms\n";
exit(0);
}
if ("$]" >= 5.025) {
if ($] >= 5.025 and !$Config{usecperl}) {
print "1..0 # Skip: encoding pragma not supported in Perl 5.26\n";
exit(0);
}
Expand Down
Loading