SEE ALSO

MarpaX::ESLIF::BNF, MarpaX::ESLIF::Tutorial::Calculator, PCRE2, jpcre2.

NOTES

The perl interface is using an all-in-one version of the underlying marpaESLIF C library. This mean that character conversion relies on libiconv to do character translation if needed. TRAILER

close(INTRO) || warn "Cannot close $dst, $!";

exit(EXIT_SUCCESS);

# # Well, I have a problem on Windows because path is greater than MAX_PATH...! # This private implementation of _dircopy is doing the job... # Even if I would use Win32::LongPath, dzil would fail afterwards -; # sub _dircopy { my ($srcdir, $dstdir, @parents) = @_;

  if (! -d $srcdir) {
      die "$srcdir is not a directory";
  }
  if (! -d $dstdir) {
      print "... Creating directory $dstdir\n";
      my ($volume, $directories, $file) = File::Spec->splitpath($dstdir, 1);
      my $newdir = undef;
      foreach (File::Spec->splitdir($directories)) {
        $newdir = $newdir ? File::Spec->catdir($newdir, $_) : $_;
        next if -d $newdir;
        die "Failed to create $newdir directory, $!" unless mkdir $newdir;
      }
  }

  my $workdir = cwd;

  my $basedir = basename($srcdir);
  my $reducedLength = 0;

  my $stats = _readdir($srcdir);
  foreach (sort keys %{$stats}) {
      next if $_ eq $updir;
      next if $_ eq $curdir;

      my $mode = $stats->{$_}->[2];

      #
      # Copy only the version of pcre2 we use
      #
      if (@parents && $parents[-1] eq 'untar') {
        next if S_ISDIR($mode) && ($_ =~ /^pcre2/) && ($_ ne 'pcre2-10.40');
      }
      #
      # Skip historical Marpa--R2 checkout from marpaWrapper
      #
      next if $_ eq 'Marpa--R2';
      #
      # Copy only the version of iconv we use
      #
      next if ($_ =~ /^libiconv/ && $_ ne 'libiconv-1.16.tar.gz');
      #
      # Do not copy known garbage
      #
      next if $_ eq 'latest';
      next if $_ eq '.build';
      next if $_ eq 'cmake_install.cmake';
      next if $_ eq 'Makefile';
      next if $_ eq 'CMakeFiles';
      next if $_ eq 'output';
      next if $_ eq 'CTestTestfile.cmake';
      next if $_ eq '.gitignore';
      next if $_ eq '.gitattributes';
      #
      # Do not copy known stuff we can skip
      #
      next if $_ eq 'Makefile';
      next if $_ =~ /\bcmake\b/;
      next if $_ eq 'cmake-utils';
      next if $_ eq 'test';
      next if $_ eq 'blog';
      next if $_ eq 't';
      next if $_ eq 'html';
      next if $_ eq 'inc';
      next if $_ eq 'lib';
      next if $_ eq 'm4';
      next if $_ eq 'pod';
      next if $_ eq 'etc';
      next if $_ eq 'xs';
      next if $_ eq 'author.t';
      next if $_ eq '.travis.yml';
      next if $_ eq 'visual-studio';
      next if $_ =~ /\..?sh$/;
      next if $_ =~ /\.3$/;
      next if $_ =~ /\.3\.gz$/;
      next if $_ =~ /\.o(?:bj)?$/;
      next if $_ =~ /\.pdb$/;
      next if $_ =~ /\.tlog$/;
      next if $_ =~ /\.vcxproj$/;
      next if $_ =~ /\.vcxproj\.filters$/;
      next if $_ =~ /\.vcxproj\.user$/;
      next if $_ =~ /\.opensdf$/;
      next if $_ =~ /\.sln$/;
      next if $_ =~ /\.suo$/;
      next if $_ =~ /\.sdf$/;
      next if $_ =~ /\.dir$/;
      next if $_ =~ /\.psess$/;
      next if $_ =~ /\.vsp$/;
      next if $_ =~ /^MarpaX\-ESLIF/;
      next if $_ eq 'Testing';
      next if $_ eq 'Win32';
      next if $_ eq 'ipch';
      next if $_ eq 'CMake-codecov';
      next if $_ eq 'testdata';
      next if $_ =~ /\.tar\.orig\.gz$/;
      next if $_ eq 'doc';
      if ($_ eq 'tar') {
        #
        # We skip only 'tar' directory of marpaESLIF
        #
        next unless @parents;
      }
      next if $_ =~ /~$/;

      if (S_ISDIR($mode)) {
          _dircopy(File::Spec->catdir($srcdir, $_), File::Spec->catdir($dstdir, $_), $_, @parents);
      } else {
          my $file = File::Spec->catfile($srcdir, $_);
          print "... Copying file $file to $dstdir\n";
          _copy($srcdir, $dstdir, $_);
      }
  }
}

sub _chdir { my ($dir) = @_;

my ($volume, $directories, $file) = File::Spec->splitpath($dir, 1);
my @dirs = File::Spec->splitdir($directories);
my @donedirs = ();
my $donedirs = '';
foreach (@dirs) {
    push(@donedirs, $_);
    $donedirs = File::Spec->catdir(@donedirs);
    chdir($_) || die "Cannot chdir to $donedirs, $!";
}
}

sub _readdir { my ($dir) = @_;

my $workdir = cwd;

_chdir($dir);

my $dh;
opendir($dh, $curdir) || die "Failed to opendir $dir, $!";
my %stats = ();
while (readdir($dh)) {
    my @stat = stat($_);
    if (! @stat) {
        warn "Failed to stat entry in $dir: $_";
    } else {
        $stats{$_} = \@stat;
    }
}
closedir($dh) || warn "Failed to closedir $dir, $!";

chdir($workdir) || die "Failed to chdir to $workdir, $!";
return \%stats;
}

sub _copy { my ($srcdir, $dstdir, $entry) = @_;

my $srcfile = File::Spec->catfile($srcdir, $entry);
my $dstfile = File::Spec->catfile($dstdir, $entry);

#
# All files I copy are short -;
#
my $workdir = cwd;
_chdir($srcdir);
open(my $in, '<', $entry) || die "Cannot open $srcfile, $!";
binmode($in) || die "Failed to set binary mode on $srcfile, $!";

chdir($workdir) || die "Failed to chdir to $workdir, $!";
_chdir($dstdir);

open(my $out, '>', $entry) || die "Cannot open $dstfile, $!";
binmode($out) || die "Failed to set binary mode on $dstfile, $!";
chdir($workdir) || die "Failed to chdir to $workdir, $!";

#
#
my $data = do { local $/; <$in> };
print $out $data;
close($in) || warn "Failed to close $srcfile, $!";
close($out) || warn "Failed to close $dstfile, $!";
}