From: Jarkko Hietaniemi Date: Thu, 14 Sep 2006 09:05:10 +0000 (+0300) Subject: C++ Encode X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f49b0b20ddb87c0688a1b763a535acedb2558e2a;p=p5sagit%2Fp5-mst-13.2.git C++ Encode Message-ID: <4508F116.40606@iki.fi> p4raw-id: //depot/perl@28846 --- diff --git a/ext/Encode/bin/enc2xs b/ext/Encode/bin/enc2xs index 7c447be..8a85ca0 100644 --- a/ext/Encode/bin/enc2xs +++ b/ext/Encode/bin/enc2xs @@ -8,8 +8,9 @@ BEGIN { 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 @@ -176,6 +177,7 @@ if ($cname =~ /\.(c|xs)$/i) # VMS may have upcased filenames with DECC$ARGV_PARS !!!!!!! DO NOT EDIT THIS FILE !!!!!!! This file was autogenerated by: $^X $0 @orig_ARGV + enc2xs VERSION $VERSION */ END } @@ -687,8 +689,10 @@ sub addstrings } 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'}}) @@ -751,7 +755,9 @@ sub outbigstring } $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; @@ -776,7 +782,10 @@ sub outtable 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'}}) {