use strict;
use warnings;
use Getopt::Std;
+use Config;
my @orig_ARGV = @ARGV;
-our $VERSION = do { my @r = (q$Revision: 2.4 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 2.5 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
# These may get re-ordered.
# RAW is a do_now as inserted by &enter
!!!!!!! DO NOT EDIT THIS FILE !!!!!!!
This file was autogenerated by:
$^X $0 @orig_ARGV
+ enc2xs VERSION $VERSION
*/
END
}
# push(@{$encoding{$name}},outstring(\*C,$e2u->{Cname}.'_def',$erep));
}
+ my $cpp = ($Config{d_cplusplus} || '') eq 'define';
+ my $ext_c = $cpp ? 'extern "C" ' : "";
foreach my $enc (sort cmp_name keys %encoding)
{
# my ($e2u,$u2e,$rep,$min_el,$max_el,$rsym) = @{$encoding{$enc}};
$sym =~ s/\W+/_/g;
my @info = ($e2u->{Cname},$u2e->{Cname},"${sym}_rep_character",$replen,
$min_el,$max_el);
- print C "static const U8 ${sym}_rep_character[] = \"$rep\";\n";
- print C "static const char ${sym}_enc_name[] = \"$enc\";\n\n";
- print C "const encode_t $sym = \n";
+ print C "${ext_c}static const U8 ${sym}_rep_character[] = \"$rep\";\n";
+ print C "${ext_c}static const char ${sym}_enc_name[] = \"$enc\";\n\n";
+ print C "${ext_c}const encode_t $sym = \n";
# This is to make null encoding work -- dankogai
for (my $i = (scalar @info) - 1; $i >= 0; --$i){
$info[$i] ||= 1;
}
if ($a->{'Forward'})
{
- my $var = $^O eq 'MacOS' ? 'extern' : 'static';
- print $fh "$var const encpage_t $name\[",scalar(@{$a->{'Entries'}}),"];\n";
+ my $cpp = ($Config{d_cplusplus} || '') eq 'define';
+ my $var = $^O eq 'MacOS' || $cpp ? 'extern' : 'static';
+ my $const = $cpp ? '' : 'const';
+ print $fh "$var $const encpage_t $name\[",scalar(@{$a->{'Entries'}}),"];\n";
}
$a->{'DoneStrings'} = 1;
foreach my $b (@{$a->{'Entries'}})
}
$strings = length $string_acc;
- my $definition = "\nstatic const U8 $name\[$strings] = { " .
+ my $cpp = ($Config{d_cplusplus} || '') eq 'define';
+ my $var = $cpp ? '' : 'static';
+ my $definition = "\n$var const U8 $name\[$strings] = { " .
join(',',unpack "C*",$string_acc);
# We have a single long line. Split it at convenient commas.
print $fh $1, "\n" while $definition =~ /\G(.{74,77},)/gcs;
my ($s,$e,$out,$t,$end,$l) = @$b;
outtable($fh,$t,$bigname) unless $t->{'Done'};
}
- print $fh "\nstatic const encpage_t $name\[",
+ my $cpp = ($Config{d_cplusplus} || '') eq 'define';
+ my $var = $cpp ? '' : 'static';
+ my $const = $cpp ? '' : 'const';
+ print $fh "\n$var $const encpage_t $name\[",
scalar(@{$a->{'Entries'}}), "] = {\n";
foreach my $b (@{$a->{'Entries'}})
{
mappings. This format is used by IBM's ICU package and was adopted
by Nick Ing-Simmons for use with the Encode module. Since UCM is
more flexible than Tcl's Encoding Map and far more user-friendly,
-this is the recommended formet for Encode now.
+this is the recommended format for Encode now.
A UCM file looks like this.