This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
C++ Encode
[perl5.git] / ext / Encode / bin / enc2xs
index 7c447be..8a85ca0 100644 (file)
@@ -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'}})
   {