From 62157b69bc72cb000e9b5e1b6b76b70685cd5cec Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 16 Dec 2009 01:00:39 +0000 Subject: .pl for latexrevise and latexdiff-vc git-svn-id: svn://tug.org/texlive/trunk@16420 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/texlive/linked_scripts/ChangeLog | 5 + .../source/texk/texlive/linked_scripts/Makefile.am | 4 +- .../source/texk/texlive/linked_scripts/Makefile.in | 4 +- .../texlive/linked_scripts/latexdiff/latexdiff-vc | 430 ----------------- .../linked_scripts/latexdiff/latexdiff-vc.pl | 430 +++++++++++++++++ .../texlive/linked_scripts/latexdiff/latexrevise | 523 --------------------- .../linked_scripts/latexdiff/latexrevise.pl | 523 +++++++++++++++++++++ Master/bin/alpha-linux/latexdiff-vc | 2 +- Master/bin/alpha-linux/latexrevise | 2 +- Master/bin/i386-cygwin/latexdiff-vc | 2 +- Master/bin/i386-cygwin/latexrevise | 2 +- Master/bin/i386-linux/latexdiff-vc | 2 +- Master/bin/i386-linux/latexrevise | 2 +- Master/bin/i386-netbsd/latexdiff-vc | 2 +- Master/bin/i386-netbsd/latexrevise | 2 +- Master/bin/i386-solaris/latexdiff-vc | 2 +- Master/bin/i386-solaris/latexrevise | 2 +- Master/bin/mips-irix/latexdiff-vc | 2 +- Master/bin/mips-irix/latexrevise | 2 +- Master/bin/powerpc-aix/latexdiff-vc | 2 +- Master/bin/powerpc-aix/latexrevise | 2 +- Master/bin/powerpc-linux/latexdiff-vc | 2 +- Master/bin/powerpc-linux/latexrevise | 2 +- Master/bin/sparc-linux/latexdiff-vc | 2 +- Master/bin/sparc-linux/latexrevise | 2 +- Master/bin/sparc-solaris/latexdiff-vc | 2 +- Master/bin/sparc-solaris/latexrevise | 2 +- Master/bin/universal-darwin/latexdiff-vc | 2 +- Master/bin/universal-darwin/latexrevise | 2 +- Master/bin/x86_64-linux/latexdiff-vc | 2 +- Master/bin/x86_64-linux/latexrevise | 2 +- Master/texmf-dist/scripts/latexdiff/latexdiff-vc | 430 ----------------- .../texmf-dist/scripts/latexdiff/latexdiff-vc.pl | 430 +++++++++++++++++ Master/texmf-dist/scripts/latexdiff/latexrevise | 523 --------------------- Master/texmf-dist/scripts/latexdiff/latexrevise.pl | 523 +++++++++++++++++++++ Master/tlpkg/libexec/ctan2tds | 2 + 36 files changed, 1941 insertions(+), 1934 deletions(-) delete mode 100755 Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc create mode 100755 Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc.pl delete mode 100755 Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise create mode 100755 Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise.pl delete mode 100755 Master/texmf-dist/scripts/latexdiff/latexdiff-vc create mode 100755 Master/texmf-dist/scripts/latexdiff/latexdiff-vc.pl delete mode 100755 Master/texmf-dist/scripts/latexdiff/latexrevise create mode 100755 Master/texmf-dist/scripts/latexdiff/latexrevise.pl diff --git a/Build/source/texk/texlive/linked_scripts/ChangeLog b/Build/source/texk/texlive/linked_scripts/ChangeLog index bf0336f491f..1e38c2f54f2 100644 --- a/Build/source/texk/texlive/linked_scripts/ChangeLog +++ b/Build/source/texk/texlive/linked_scripts/ChangeLog @@ -1,3 +1,8 @@ +2009-12-16 Karl Berry + + * Makefile.am (nobase_dist_script_SCRIPTS): .pl for latexrevise + and latexdiff-vc. + 2009-11-28 Karl Berry * Makefile.am (nobase_dist_script_SCRIPTS): add bibexport.sh. diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am index a64a07b55a3..f9209cdb0aa 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.am +++ b/Build/source/texk/texlive/linked_scripts/Makefile.am @@ -67,8 +67,8 @@ nobase_dist_script_SCRIPTS = \ glossaries/makeglossaries \ latex2man/latex2man \ latexdiff/latexdiff.pl \ - latexdiff/latexdiff-vc \ - latexdiff/latexrevise \ + latexdiff/latexdiff-vc.pl \ + latexdiff/latexrevise.pl \ latexmk/latexmk.pl \ listings-ext/listings-ext.sh \ mkjobtexmf/mkjobtexmf.pl \ diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in index 469e68599d5..4b62823180a 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.in +++ b/Build/source/texk/texlive/linked_scripts/Makefile.in @@ -216,8 +216,8 @@ nobase_dist_script_SCRIPTS = \ glossaries/makeglossaries \ latex2man/latex2man \ latexdiff/latexdiff.pl \ - latexdiff/latexdiff-vc \ - latexdiff/latexrevise \ + latexdiff/latexdiff-vc.pl \ + latexdiff/latexrevise.pl \ latexmk/latexmk.pl \ listings-ext/listings-ext.sh \ mkjobtexmf/mkjobtexmf.pl \ diff --git a/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc b/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc deleted file mode 100755 index 3e9a3f246de..00000000000 --- a/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc +++ /dev/null @@ -1,430 +0,0 @@ -#!/usr/bin/perl -w -# Place the following 2 lines at beginning to make script independent of location of perl -#eval 'exec perl -w -S $0 ${1+"$@"}' -# if 0; # not running under some shell -# -# latexdiff-vc - wrapper script for applying latexdiff to rcs managed files -# and for automatised creation of postscript or pdf from difference file -# -# Copyright (C) 2005 F J Tilmann (tilmann@esc.cam.ac.uk) -# -# Contributors: S Utcke, H Bruyninckx -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License Version 2 as published by -# the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Detailed usage information at the end of the file -# -# version 0.25: -# - bbl is allowed as alternative extension (instead of .tex) -# -use Getopt::Long ; -use Pod::Usage qw/pod2usage/ ; -use File::Temp qw/tempdir/ ; -use File::Basename qw/dirname/; -use strict ; - -# Option names -my ($version,$help,$postscript,$pdf,$force,$dir,$cvs,$rcs,$svn,$diffcmd,$patchcmd,@revs); -# Preset Variables -my $latexdiff="latexdiff"; # Program for making the comparison -my $vc=""; -my $tempdir=tempdir(CLEANUP => 1); -# Variables -my ($file1,$file2,$diff,$diffbase,$answer,$options,$infile,$append,$dirname,$cwd); -my (@files,@ldoptions,@tmpfiles,@ptmpfiles,@difffiles); # , - - -Getopt::Long::Configure('pass_through','bundling'); - -GetOptions('revision|r:s' => \@revs, - 'cvs' => \$cvs, - 'rcs' => \$rcs, - 'svn' => \$svn, - 'dir|d:s' => \$dir, - 'postscript|ps' => \$postscript, - 'pdf' => \$pdf, - 'force' => \$force, - 'version' => \$version, - 'help|h' => \$help); - -if ( $help ) { - pod2usage(1) ; -} - -if ( $version ) { - die "This is LATEXDIFF-VC 0.25\n" ; -} - -if ( $cvs ) { - $vc="CVS"; -} -if ( $rcs ) { - die "Cannot specify more than one of --cvs, --rcs or --svn." if ($vc); - $vc="RCS"; -} -if ( $svn ) { - die "Cannot specify more than one of --cvs, --rcs or --svn." if ($vc); - $vc="SVN"; -} - -# check whether the first file name got misinterpreted as an option to an empty -r option -if ( @revs && -f $revs[$#revs] ) { - unshift @ARGV,$revs[$#revs]; - $revs[$#revs]=""; -} -# check whether the first file name got misinterpreted as an option to an empty -d option -if ( defined($dir) && -f $dir ) { - unshift @ARGV,$dir; - $dir=""; -} - -$file2=pop @ARGV; -( defined($file2) && $file2 =~ /\.(tex|bbl)$/ ) or pod2usage("Must specify at least one tex or bbl file"); - -if (! $vc && scalar(@revs)>0 ) { - # have to guess $vc - # check whether we have a special name - if ( $0 =~ /-cvs$/ ) { - $vc="CVS"; - } elsif ( $0 =~ /-rcs$/ ) { - $vc="RCS"; - } elsif ( $0 =~ /-svn$/ ) { - $vc="SVN"; - } elsif ( -e "CVSROOT" || defined($ENV{"CVSROOT"}) ) { - print STDERR "Guess you are using CVS ...\n"; - $vc="CVS"; - } elsif ( -e "$file2,v" ) { - print STDERR "Guess you are using RCS ...\n"; - $vc="RCS"; - } elsif ( -d ".svn" ) { - print STDERR "Guess you are using SVN ...\n"; - $vc="SVN"; - } else { - print STDERR "Cannot figure out version control system, so I default to CVS\n"; - $vc="CVS"; - } -} - -if (defined($dir) && $dir=~/^\.\/?/ ) { - print STDERR "You wrote selected -dir=. but you do not really like to do that, do you ?\n"; - exit 10 -} - -if ( scalar(@revs)>0 ) { - if ( $vc eq "CVS" ) { - $diffcmd = "cvs diff -u -r"; - $patchcmd = "patch -R -p0"; - } elsif ( $vc eq "RCS" ) { - $diffcmd = "rcsdiff -u -r"; - $patchcmd = "patch -R -p0"; - } elsif ( $vc eq "SVN" ) { - $diffcmd = "svn diff -r "; - $patchcmd = "patch -R -p0"; - } else { - print STDERR "Unknown versioning system $vc \n"; - exit 10; - } -} - - -# make file list (last arguments), initial arguments have to be passed to latexdiff -# We assume an argument is a valid file rather than a latexdiff argument -# if it has extension .tex or .bbl - -@files=($file2); -while( $file1=pop @ARGV ) { - if ( $file1 =~ /\.(tex|bbl)$/ ) { - # $file1 looks like a valid file name and is prepended to file list - unshift @files, $file1 ; - } else { - # $file1 looks like an option for latexdiff, push it back to argument stack - unshift @ldoptions, $file1 ; - } -} - -if ( scalar(@revs) == 0 ) { - pod2usage("When -r option is not used, two .tex files (old and new) must be given on the command line") unless @files==2; - # compare two files - $file1=shift @files ; -} - -if ( scalar(@revs) == 2 ) { - $append = "-diff$revs[0]-$revs[1]"; -} elsif ( scalar(@revs) == 1 || $revs[0] ) { - $append = "-diff$revs[0]"; -} else { - $append = "-diff"; -} - -if ( defined ($dir) && ! $dir ) { - # bare -d option => choose directory name - ($dir=$append) =~ s/^-//; -} - -if ( ($vc eq "SVN" || $vc eq "CVS") && scalar(@revs)) { - length($revs[$#revs]) > 0 or $revs[$#revs]="HEAD"; - length($revs[0]) > 0 or $revs[0]="HEAD"; -} - -#exit ; - - -# cycle through all files - -@difffiles=(); -while ( $infile=$file2=shift @files ) { - print STDERR "Working on $infile \n"; - if ( scalar(@revs) == 1 ) { - ($file1=$infile) =~ s/\.(tex|bbl)/-oldtmp-$$.$1/ ; - push @tmpfiles,$file1; - # compare file with previous version ($revs[0]="") or specified version - system("$diffcmd$revs[0] $infile| $patchcmd -o$file1") ; - } elsif ( scalar(@revs) == 2 ) { - ($file1=$infile) =~ s/\.(tex|bbl)/-oldtmp-$$.$1/ ; - $file2 =~ s/\.(tex|bbl)/-newtmp-$$.$1/ ; - push @tmpfiles,$file2; - system("$diffcmd$revs[1] $infile | $patchcmd -o$file2") ; - system("$diffcmd$revs[0] $infile | $patchcmd -o$file1") ; - } - - if ( -z $file1 || -z $file2) { - print STDERR "One or both of the files to compare are empty. Possibly something went wrong in the retrieval of older versions. Aborting ...\n" ; - exit(10); - } - - # Get name of difference file - if ( defined($dir) ) { - $diff="$dir/$infile" ; - } else { - ($diff=$infile) =~ s/\.(tex|bbl)$/$append.$1/ ; - } - # make directories if needed - $dirname=dirname($diff) ; - system("mkdir -p $dirname") unless ( -e $dirname ); - - # Remaining options are passed to latexdiff - $options = join(" ",@ldoptions); - - if ( -e $diff && ! $force ) { - print STDERR "OK to overwrite existing file $diff (y/n)? "; - $answer = ; - unless ($answer =~ /^y/i ) { - unlink @tmpfiles; - die "Abort ... " ; - } - } - print "Running $latexdiff\n"; - unless ( system("$latexdiff $options $file1 $file2 > $diff") == 0 ) { - print STDERR "Something went wrong in $latexdiff. Deleting $diff and abort\n" ; unlink $diff ; exit(5) - }; - print "Generated difference file $diff\n"; - - if ( ( $postscript or $pdf ) and !( scalar(@revs) && greptex( qr/\\document(?:class|style)/ , $diff ) ) ) { - # save filename for later processing if postscript or pdf conversion is requested and either two-file mode was used (scalar(@revs)==0) or the diff file contains documentclass statement (ie. is a root document) - push @difffiles, $diff ; - } - - unlink @tmpfiles; -} - -foreach $diff ( @difffiles ) { - chomp($cwd=(`pwd`)); - if (defined($dir)) { - ( $diff =~ s/$dir\/?// ) ; - chdir $dir ; - } - @ptmpfiles=(); - ( $diffbase=$diff) =~ s/\.(tex)$// ; - - # adapt magically changebar styles to [pdftex] display driver if pdf output was selected - if ( $pdf ) { - system("sed \"s/Package\\[dvips\\]/Package[pdftex]/\" $diff > $diff.tmp$$ ; \\mv $diff.tmp$$ $diff"); - } - print STDERR "PDF: $pdf Postscript: $postscript cwd $cwd\n"; - - if ( system("grep -q \'^[^%]*\\\\bibliography\' $diff") == 0 ) { - if ( $postscript) { - system("latex --interaction=batchmode $diff; bibtex $diffbase"); - push @ptmpfiles, "$diffbase.bbl","$diffbase.bbl" ; - } elsif ( $pdf ) { - system("pdflatex --interaction=batchmode $diff; bibtex $diffbase"); - push @ptmpfiles, "$diffbase.bbl","$diffbase.bbl" ; - } - } - - if ( $postscript ) { - my $dvi="$diffbase.dvi"; - my $ps="$diffbase.ps"; - - system("latex --interaction=batchmode $diff; latex $diff; dvips -o $ps $dvi"); - push @ptmpfiles, "$diffbase.aux","$diffbase.log",$dvi ; - print "Generated postscript file $ps\n"; - } - elsif ( $pdf ) { - system("pdflatex --interaction=batchmode $diff; pdflatex $diff"); - push @ptmpfiles, "$diffbase.aux","$diffbase.log"; - } - unlink @ptmpfiles; - chdir $cwd; -} - -# greptex returns 1 if regex is not matched in filename -# 0 if there is a match -sub greptex { - my ($regex,$filename)=@_; - my ($i)=0; - open (FH, $filename) or die("Couldn't open $filename: $!"); - while () { - next if /^\s*%/; # skip comment lines - if ( m/$regex/ ) { - close(FH); - return(0); - } - # only scan 25 lines - $i++; - last if $i>25 ; - } - close(FH); - return(1); -} - - -=head1 NAME - -latexdiff-vc - wrapper script that calls latexdiff for different versions of a file under version management (CVS, RCS or SVN) - -=head1 SYNOPSIS - -B [ F ] [ F ] B<-r> [F] [B<-r> F] F [ F ...] - - or - -B [ F ] [ F ][ B<--postscript> | B<--pdf> ] F F - -=head1 DESCRIPTION - -I is a wrapper script that applies I to a -file, or multiple files under version control (CVS or RCS), and optionally runs the -sequence of C and C or C commands necessary to -produce pdf or postscript output of the difference tex file(s). It can -also be applied to a pair of files to automatise the generation of difference -file in postscript or pdf format. - -=head1 OPTIONS - -=over 4 - -=item B<--rcs>, B<--svn>, or B<--cvs> - -Set the version system. -If no version system is specified, latexdiff-vc will venture a guess. - -latexdiff-cvs and latexdiff-rcs are variants of latexdiff-vc which default to -the respective versioning system. However, this default can still be overridden using the options above. - -=item B<-r>, B<-r> F or B<--revision>, B<--revision=>F - -Choose revision (under RCS, CVS or SVN). One or two B<-r> options can be -specified, and the resulting in different behaviour: - -=over 4 - -=item B -r F ... - -compares F with the most recent version checked into RCS. - -=item B -r F F ... - -compares F with revision F. - -=item B -r F -r F F ... - -compares revisions F and F of F. - -Multiple files can be specified for all of the above options. All files must have the -extension C<.tex>, though. - -=item B F F - -compares two files. - -=back - -The name of the difference file is generated automatically and -reported to stdout. - -=item B<-d> or B<--dir> B<-d> F or B<--dir=>F - -Rather than appending the string C and optionally the version -numbers given to the output-file, this will prepend a directory name C -to the -original filename, creating the directory and subdirectories should they not exist already. This is particularly useful in order to clone a -complete directory hierarchy. Optionally, a pathname F can be specified, which is prepended instead of C. - -=item B<--ps> or B<--postscript> - -Generate postscript output from difference file. This will run the -sequence C on the difference file (do not use -this option in the rare cases, where three C commands are -required if you care about correct referencing). If the difference -file contains a C<\bibliography> tag, run the sequence C. - -=item B<--pdf> - -Generate pdf output from difference file using C. This will -run the sequence C on the difference file, or -C for files requiring bibtex. - -=item B<--force> - -Overwrite existing diff files without asking for confirmation. Default -behaviour is to ask for confirmation before overwriting an existing difference -file. - -=item B<--help> or -B<-h> - -Show help text - -=item B<--version> - -Show version number - -=back - -All other options are passed on to C. - -=head1 SEE ALSO - -L - -=head1 PORTABILITY - -I uses external commands and is therefore -limited to Unix-like systems. It also requires the RCS version control -system and latex to be installed on the system. Modules from Perl 5.8 -or higher are required. - - -=head1 AUTHOR - -Copyright (C) 2005 Frederik Tilmann - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License Version 2 -Contributors: S Utcke, H Bruyninckx - -=cut - diff --git a/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc.pl b/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc.pl new file mode 100755 index 00000000000..3e9a3f246de --- /dev/null +++ b/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc.pl @@ -0,0 +1,430 @@ +#!/usr/bin/perl -w +# Place the following 2 lines at beginning to make script independent of location of perl +#eval 'exec perl -w -S $0 ${1+"$@"}' +# if 0; # not running under some shell +# +# latexdiff-vc - wrapper script for applying latexdiff to rcs managed files +# and for automatised creation of postscript or pdf from difference file +# +# Copyright (C) 2005 F J Tilmann (tilmann@esc.cam.ac.uk) +# +# Contributors: S Utcke, H Bruyninckx +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License Version 2 as published by +# the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Detailed usage information at the end of the file +# +# version 0.25: +# - bbl is allowed as alternative extension (instead of .tex) +# +use Getopt::Long ; +use Pod::Usage qw/pod2usage/ ; +use File::Temp qw/tempdir/ ; +use File::Basename qw/dirname/; +use strict ; + +# Option names +my ($version,$help,$postscript,$pdf,$force,$dir,$cvs,$rcs,$svn,$diffcmd,$patchcmd,@revs); +# Preset Variables +my $latexdiff="latexdiff"; # Program for making the comparison +my $vc=""; +my $tempdir=tempdir(CLEANUP => 1); +# Variables +my ($file1,$file2,$diff,$diffbase,$answer,$options,$infile,$append,$dirname,$cwd); +my (@files,@ldoptions,@tmpfiles,@ptmpfiles,@difffiles); # , + + +Getopt::Long::Configure('pass_through','bundling'); + +GetOptions('revision|r:s' => \@revs, + 'cvs' => \$cvs, + 'rcs' => \$rcs, + 'svn' => \$svn, + 'dir|d:s' => \$dir, + 'postscript|ps' => \$postscript, + 'pdf' => \$pdf, + 'force' => \$force, + 'version' => \$version, + 'help|h' => \$help); + +if ( $help ) { + pod2usage(1) ; +} + +if ( $version ) { + die "This is LATEXDIFF-VC 0.25\n" ; +} + +if ( $cvs ) { + $vc="CVS"; +} +if ( $rcs ) { + die "Cannot specify more than one of --cvs, --rcs or --svn." if ($vc); + $vc="RCS"; +} +if ( $svn ) { + die "Cannot specify more than one of --cvs, --rcs or --svn." if ($vc); + $vc="SVN"; +} + +# check whether the first file name got misinterpreted as an option to an empty -r option +if ( @revs && -f $revs[$#revs] ) { + unshift @ARGV,$revs[$#revs]; + $revs[$#revs]=""; +} +# check whether the first file name got misinterpreted as an option to an empty -d option +if ( defined($dir) && -f $dir ) { + unshift @ARGV,$dir; + $dir=""; +} + +$file2=pop @ARGV; +( defined($file2) && $file2 =~ /\.(tex|bbl)$/ ) or pod2usage("Must specify at least one tex or bbl file"); + +if (! $vc && scalar(@revs)>0 ) { + # have to guess $vc + # check whether we have a special name + if ( $0 =~ /-cvs$/ ) { + $vc="CVS"; + } elsif ( $0 =~ /-rcs$/ ) { + $vc="RCS"; + } elsif ( $0 =~ /-svn$/ ) { + $vc="SVN"; + } elsif ( -e "CVSROOT" || defined($ENV{"CVSROOT"}) ) { + print STDERR "Guess you are using CVS ...\n"; + $vc="CVS"; + } elsif ( -e "$file2,v" ) { + print STDERR "Guess you are using RCS ...\n"; + $vc="RCS"; + } elsif ( -d ".svn" ) { + print STDERR "Guess you are using SVN ...\n"; + $vc="SVN"; + } else { + print STDERR "Cannot figure out version control system, so I default to CVS\n"; + $vc="CVS"; + } +} + +if (defined($dir) && $dir=~/^\.\/?/ ) { + print STDERR "You wrote selected -dir=. but you do not really like to do that, do you ?\n"; + exit 10 +} + +if ( scalar(@revs)>0 ) { + if ( $vc eq "CVS" ) { + $diffcmd = "cvs diff -u -r"; + $patchcmd = "patch -R -p0"; + } elsif ( $vc eq "RCS" ) { + $diffcmd = "rcsdiff -u -r"; + $patchcmd = "patch -R -p0"; + } elsif ( $vc eq "SVN" ) { + $diffcmd = "svn diff -r "; + $patchcmd = "patch -R -p0"; + } else { + print STDERR "Unknown versioning system $vc \n"; + exit 10; + } +} + + +# make file list (last arguments), initial arguments have to be passed to latexdiff +# We assume an argument is a valid file rather than a latexdiff argument +# if it has extension .tex or .bbl + +@files=($file2); +while( $file1=pop @ARGV ) { + if ( $file1 =~ /\.(tex|bbl)$/ ) { + # $file1 looks like a valid file name and is prepended to file list + unshift @files, $file1 ; + } else { + # $file1 looks like an option for latexdiff, push it back to argument stack + unshift @ldoptions, $file1 ; + } +} + +if ( scalar(@revs) == 0 ) { + pod2usage("When -r option is not used, two .tex files (old and new) must be given on the command line") unless @files==2; + # compare two files + $file1=shift @files ; +} + +if ( scalar(@revs) == 2 ) { + $append = "-diff$revs[0]-$revs[1]"; +} elsif ( scalar(@revs) == 1 || $revs[0] ) { + $append = "-diff$revs[0]"; +} else { + $append = "-diff"; +} + +if ( defined ($dir) && ! $dir ) { + # bare -d option => choose directory name + ($dir=$append) =~ s/^-//; +} + +if ( ($vc eq "SVN" || $vc eq "CVS") && scalar(@revs)) { + length($revs[$#revs]) > 0 or $revs[$#revs]="HEAD"; + length($revs[0]) > 0 or $revs[0]="HEAD"; +} + +#exit ; + + +# cycle through all files + +@difffiles=(); +while ( $infile=$file2=shift @files ) { + print STDERR "Working on $infile \n"; + if ( scalar(@revs) == 1 ) { + ($file1=$infile) =~ s/\.(tex|bbl)/-oldtmp-$$.$1/ ; + push @tmpfiles,$file1; + # compare file with previous version ($revs[0]="") or specified version + system("$diffcmd$revs[0] $infile| $patchcmd -o$file1") ; + } elsif ( scalar(@revs) == 2 ) { + ($file1=$infile) =~ s/\.(tex|bbl)/-oldtmp-$$.$1/ ; + $file2 =~ s/\.(tex|bbl)/-newtmp-$$.$1/ ; + push @tmpfiles,$file2; + system("$diffcmd$revs[1] $infile | $patchcmd -o$file2") ; + system("$diffcmd$revs[0] $infile | $patchcmd -o$file1") ; + } + + if ( -z $file1 || -z $file2) { + print STDERR "One or both of the files to compare are empty. Possibly something went wrong in the retrieval of older versions. Aborting ...\n" ; + exit(10); + } + + # Get name of difference file + if ( defined($dir) ) { + $diff="$dir/$infile" ; + } else { + ($diff=$infile) =~ s/\.(tex|bbl)$/$append.$1/ ; + } + # make directories if needed + $dirname=dirname($diff) ; + system("mkdir -p $dirname") unless ( -e $dirname ); + + # Remaining options are passed to latexdiff + $options = join(" ",@ldoptions); + + if ( -e $diff && ! $force ) { + print STDERR "OK to overwrite existing file $diff (y/n)? "; + $answer = ; + unless ($answer =~ /^y/i ) { + unlink @tmpfiles; + die "Abort ... " ; + } + } + print "Running $latexdiff\n"; + unless ( system("$latexdiff $options $file1 $file2 > $diff") == 0 ) { + print STDERR "Something went wrong in $latexdiff. Deleting $diff and abort\n" ; unlink $diff ; exit(5) + }; + print "Generated difference file $diff\n"; + + if ( ( $postscript or $pdf ) and !( scalar(@revs) && greptex( qr/\\document(?:class|style)/ , $diff ) ) ) { + # save filename for later processing if postscript or pdf conversion is requested and either two-file mode was used (scalar(@revs)==0) or the diff file contains documentclass statement (ie. is a root document) + push @difffiles, $diff ; + } + + unlink @tmpfiles; +} + +foreach $diff ( @difffiles ) { + chomp($cwd=(`pwd`)); + if (defined($dir)) { + ( $diff =~ s/$dir\/?// ) ; + chdir $dir ; + } + @ptmpfiles=(); + ( $diffbase=$diff) =~ s/\.(tex)$// ; + + # adapt magically changebar styles to [pdftex] display driver if pdf output was selected + if ( $pdf ) { + system("sed \"s/Package\\[dvips\\]/Package[pdftex]/\" $diff > $diff.tmp$$ ; \\mv $diff.tmp$$ $diff"); + } + print STDERR "PDF: $pdf Postscript: $postscript cwd $cwd\n"; + + if ( system("grep -q \'^[^%]*\\\\bibliography\' $diff") == 0 ) { + if ( $postscript) { + system("latex --interaction=batchmode $diff; bibtex $diffbase"); + push @ptmpfiles, "$diffbase.bbl","$diffbase.bbl" ; + } elsif ( $pdf ) { + system("pdflatex --interaction=batchmode $diff; bibtex $diffbase"); + push @ptmpfiles, "$diffbase.bbl","$diffbase.bbl" ; + } + } + + if ( $postscript ) { + my $dvi="$diffbase.dvi"; + my $ps="$diffbase.ps"; + + system("latex --interaction=batchmode $diff; latex $diff; dvips -o $ps $dvi"); + push @ptmpfiles, "$diffbase.aux","$diffbase.log",$dvi ; + print "Generated postscript file $ps\n"; + } + elsif ( $pdf ) { + system("pdflatex --interaction=batchmode $diff; pdflatex $diff"); + push @ptmpfiles, "$diffbase.aux","$diffbase.log"; + } + unlink @ptmpfiles; + chdir $cwd; +} + +# greptex returns 1 if regex is not matched in filename +# 0 if there is a match +sub greptex { + my ($regex,$filename)=@_; + my ($i)=0; + open (FH, $filename) or die("Couldn't open $filename: $!"); + while () { + next if /^\s*%/; # skip comment lines + if ( m/$regex/ ) { + close(FH); + return(0); + } + # only scan 25 lines + $i++; + last if $i>25 ; + } + close(FH); + return(1); +} + + +=head1 NAME + +latexdiff-vc - wrapper script that calls latexdiff for different versions of a file under version management (CVS, RCS or SVN) + +=head1 SYNOPSIS + +B [ F ] [ F ] B<-r> [F] [B<-r> F] F [ F ...] + + or + +B [ F ] [ F ][ B<--postscript> | B<--pdf> ] F F + +=head1 DESCRIPTION + +I is a wrapper script that applies I to a +file, or multiple files under version control (CVS or RCS), and optionally runs the +sequence of C and C or C commands necessary to +produce pdf or postscript output of the difference tex file(s). It can +also be applied to a pair of files to automatise the generation of difference +file in postscript or pdf format. + +=head1 OPTIONS + +=over 4 + +=item B<--rcs>, B<--svn>, or B<--cvs> + +Set the version system. +If no version system is specified, latexdiff-vc will venture a guess. + +latexdiff-cvs and latexdiff-rcs are variants of latexdiff-vc which default to +the respective versioning system. However, this default can still be overridden using the options above. + +=item B<-r>, B<-r> F or B<--revision>, B<--revision=>F + +Choose revision (under RCS, CVS or SVN). One or two B<-r> options can be +specified, and the resulting in different behaviour: + +=over 4 + +=item B -r F ... + +compares F with the most recent version checked into RCS. + +=item B -r F F ... + +compares F with revision F. + +=item B -r F -r F F ... + +compares revisions F and F of F. + +Multiple files can be specified for all of the above options. All files must have the +extension C<.tex>, though. + +=item B F F + +compares two files. + +=back + +The name of the difference file is generated automatically and +reported to stdout. + +=item B<-d> or B<--dir> B<-d> F or B<--dir=>F + +Rather than appending the string C and optionally the version +numbers given to the output-file, this will prepend a directory name C +to the +original filename, creating the directory and subdirectories should they not exist already. This is particularly useful in order to clone a +complete directory hierarchy. Optionally, a pathname F can be specified, which is prepended instead of C. + +=item B<--ps> or B<--postscript> + +Generate postscript output from difference file. This will run the +sequence C on the difference file (do not use +this option in the rare cases, where three C commands are +required if you care about correct referencing). If the difference +file contains a C<\bibliography> tag, run the sequence C. + +=item B<--pdf> + +Generate pdf output from difference file using C. This will +run the sequence C on the difference file, or +C for files requiring bibtex. + +=item B<--force> + +Overwrite existing diff files without asking for confirmation. Default +behaviour is to ask for confirmation before overwriting an existing difference +file. + +=item B<--help> or +B<-h> + +Show help text + +=item B<--version> + +Show version number + +=back + +All other options are passed on to C. + +=head1 SEE ALSO + +L + +=head1 PORTABILITY + +I uses external commands and is therefore +limited to Unix-like systems. It also requires the RCS version control +system and latex to be installed on the system. Modules from Perl 5.8 +or higher are required. + + +=head1 AUTHOR + +Copyright (C) 2005 Frederik Tilmann + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License Version 2 +Contributors: S Utcke, H Bruyninckx + +=cut + diff --git a/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise b/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise deleted file mode 100755 index 279dac1fc6a..00000000000 --- a/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise +++ /dev/null @@ -1,523 +0,0 @@ -#!/usr/bin/perl -w -# latexrevise - takes output file of latexdiff and removes either discarded -# or appended passages, then deletes all other latexdiff markup -# -# Copyright (C) 2004 F J Tilmann (tilmann@esc.cam.ac.uk) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License Version 2 as published by -# the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Detailed usage information at the end of the file -# -# Version 0.1 First public release -# Version 0.3 Updated for compatibility with latexdiff 0.3 output (DIFAUXCMD removal) -# - -use Getopt::Long ; -use strict; - -# Markup strings (make sure that this are set to the same value as in -# latexdiff) -# If at all possible, do not change these as parts of the program -# depend on the actual name. -# At the very least adapt subroutine postprocess to new tokens. - -# note: have to use three backslashes to mean one literal one (reason -# unknown -my $ADDMARKOPEN='\\\DIFaddbegin(?:FL)? '; # Token to mark begin of appended text -my $ADDMARKCLOSE='\\\DIFaddend(?:FL)?(?: |\z)'; # Token to mark end of appended text (|\z only deals with the case of \DIFaddend right before \end{document} -my $ADDOPEN='\\\DIFadd(?:FL)?{'; # To mark begin of added text passage -my $ADDCLOSE='}'; # To mark end of added text passage -my $ADDCOMMENT='DIF > '; # To mark added comment line -my $DELMARKOPEN='\\\DIFdelbegin(?:FL)? '; # Token to mark begin of deleted text -my $DELMARKCLOSE='\\\DIFdelend(?:FL)?(?: |\z)'; # Token to mark end of deleted text -my $DELOPEN='\\\DIFdel(?:FL)?{'; # To mark begin of deleted text passage -my $DELCLOSE='}'; # To mark end of deleted text passage -my $ALTEXT='FL'; # string which might be appended to above commands -my $DELCMDOPEN='%DIFDELCMD < '; # To mark begin of deleted commands (must begin with %, i.e., be a comment -my $DELCMDCLOSE="%%%\n"; # To mark end of deleted commands (must end with a new line) -my $AUXCMD='%DIFAUXCMD' ; # follows auxiliary commands put in by latexdiff to make difference file legal -my $DELCOMMENT='DIF < '; # To mark deleted comment line - -my $PREAMBLEXTBEG='^%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF$'; -my $PREAMBLEXTEND='^%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF$'; - - -my $pat0 = '(?:[^{}]|\\\{|\\\})*'; -my $pat1 = '(?:[^{}]|\\\{|\\\}|\{'.$pat0.'\})*'; -my $pat2 = '(?:[^{}]|\\\{|\\\}|\{'.$pat1.'\})*'; -my $pat3 = '(?:[^{}]|\\\{|\\\}|\{'.$pat2.'\})*'; -my $pat4 = '(?:[^{}]|\\\{|\\\}|\{'.$pat3.'\})*'; -my $brat0 = '(?:[^\[\]]|\\\[|\\\])*'; - - -my ($input,$preamble,$body,$post); -my (@matches); -my ($cnt,$prematch,$postmatch); -my ($help); -my ($verbose,$quiet,$accept,$decline,$simplify)=(0,0,0,0,0); -my ($comment,$comenv,$markup,$markenv); - -# A word unlikely ever to be used in a real latex file -my $someword='gobbledegooksygook'; - -Getopt::Long::Configure('bundling'); -GetOptions('accept|a' => \$accept, - 'decline|d'=> \$decline, - 'simplify|s' => \$simplify, - 'comment|c=s' => \$comment, - 'comment-environment|e=s' => \$comenv, - 'markup|m=s' => \$markup, - 'markup-environment|n=s' => \$markenv, - 'no-warnings|q' => \$verbose, - 'verbose|V' => \$verbose, - 'help|h|H' => \$help); - -if ( $help ) { - usage() ; -} - -if ( ($accept && $decline) || ($accept && $simplify) || ($decline && $simplify) ) { - die '-a,-d and -s options are mutually axclusive. Type latexrevise -h to get more help.'; -} - - - -print STDERR "ACCEPT mode\n" if $verbose && $accept; -print STDERR "DECLINE mode\n" if $verbose && $decline; -print STDERR "SIMPLIFY mode. WARNING: The output will not normally be valid latex,\n" if $verbose && $simplify; - -# Slurp old and new files -{ - local $/ ; # locally set record operator to undefined, ie. enable whole-file mode - $input=<>; -} - -# split into parts -($preamble,$body,$post)=splitdoc($input,'\begin{document}','\end{document}'); - -if (length $preamble && ( $accept || $decline ) ) { - # - # WORK ON PREAMBLE - # - # (compare subroutine linediff in latexdiff to make sure correct strings are used) - - # remove extra commands added to preamble by latexdiff - $preamble =~ s/${PREAMBLEXTBEG}.*?${PREAMBLEXTEND}\n{0,1}//smg ; - - if ( $accept ) { - # delete mark up in appended lines - $preamble =~ s/^(.*) %DIF > $/$1/mg ; - } elsif ( $decline ) { - # delete appended lines - # $preamble =~ s/^(.*) %DIF > $//mg ; - $preamble =~ s/^(.*) %DIF > \n//mg ; - # delete markup in deleted lines - $preamble =~ s/^%DIF < //mg ; - } - # remove any remaining DIF markups - #$preamble =~ s/%DIF.*$//mg ; - $preamble =~ s/%DIF.*?\n//sg ; -} -#print $preamble ; - -# -# WORK ON BODY -# -if ($accept) { - # remove ADDMARKOPEN, ADDMARKCLOSE tokens - @matches= $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/sg; - checkpure(@matches); - $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/$1/sg; - # remove text flanked by DELMARKOPEN, DELMARKCLOSE tokens - @matches= $body =~ m/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/sg; - checkpure(@matches); - $body =~ s/${DELMARKOPEN}(.*?)${DELMARKCLOSE}//sg; - # remove markup of added comments - $body =~ s/%${ADDCOMMENT}(.*?)$/%$1/mg ; - # remove deleted comments (full line) - $body =~ s/^%${DELCOMMENT}.*?\n//mg ; - # remove deleted comments (part of line) - $body =~ s/%${DELCOMMENT}.*?$//mg ; -} -elsif ( $decline) { - # remove DELMARKOPEN, DELMARKCLOSE tokens - @matches= $body =~ m/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/sg; - checkpure(@matches); - $body =~ s/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/$1/sg; - # remove text flanked by ADDMARKOPEN, ADDMARKCLOSE tokens - # as latexdiff algorithm keeps the formatting and white spaces - # of the new text, sometimes whitespace might be inserted or - # removed inappropriately. We try to guess whether this has - # happened - - # Mop up tokens. This must be done already now as otherwise - # detection of white-space problems does not work - $cnt = $body =~ s/${DELOPEN}($pat4)${DELCLOSE}/$1/sg; - # remove markup of deleted commands - $cnt += $body =~ s/${DELCMDOPEN}(.*?)${DELCMDCLOSE}/$1/sg ; - $cnt += $body =~ s/${DELCMDOPEN}//g ; - # remove aux commands - $cnt += $body =~ s/^.*${AUXCMD}$/${someword}/mg; $body =~ s/${someword}\n//g; - - while ( $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/s ) { - $prematch=$`; - $postmatch=$'; - checkpure($1); - if ( $prematch =~ /\w$/s && $postmatch =~ /^\w/ ) { - # apparently no white-space between word=>Insert white space - $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/ /s ; - } - elsif ( $prematch =~ /\s$/s && $postmatch =~ /^[.,;:]/ ) { - # space immediately before one of ".,:;" => remove this space - $body =~ s/\s${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//s ; - } - else { - # do not insert or remove any extras - $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//s; - } - } -# Alternative without special cases treatment -# @matches= $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/sg; -# checkpure(@matches); -# $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//sg; - # remove markup of deleted comments - $body =~ s/%${DELCOMMENT}(.*?)$/%$1/mg ; - # remove added comments (full line) - $body =~ s/^%${ADDCOMMENT}.*?\n//mg ; - # remove added comments (part of line) - $body =~ s/%${ADDCOMMENT}.*?$//mg ; -} - -# remove any remaining tokens -if ( $accept || $decline || $simplify ) { - # first substitution command deals with special case of added paragraph - $cnt = $body =~ s/${ADDOPEN}($pat4)\n${ADDCLOSE}\n/$1\n/sg; - $cnt += $body =~ s/${ADDOPEN}($pat4)${ADDCLOSE}/$1/sg; - $cnt==0 || warn 'Remaining $ADDOPEN tokens in DECLINE mode\n' unless ( $quiet || $accept || $simplify ); -} -if ($accept || $simplify ) { - # Note: in decline mode these commands have already been removed above - $cnt = $body =~ s/${DELOPEN}($pat4)${DELCLOSE}/$1/sg; - #### remove markup of deleted commands - $cnt += $body =~ s/${DELCMDOPEN}(.*?)${DELCMDCLOSE}/$1/sg ; - $cnt += $body =~ s/${DELCMDOPEN}//g ; - # remove aux commands - # $cnt += - $body =~ s/^.*${AUXCMD}$/${someword}/mg; $body =~ s/${someword}\n//g; - - #### remove deleted comments - ###$cnt += $body =~ s/${DIFDELCMD}.*?$//mg ; - $cnt==0 || warn 'Remaining $DELOPEN or $DIFDELCMD tokens in ACCEPT mode\n' unless ( $quiet || $simplify ); -} - -# Remove comment commands -if (defined($comment)) { - print STDERR "Removing \\$comment\{..\} sequences ..." if $verbose; - # protect $comments in comments by making them look different - $body =~ s/(%.*)${comment}(.*)$/$1${someword}$2/mg ; - # carry out the substitution - $cnt = 0 + $body =~ s/\\${comment}(?:\[${brat0}\])?\{${pat4}\}//sg ; - print STDERR "$cnt matches found and removed.\n" if $verbose; - # and undo the protection substitution - $body =~ s/(%.*)${someword}(.*)$/$1${comment}$2/mg ; -} -if (defined($comenv)) { - print STDERR "Removing $comenv environments ..." if $verbose; - $body =~ s/(%.*)${comenv}/$1${someword}/mg ; -## $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{\$comenv\}.*?\\end\{\$comenv\}//sg ; - $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{${comenv}\}.*?\\end\{${comenv}\}\s*?\n//sg ; - print STDERR "$cnt matches found and removed.\n" if $verbose; - $body =~ s/(%.*)${someword}/$1${comenv}/mg ; -} - -if (defined($markup)) { - print STDERR "Removing \\$markup\{..\} cpmmands ..." if $verbose; - # protect $markups in comments by making them look different - $body =~ s/(%.*)${markup}(.*)$/$1${someword}$2/mg ; - # carry out the substitution - $cnt = 0 + $body =~ s/\\${markup}(?:\[${brat0}\])?\{(${pat4})\}/$1/sg ; - print STDERR "$cnt matches found and removed.\n" if $verbose; - # and undo the protection substitution - $body =~ s/(%.*)${someword}(.*)$/$1${markup}$2/mg ; -} -if (defined($markenv)) { - print STDERR "Removing $markenv environments ..." if $verbose; - $body =~ s/(%.*)${markenv}/$1${someword}/mg ; - $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{${markenv}\}\n?//sg; - $cnt += 0 + $body =~ s/\\end\{${markenv}\}\n?//sg; - print STDERR $cnt/2, " matches found and removed.\n" if $verbose; - $body =~ s/(%.*)${someword}/$1${markenv}/mg ; -} - - -if ( length $preamble ) { - print "$preamble\\begin{document}${body}\\end{document}$post"; -} else { - print $body; -} - -# checkpure(@matches) -# checks whether any of the strings in matches contains -# $ADDMARKOPEN, $ADDMARKCLOSE,$DELMARKOPEN, or $DELMARKCLOSE -# If so, die reporting nesting problems, otherwise return to caller -sub checkpure { - while (defined($_=shift)) { - if ( /$ADDMARKOPEN/ || /$ADDMARKCLOSE/ - || /$DELMARKOPEN/ || /$DELMARKCLOSE/ ) { - die <=0 && $j>$i ) { - $part1 = substr($text,0,$i) ; - $part2 = substr($text,$i+$l1,$j-$i-$l1); - $part3 = substr($text,$j+$l2) unless $j+$l2 >= length $text; - } else { - die "$word1 or $word2 not in the correct order or not present as a pair." - } - return ($part1,$part2,$part3); -} - - - -sub usage { - die <<"EOF"; -Usage: $0 [OPTIONS] [diff.tex] > revised.tex - -Read a file diff.tex (output of latexdiff), and remove its markup. -If no filename is given read from standard input. The command can be used -in ACCEPT, DECLINE, or SIMPLIFY mode, and be used to remove user-defined -latex commands from the input (see options -c, -e, -m, -n below). -In ACCEPT mode, all appended text fragments (or preamble lines) -are kept, and all discarded text fragments (or preamble lines) are -deleted. -In DECLINE mode, all discarded text fragments are kept, and all appended -text fragments are deleted. -If you wish to keep some changes, edit the diff.tex file in -advance, and manually remove those tokens which would otherwise be -deleted. Note that latexrevise only pays attention to the \\DIFaddbegin, -\\DIFaddend, \\DIFdelbegin, and \\DIFdelend tokens and corresponding FL -varieties. All \\DIFadd and \\DIFdel commands (but not their content) are -simply deleted. The commands added by latexdiff to the preamble are also -removed. -In SIMPLIFY mode all latexdiff markup is removed from the body of the text (after -\\begin{document}) except for \\DIFaddbegin, \\DIFaddend, \\DIFdelbegin, \\DIFdelend -tokens and the corresponding FL varieties of those commands. The result -will not in general be valid latex-code but might be easier to read and edit in -preparation for a subsequent run in ACCEPT or DECLINE mode. -In SIMPLIFY mode the preamble is left unmodified. - --a ---accept Run in ACCEPT mode (delete all blocks marked by \\DIFdelbegin - and \\DIFdelend). - --d ---decline Run in DECLINE mode (delete all blocks marked by \\DIFaddbegin - and \\DIFaddend). - --s ---simplify Run in SIMPLIFY mode (Keep all \\DIFaddbegin, \\DIFaddend, - \\DIFdelbegin, \\DIFdelend tokens, but remove all other latexdiff - markup from body. - -Note that the three mode options are mutually exclusive. If no mode option is given, -latexrevise simply removes user annotations and markup according to the following four -options. - - --c cmd ---comment=cmd Remove \\cmd{...}. cmd is supposed to mark some explicit - anotations which should be removed from the file before - release. - --e envir ---comment-environment=envir - Remove explicit annotation environments from the text, i.e. remove - \\begin{envir} - ... - \\end{envir} - blocks. - --m cmd ---markup=cmd Remove the markup command cmd but leave its argument, i.e. - turn \\cmd{abc} into abc. - --n envir ---markup-environment=envir - Similarly, remove \\begin{envir} and \\end{envir} commands, - but leave content of the environment in the text. - --q ---no-warnings Do not warn users about \\DIDadd{..} or \\DIFdel statements - which should not be there anymore - --V ---verbose Verbose output - -EOF -} - -=head1 NAME - -latexrevise - selectively remove markup and text from latexdiff output - -=head1 SYNOPSIS - -B [ B ] [ F ] > F - -=head1 DESCRIPTION - -I reads a file C (output of I), and remove the markup commands. -If no filename is given the input is read from standard input. The command can be used -in I, I, or I mode, or can be used to remove user-defined -latex commands from the input (see B<-c>, B<-e>, B<-m>, and B<-n> below). -In I mode, all appended text fragments (or preamble lines) -are kept, and all discarded text fragments (or preamble lines) are -deleted. -In I mode, all discarded text fragments are kept, and all appended -text fragments are deleted. -If you wish to keep some changes, edit the diff.tex file in -advance, and manually remove those tokens which would otherwise be -deleted. Note that I only pays attention to the C<\DIFaddbegin>, -C<\DIFaddend>, C<\DIFdelbegin>, and C<\DIFdelend> tokens and corresponding FL -varieties. All C<\DIFadd> and C<\DIFdel> commands (but not their contents) are -simply deleted. The commands added by latexdiff to the preamble are also -removed. -In I mode, C<\DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend> -tokens and their corresponding C varieties are kept but all other markup (e.g. C and <\DIFdel>) is removed. The result -will not in general be valid latex-code but it will be easier to read and edit in -preparation for a subsequent run in I or I mode. -In I mode the preamble is left unmodified. - -=head1 OPTIONS - -=over 4 - -=item B<-a> or B<--accept> - -Run in I mode (delete all blocks marked by C<\DIFdelbegin> and C<\DIFdelend>). - -=item B<-d> or B<--decline> - -Run in I mode (delete all blocks marked by C<\DIFaddbegin> -and C<\DIFaddend>). - -=item B<-s> or B<--simplify> - -Run in I mode (Keep all C<\DIFaddbegin>, C<\DIFaddend>, -C<\DIFdelbegin>, C<\DIFdelend> tokens, but remove all other latexdiff -markup from body). - -=back - -Note that the three mode options are mutually exclusive. If no mode option is given, -I simply removes user annotations and markup according to the following four -options. - -=over 4 - -=item B<-c cmd> or B<--comment=cmd> - -Remove C<\cmd{...}> sequences. C is supposed to mark some explicit -anotations which should be removed from the file before -release. - -=item B<-e envir> or B<--comment-environment=envir> - -Remove explicit annotation environments from the text, i.e. remove - - \begin{envir} - ... - \end{envir} - -blocks. - -=item B<-m cmd> or B<--markup=cmd> - -Remove the markup command C<\cmd> but leave its argument, i.e. -turn C<\cmd{abc}> into C. - -=item B<-n envir> or B<--markup-environment=envir> - -Similarly, remove C<\begin{envir}> and C<\end{envir}> commands but -leave content of the environment in the text. - - -=item B<-V> or B<--verbose> - -Verbose output - -=item B<-q> or B<--no-warnings> - -Do not warn users about C<\DIDadd{..}> or C<\DIFdel{..}> statements -which should have been removed already. - -=back - -=head1 BUGS - -The current version is a beta version which has not yet been -extensively tested, but worked fine locally. Please send bug reports -to I. Include the serial number of I -(from comments at the top of the source). If you come across latexdiff -output which is not processed correctly by I please include the -problem file as well as the old and new files on which it is based, -ideally edited to only contain the offending passage as long as that still -reproduces the problem. - -I gets confused by commented C<\begin{document}> or -C<\end{document}> statements - -=head1 SEE ALSO - -L - -=head1 PORTABILITY - -I does not make use of external commands and thus should run -on any platform supporting PERL v5 or higher. - -=head1 AUTHOR - -Copyright (C) 2004 Frederik Tilmann - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License Version 2 - -=cut diff --git a/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise.pl b/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise.pl new file mode 100755 index 00000000000..279dac1fc6a --- /dev/null +++ b/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise.pl @@ -0,0 +1,523 @@ +#!/usr/bin/perl -w +# latexrevise - takes output file of latexdiff and removes either discarded +# or appended passages, then deletes all other latexdiff markup +# +# Copyright (C) 2004 F J Tilmann (tilmann@esc.cam.ac.uk) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License Version 2 as published by +# the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Detailed usage information at the end of the file +# +# Version 0.1 First public release +# Version 0.3 Updated for compatibility with latexdiff 0.3 output (DIFAUXCMD removal) +# + +use Getopt::Long ; +use strict; + +# Markup strings (make sure that this are set to the same value as in +# latexdiff) +# If at all possible, do not change these as parts of the program +# depend on the actual name. +# At the very least adapt subroutine postprocess to new tokens. + +# note: have to use three backslashes to mean one literal one (reason +# unknown +my $ADDMARKOPEN='\\\DIFaddbegin(?:FL)? '; # Token to mark begin of appended text +my $ADDMARKCLOSE='\\\DIFaddend(?:FL)?(?: |\z)'; # Token to mark end of appended text (|\z only deals with the case of \DIFaddend right before \end{document} +my $ADDOPEN='\\\DIFadd(?:FL)?{'; # To mark begin of added text passage +my $ADDCLOSE='}'; # To mark end of added text passage +my $ADDCOMMENT='DIF > '; # To mark added comment line +my $DELMARKOPEN='\\\DIFdelbegin(?:FL)? '; # Token to mark begin of deleted text +my $DELMARKCLOSE='\\\DIFdelend(?:FL)?(?: |\z)'; # Token to mark end of deleted text +my $DELOPEN='\\\DIFdel(?:FL)?{'; # To mark begin of deleted text passage +my $DELCLOSE='}'; # To mark end of deleted text passage +my $ALTEXT='FL'; # string which might be appended to above commands +my $DELCMDOPEN='%DIFDELCMD < '; # To mark begin of deleted commands (must begin with %, i.e., be a comment +my $DELCMDCLOSE="%%%\n"; # To mark end of deleted commands (must end with a new line) +my $AUXCMD='%DIFAUXCMD' ; # follows auxiliary commands put in by latexdiff to make difference file legal +my $DELCOMMENT='DIF < '; # To mark deleted comment line + +my $PREAMBLEXTBEG='^%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF$'; +my $PREAMBLEXTEND='^%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF$'; + + +my $pat0 = '(?:[^{}]|\\\{|\\\})*'; +my $pat1 = '(?:[^{}]|\\\{|\\\}|\{'.$pat0.'\})*'; +my $pat2 = '(?:[^{}]|\\\{|\\\}|\{'.$pat1.'\})*'; +my $pat3 = '(?:[^{}]|\\\{|\\\}|\{'.$pat2.'\})*'; +my $pat4 = '(?:[^{}]|\\\{|\\\}|\{'.$pat3.'\})*'; +my $brat0 = '(?:[^\[\]]|\\\[|\\\])*'; + + +my ($input,$preamble,$body,$post); +my (@matches); +my ($cnt,$prematch,$postmatch); +my ($help); +my ($verbose,$quiet,$accept,$decline,$simplify)=(0,0,0,0,0); +my ($comment,$comenv,$markup,$markenv); + +# A word unlikely ever to be used in a real latex file +my $someword='gobbledegooksygook'; + +Getopt::Long::Configure('bundling'); +GetOptions('accept|a' => \$accept, + 'decline|d'=> \$decline, + 'simplify|s' => \$simplify, + 'comment|c=s' => \$comment, + 'comment-environment|e=s' => \$comenv, + 'markup|m=s' => \$markup, + 'markup-environment|n=s' => \$markenv, + 'no-warnings|q' => \$verbose, + 'verbose|V' => \$verbose, + 'help|h|H' => \$help); + +if ( $help ) { + usage() ; +} + +if ( ($accept && $decline) || ($accept && $simplify) || ($decline && $simplify) ) { + die '-a,-d and -s options are mutually axclusive. Type latexrevise -h to get more help.'; +} + + + +print STDERR "ACCEPT mode\n" if $verbose && $accept; +print STDERR "DECLINE mode\n" if $verbose && $decline; +print STDERR "SIMPLIFY mode. WARNING: The output will not normally be valid latex,\n" if $verbose && $simplify; + +# Slurp old and new files +{ + local $/ ; # locally set record operator to undefined, ie. enable whole-file mode + $input=<>; +} + +# split into parts +($preamble,$body,$post)=splitdoc($input,'\begin{document}','\end{document}'); + +if (length $preamble && ( $accept || $decline ) ) { + # + # WORK ON PREAMBLE + # + # (compare subroutine linediff in latexdiff to make sure correct strings are used) + + # remove extra commands added to preamble by latexdiff + $preamble =~ s/${PREAMBLEXTBEG}.*?${PREAMBLEXTEND}\n{0,1}//smg ; + + if ( $accept ) { + # delete mark up in appended lines + $preamble =~ s/^(.*) %DIF > $/$1/mg ; + } elsif ( $decline ) { + # delete appended lines + # $preamble =~ s/^(.*) %DIF > $//mg ; + $preamble =~ s/^(.*) %DIF > \n//mg ; + # delete markup in deleted lines + $preamble =~ s/^%DIF < //mg ; + } + # remove any remaining DIF markups + #$preamble =~ s/%DIF.*$//mg ; + $preamble =~ s/%DIF.*?\n//sg ; +} +#print $preamble ; + +# +# WORK ON BODY +# +if ($accept) { + # remove ADDMARKOPEN, ADDMARKCLOSE tokens + @matches= $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/sg; + checkpure(@matches); + $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/$1/sg; + # remove text flanked by DELMARKOPEN, DELMARKCLOSE tokens + @matches= $body =~ m/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/sg; + checkpure(@matches); + $body =~ s/${DELMARKOPEN}(.*?)${DELMARKCLOSE}//sg; + # remove markup of added comments + $body =~ s/%${ADDCOMMENT}(.*?)$/%$1/mg ; + # remove deleted comments (full line) + $body =~ s/^%${DELCOMMENT}.*?\n//mg ; + # remove deleted comments (part of line) + $body =~ s/%${DELCOMMENT}.*?$//mg ; +} +elsif ( $decline) { + # remove DELMARKOPEN, DELMARKCLOSE tokens + @matches= $body =~ m/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/sg; + checkpure(@matches); + $body =~ s/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/$1/sg; + # remove text flanked by ADDMARKOPEN, ADDMARKCLOSE tokens + # as latexdiff algorithm keeps the formatting and white spaces + # of the new text, sometimes whitespace might be inserted or + # removed inappropriately. We try to guess whether this has + # happened + + # Mop up tokens. This must be done already now as otherwise + # detection of white-space problems does not work + $cnt = $body =~ s/${DELOPEN}($pat4)${DELCLOSE}/$1/sg; + # remove markup of deleted commands + $cnt += $body =~ s/${DELCMDOPEN}(.*?)${DELCMDCLOSE}/$1/sg ; + $cnt += $body =~ s/${DELCMDOPEN}//g ; + # remove aux commands + $cnt += $body =~ s/^.*${AUXCMD}$/${someword}/mg; $body =~ s/${someword}\n//g; + + while ( $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/s ) { + $prematch=$`; + $postmatch=$'; + checkpure($1); + if ( $prematch =~ /\w$/s && $postmatch =~ /^\w/ ) { + # apparently no white-space between word=>Insert white space + $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/ /s ; + } + elsif ( $prematch =~ /\s$/s && $postmatch =~ /^[.,;:]/ ) { + # space immediately before one of ".,:;" => remove this space + $body =~ s/\s${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//s ; + } + else { + # do not insert or remove any extras + $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//s; + } + } +# Alternative without special cases treatment +# @matches= $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/sg; +# checkpure(@matches); +# $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//sg; + # remove markup of deleted comments + $body =~ s/%${DELCOMMENT}(.*?)$/%$1/mg ; + # remove added comments (full line) + $body =~ s/^%${ADDCOMMENT}.*?\n//mg ; + # remove added comments (part of line) + $body =~ s/%${ADDCOMMENT}.*?$//mg ; +} + +# remove any remaining tokens +if ( $accept || $decline || $simplify ) { + # first substitution command deals with special case of added paragraph + $cnt = $body =~ s/${ADDOPEN}($pat4)\n${ADDCLOSE}\n/$1\n/sg; + $cnt += $body =~ s/${ADDOPEN}($pat4)${ADDCLOSE}/$1/sg; + $cnt==0 || warn 'Remaining $ADDOPEN tokens in DECLINE mode\n' unless ( $quiet || $accept || $simplify ); +} +if ($accept || $simplify ) { + # Note: in decline mode these commands have already been removed above + $cnt = $body =~ s/${DELOPEN}($pat4)${DELCLOSE}/$1/sg; + #### remove markup of deleted commands + $cnt += $body =~ s/${DELCMDOPEN}(.*?)${DELCMDCLOSE}/$1/sg ; + $cnt += $body =~ s/${DELCMDOPEN}//g ; + # remove aux commands + # $cnt += + $body =~ s/^.*${AUXCMD}$/${someword}/mg; $body =~ s/${someword}\n//g; + + #### remove deleted comments + ###$cnt += $body =~ s/${DIFDELCMD}.*?$//mg ; + $cnt==0 || warn 'Remaining $DELOPEN or $DIFDELCMD tokens in ACCEPT mode\n' unless ( $quiet || $simplify ); +} + +# Remove comment commands +if (defined($comment)) { + print STDERR "Removing \\$comment\{..\} sequences ..." if $verbose; + # protect $comments in comments by making them look different + $body =~ s/(%.*)${comment}(.*)$/$1${someword}$2/mg ; + # carry out the substitution + $cnt = 0 + $body =~ s/\\${comment}(?:\[${brat0}\])?\{${pat4}\}//sg ; + print STDERR "$cnt matches found and removed.\n" if $verbose; + # and undo the protection substitution + $body =~ s/(%.*)${someword}(.*)$/$1${comment}$2/mg ; +} +if (defined($comenv)) { + print STDERR "Removing $comenv environments ..." if $verbose; + $body =~ s/(%.*)${comenv}/$1${someword}/mg ; +## $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{\$comenv\}.*?\\end\{\$comenv\}//sg ; + $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{${comenv}\}.*?\\end\{${comenv}\}\s*?\n//sg ; + print STDERR "$cnt matches found and removed.\n" if $verbose; + $body =~ s/(%.*)${someword}/$1${comenv}/mg ; +} + +if (defined($markup)) { + print STDERR "Removing \\$markup\{..\} cpmmands ..." if $verbose; + # protect $markups in comments by making them look different + $body =~ s/(%.*)${markup}(.*)$/$1${someword}$2/mg ; + # carry out the substitution + $cnt = 0 + $body =~ s/\\${markup}(?:\[${brat0}\])?\{(${pat4})\}/$1/sg ; + print STDERR "$cnt matches found and removed.\n" if $verbose; + # and undo the protection substitution + $body =~ s/(%.*)${someword}(.*)$/$1${markup}$2/mg ; +} +if (defined($markenv)) { + print STDERR "Removing $markenv environments ..." if $verbose; + $body =~ s/(%.*)${markenv}/$1${someword}/mg ; + $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{${markenv}\}\n?//sg; + $cnt += 0 + $body =~ s/\\end\{${markenv}\}\n?//sg; + print STDERR $cnt/2, " matches found and removed.\n" if $verbose; + $body =~ s/(%.*)${someword}/$1${markenv}/mg ; +} + + +if ( length $preamble ) { + print "$preamble\\begin{document}${body}\\end{document}$post"; +} else { + print $body; +} + +# checkpure(@matches) +# checks whether any of the strings in matches contains +# $ADDMARKOPEN, $ADDMARKCLOSE,$DELMARKOPEN, or $DELMARKCLOSE +# If so, die reporting nesting problems, otherwise return to caller +sub checkpure { + while (defined($_=shift)) { + if ( /$ADDMARKOPEN/ || /$ADDMARKCLOSE/ + || /$DELMARKOPEN/ || /$DELMARKCLOSE/ ) { + die <=0 && $j>$i ) { + $part1 = substr($text,0,$i) ; + $part2 = substr($text,$i+$l1,$j-$i-$l1); + $part3 = substr($text,$j+$l2) unless $j+$l2 >= length $text; + } else { + die "$word1 or $word2 not in the correct order or not present as a pair." + } + return ($part1,$part2,$part3); +} + + + +sub usage { + die <<"EOF"; +Usage: $0 [OPTIONS] [diff.tex] > revised.tex + +Read a file diff.tex (output of latexdiff), and remove its markup. +If no filename is given read from standard input. The command can be used +in ACCEPT, DECLINE, or SIMPLIFY mode, and be used to remove user-defined +latex commands from the input (see options -c, -e, -m, -n below). +In ACCEPT mode, all appended text fragments (or preamble lines) +are kept, and all discarded text fragments (or preamble lines) are +deleted. +In DECLINE mode, all discarded text fragments are kept, and all appended +text fragments are deleted. +If you wish to keep some changes, edit the diff.tex file in +advance, and manually remove those tokens which would otherwise be +deleted. Note that latexrevise only pays attention to the \\DIFaddbegin, +\\DIFaddend, \\DIFdelbegin, and \\DIFdelend tokens and corresponding FL +varieties. All \\DIFadd and \\DIFdel commands (but not their content) are +simply deleted. The commands added by latexdiff to the preamble are also +removed. +In SIMPLIFY mode all latexdiff markup is removed from the body of the text (after +\\begin{document}) except for \\DIFaddbegin, \\DIFaddend, \\DIFdelbegin, \\DIFdelend +tokens and the corresponding FL varieties of those commands. The result +will not in general be valid latex-code but might be easier to read and edit in +preparation for a subsequent run in ACCEPT or DECLINE mode. +In SIMPLIFY mode the preamble is left unmodified. + +-a +--accept Run in ACCEPT mode (delete all blocks marked by \\DIFdelbegin + and \\DIFdelend). + +-d +--decline Run in DECLINE mode (delete all blocks marked by \\DIFaddbegin + and \\DIFaddend). + +-s +--simplify Run in SIMPLIFY mode (Keep all \\DIFaddbegin, \\DIFaddend, + \\DIFdelbegin, \\DIFdelend tokens, but remove all other latexdiff + markup from body. + +Note that the three mode options are mutually exclusive. If no mode option is given, +latexrevise simply removes user annotations and markup according to the following four +options. + + +-c cmd +--comment=cmd Remove \\cmd{...}. cmd is supposed to mark some explicit + anotations which should be removed from the file before + release. + +-e envir +--comment-environment=envir + Remove explicit annotation environments from the text, i.e. remove + \\begin{envir} + ... + \\end{envir} + blocks. + +-m cmd +--markup=cmd Remove the markup command cmd but leave its argument, i.e. + turn \\cmd{abc} into abc. + +-n envir +--markup-environment=envir + Similarly, remove \\begin{envir} and \\end{envir} commands, + but leave content of the environment in the text. + +-q +--no-warnings Do not warn users about \\DIDadd{..} or \\DIFdel statements + which should not be there anymore + +-V +--verbose Verbose output + +EOF +} + +=head1 NAME + +latexrevise - selectively remove markup and text from latexdiff output + +=head1 SYNOPSIS + +B [ B ] [ F ] > F + +=head1 DESCRIPTION + +I reads a file C (output of I), and remove the markup commands. +If no filename is given the input is read from standard input. The command can be used +in I, I, or I mode, or can be used to remove user-defined +latex commands from the input (see B<-c>, B<-e>, B<-m>, and B<-n> below). +In I mode, all appended text fragments (or preamble lines) +are kept, and all discarded text fragments (or preamble lines) are +deleted. +In I mode, all discarded text fragments are kept, and all appended +text fragments are deleted. +If you wish to keep some changes, edit the diff.tex file in +advance, and manually remove those tokens which would otherwise be +deleted. Note that I only pays attention to the C<\DIFaddbegin>, +C<\DIFaddend>, C<\DIFdelbegin>, and C<\DIFdelend> tokens and corresponding FL +varieties. All C<\DIFadd> and C<\DIFdel> commands (but not their contents) are +simply deleted. The commands added by latexdiff to the preamble are also +removed. +In I mode, C<\DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend> +tokens and their corresponding C varieties are kept but all other markup (e.g. C and <\DIFdel>) is removed. The result +will not in general be valid latex-code but it will be easier to read and edit in +preparation for a subsequent run in I or I mode. +In I mode the preamble is left unmodified. + +=head1 OPTIONS + +=over 4 + +=item B<-a> or B<--accept> + +Run in I mode (delete all blocks marked by C<\DIFdelbegin> and C<\DIFdelend>). + +=item B<-d> or B<--decline> + +Run in I mode (delete all blocks marked by C<\DIFaddbegin> +and C<\DIFaddend>). + +=item B<-s> or B<--simplify> + +Run in I mode (Keep all C<\DIFaddbegin>, C<\DIFaddend>, +C<\DIFdelbegin>, C<\DIFdelend> tokens, but remove all other latexdiff +markup from body). + +=back + +Note that the three mode options are mutually exclusive. If no mode option is given, +I simply removes user annotations and markup according to the following four +options. + +=over 4 + +=item B<-c cmd> or B<--comment=cmd> + +Remove C<\cmd{...}> sequences. C is supposed to mark some explicit +anotations which should be removed from the file before +release. + +=item B<-e envir> or B<--comment-environment=envir> + +Remove explicit annotation environments from the text, i.e. remove + + \begin{envir} + ... + \end{envir} + +blocks. + +=item B<-m cmd> or B<--markup=cmd> + +Remove the markup command C<\cmd> but leave its argument, i.e. +turn C<\cmd{abc}> into C. + +=item B<-n envir> or B<--markup-environment=envir> + +Similarly, remove C<\begin{envir}> and C<\end{envir}> commands but +leave content of the environment in the text. + + +=item B<-V> or B<--verbose> + +Verbose output + +=item B<-q> or B<--no-warnings> + +Do not warn users about C<\DIDadd{..}> or C<\DIFdel{..}> statements +which should have been removed already. + +=back + +=head1 BUGS + +The current version is a beta version which has not yet been +extensively tested, but worked fine locally. Please send bug reports +to I. Include the serial number of I +(from comments at the top of the source). If you come across latexdiff +output which is not processed correctly by I please include the +problem file as well as the old and new files on which it is based, +ideally edited to only contain the offending passage as long as that still +reproduces the problem. + +I gets confused by commented C<\begin{document}> or +C<\end{document}> statements + +=head1 SEE ALSO + +L + +=head1 PORTABILITY + +I does not make use of external commands and thus should run +on any platform supporting PERL v5 or higher. + +=head1 AUTHOR + +Copyright (C) 2004 Frederik Tilmann + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License Version 2 + +=cut diff --git a/Master/bin/alpha-linux/latexdiff-vc b/Master/bin/alpha-linux/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/alpha-linux/latexdiff-vc +++ b/Master/bin/alpha-linux/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/alpha-linux/latexrevise b/Master/bin/alpha-linux/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/alpha-linux/latexrevise +++ b/Master/bin/alpha-linux/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/i386-cygwin/latexdiff-vc b/Master/bin/i386-cygwin/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/i386-cygwin/latexdiff-vc +++ b/Master/bin/i386-cygwin/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/i386-cygwin/latexrevise b/Master/bin/i386-cygwin/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/i386-cygwin/latexrevise +++ b/Master/bin/i386-cygwin/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/i386-linux/latexdiff-vc b/Master/bin/i386-linux/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/i386-linux/latexdiff-vc +++ b/Master/bin/i386-linux/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/i386-linux/latexrevise b/Master/bin/i386-linux/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/i386-linux/latexrevise +++ b/Master/bin/i386-linux/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/i386-netbsd/latexdiff-vc b/Master/bin/i386-netbsd/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/i386-netbsd/latexdiff-vc +++ b/Master/bin/i386-netbsd/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/i386-netbsd/latexrevise b/Master/bin/i386-netbsd/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/i386-netbsd/latexrevise +++ b/Master/bin/i386-netbsd/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/i386-solaris/latexdiff-vc b/Master/bin/i386-solaris/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/i386-solaris/latexdiff-vc +++ b/Master/bin/i386-solaris/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/i386-solaris/latexrevise b/Master/bin/i386-solaris/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/i386-solaris/latexrevise +++ b/Master/bin/i386-solaris/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/mips-irix/latexdiff-vc b/Master/bin/mips-irix/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/mips-irix/latexdiff-vc +++ b/Master/bin/mips-irix/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/mips-irix/latexrevise b/Master/bin/mips-irix/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/mips-irix/latexrevise +++ b/Master/bin/mips-irix/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/powerpc-aix/latexdiff-vc b/Master/bin/powerpc-aix/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/powerpc-aix/latexdiff-vc +++ b/Master/bin/powerpc-aix/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/powerpc-aix/latexrevise b/Master/bin/powerpc-aix/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/powerpc-aix/latexrevise +++ b/Master/bin/powerpc-aix/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/powerpc-linux/latexdiff-vc b/Master/bin/powerpc-linux/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/powerpc-linux/latexdiff-vc +++ b/Master/bin/powerpc-linux/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/powerpc-linux/latexrevise b/Master/bin/powerpc-linux/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/powerpc-linux/latexrevise +++ b/Master/bin/powerpc-linux/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/sparc-linux/latexdiff-vc b/Master/bin/sparc-linux/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/sparc-linux/latexdiff-vc +++ b/Master/bin/sparc-linux/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/sparc-linux/latexrevise b/Master/bin/sparc-linux/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/sparc-linux/latexrevise +++ b/Master/bin/sparc-linux/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/sparc-solaris/latexdiff-vc b/Master/bin/sparc-solaris/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/sparc-solaris/latexdiff-vc +++ b/Master/bin/sparc-solaris/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/sparc-solaris/latexrevise b/Master/bin/sparc-solaris/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/sparc-solaris/latexrevise +++ b/Master/bin/sparc-solaris/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/universal-darwin/latexdiff-vc b/Master/bin/universal-darwin/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/universal-darwin/latexdiff-vc +++ b/Master/bin/universal-darwin/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/universal-darwin/latexrevise b/Master/bin/universal-darwin/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/universal-darwin/latexrevise +++ b/Master/bin/universal-darwin/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/bin/x86_64-linux/latexdiff-vc b/Master/bin/x86_64-linux/latexdiff-vc index 608d1da907e..7f25407d7e5 120000 --- a/Master/bin/x86_64-linux/latexdiff-vc +++ b/Master/bin/x86_64-linux/latexdiff-vc @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexdiff-vc \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexdiff-vc.pl \ No newline at end of file diff --git a/Master/bin/x86_64-linux/latexrevise b/Master/bin/x86_64-linux/latexrevise index 36bc5559964..d2325c31e6c 120000 --- a/Master/bin/x86_64-linux/latexrevise +++ b/Master/bin/x86_64-linux/latexrevise @@ -1 +1 @@ -../../texmf-dist/scripts/latexdiff/latexrevise \ No newline at end of file +../../texmf-dist/scripts/latexdiff/latexrevise.pl \ No newline at end of file diff --git a/Master/texmf-dist/scripts/latexdiff/latexdiff-vc b/Master/texmf-dist/scripts/latexdiff/latexdiff-vc deleted file mode 100755 index 3e9a3f246de..00000000000 --- a/Master/texmf-dist/scripts/latexdiff/latexdiff-vc +++ /dev/null @@ -1,430 +0,0 @@ -#!/usr/bin/perl -w -# Place the following 2 lines at beginning to make script independent of location of perl -#eval 'exec perl -w -S $0 ${1+"$@"}' -# if 0; # not running under some shell -# -# latexdiff-vc - wrapper script for applying latexdiff to rcs managed files -# and for automatised creation of postscript or pdf from difference file -# -# Copyright (C) 2005 F J Tilmann (tilmann@esc.cam.ac.uk) -# -# Contributors: S Utcke, H Bruyninckx -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License Version 2 as published by -# the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Detailed usage information at the end of the file -# -# version 0.25: -# - bbl is allowed as alternative extension (instead of .tex) -# -use Getopt::Long ; -use Pod::Usage qw/pod2usage/ ; -use File::Temp qw/tempdir/ ; -use File::Basename qw/dirname/; -use strict ; - -# Option names -my ($version,$help,$postscript,$pdf,$force,$dir,$cvs,$rcs,$svn,$diffcmd,$patchcmd,@revs); -# Preset Variables -my $latexdiff="latexdiff"; # Program for making the comparison -my $vc=""; -my $tempdir=tempdir(CLEANUP => 1); -# Variables -my ($file1,$file2,$diff,$diffbase,$answer,$options,$infile,$append,$dirname,$cwd); -my (@files,@ldoptions,@tmpfiles,@ptmpfiles,@difffiles); # , - - -Getopt::Long::Configure('pass_through','bundling'); - -GetOptions('revision|r:s' => \@revs, - 'cvs' => \$cvs, - 'rcs' => \$rcs, - 'svn' => \$svn, - 'dir|d:s' => \$dir, - 'postscript|ps' => \$postscript, - 'pdf' => \$pdf, - 'force' => \$force, - 'version' => \$version, - 'help|h' => \$help); - -if ( $help ) { - pod2usage(1) ; -} - -if ( $version ) { - die "This is LATEXDIFF-VC 0.25\n" ; -} - -if ( $cvs ) { - $vc="CVS"; -} -if ( $rcs ) { - die "Cannot specify more than one of --cvs, --rcs or --svn." if ($vc); - $vc="RCS"; -} -if ( $svn ) { - die "Cannot specify more than one of --cvs, --rcs or --svn." if ($vc); - $vc="SVN"; -} - -# check whether the first file name got misinterpreted as an option to an empty -r option -if ( @revs && -f $revs[$#revs] ) { - unshift @ARGV,$revs[$#revs]; - $revs[$#revs]=""; -} -# check whether the first file name got misinterpreted as an option to an empty -d option -if ( defined($dir) && -f $dir ) { - unshift @ARGV,$dir; - $dir=""; -} - -$file2=pop @ARGV; -( defined($file2) && $file2 =~ /\.(tex|bbl)$/ ) or pod2usage("Must specify at least one tex or bbl file"); - -if (! $vc && scalar(@revs)>0 ) { - # have to guess $vc - # check whether we have a special name - if ( $0 =~ /-cvs$/ ) { - $vc="CVS"; - } elsif ( $0 =~ /-rcs$/ ) { - $vc="RCS"; - } elsif ( $0 =~ /-svn$/ ) { - $vc="SVN"; - } elsif ( -e "CVSROOT" || defined($ENV{"CVSROOT"}) ) { - print STDERR "Guess you are using CVS ...\n"; - $vc="CVS"; - } elsif ( -e "$file2,v" ) { - print STDERR "Guess you are using RCS ...\n"; - $vc="RCS"; - } elsif ( -d ".svn" ) { - print STDERR "Guess you are using SVN ...\n"; - $vc="SVN"; - } else { - print STDERR "Cannot figure out version control system, so I default to CVS\n"; - $vc="CVS"; - } -} - -if (defined($dir) && $dir=~/^\.\/?/ ) { - print STDERR "You wrote selected -dir=. but you do not really like to do that, do you ?\n"; - exit 10 -} - -if ( scalar(@revs)>0 ) { - if ( $vc eq "CVS" ) { - $diffcmd = "cvs diff -u -r"; - $patchcmd = "patch -R -p0"; - } elsif ( $vc eq "RCS" ) { - $diffcmd = "rcsdiff -u -r"; - $patchcmd = "patch -R -p0"; - } elsif ( $vc eq "SVN" ) { - $diffcmd = "svn diff -r "; - $patchcmd = "patch -R -p0"; - } else { - print STDERR "Unknown versioning system $vc \n"; - exit 10; - } -} - - -# make file list (last arguments), initial arguments have to be passed to latexdiff -# We assume an argument is a valid file rather than a latexdiff argument -# if it has extension .tex or .bbl - -@files=($file2); -while( $file1=pop @ARGV ) { - if ( $file1 =~ /\.(tex|bbl)$/ ) { - # $file1 looks like a valid file name and is prepended to file list - unshift @files, $file1 ; - } else { - # $file1 looks like an option for latexdiff, push it back to argument stack - unshift @ldoptions, $file1 ; - } -} - -if ( scalar(@revs) == 0 ) { - pod2usage("When -r option is not used, two .tex files (old and new) must be given on the command line") unless @files==2; - # compare two files - $file1=shift @files ; -} - -if ( scalar(@revs) == 2 ) { - $append = "-diff$revs[0]-$revs[1]"; -} elsif ( scalar(@revs) == 1 || $revs[0] ) { - $append = "-diff$revs[0]"; -} else { - $append = "-diff"; -} - -if ( defined ($dir) && ! $dir ) { - # bare -d option => choose directory name - ($dir=$append) =~ s/^-//; -} - -if ( ($vc eq "SVN" || $vc eq "CVS") && scalar(@revs)) { - length($revs[$#revs]) > 0 or $revs[$#revs]="HEAD"; - length($revs[0]) > 0 or $revs[0]="HEAD"; -} - -#exit ; - - -# cycle through all files - -@difffiles=(); -while ( $infile=$file2=shift @files ) { - print STDERR "Working on $infile \n"; - if ( scalar(@revs) == 1 ) { - ($file1=$infile) =~ s/\.(tex|bbl)/-oldtmp-$$.$1/ ; - push @tmpfiles,$file1; - # compare file with previous version ($revs[0]="") or specified version - system("$diffcmd$revs[0] $infile| $patchcmd -o$file1") ; - } elsif ( scalar(@revs) == 2 ) { - ($file1=$infile) =~ s/\.(tex|bbl)/-oldtmp-$$.$1/ ; - $file2 =~ s/\.(tex|bbl)/-newtmp-$$.$1/ ; - push @tmpfiles,$file2; - system("$diffcmd$revs[1] $infile | $patchcmd -o$file2") ; - system("$diffcmd$revs[0] $infile | $patchcmd -o$file1") ; - } - - if ( -z $file1 || -z $file2) { - print STDERR "One or both of the files to compare are empty. Possibly something went wrong in the retrieval of older versions. Aborting ...\n" ; - exit(10); - } - - # Get name of difference file - if ( defined($dir) ) { - $diff="$dir/$infile" ; - } else { - ($diff=$infile) =~ s/\.(tex|bbl)$/$append.$1/ ; - } - # make directories if needed - $dirname=dirname($diff) ; - system("mkdir -p $dirname") unless ( -e $dirname ); - - # Remaining options are passed to latexdiff - $options = join(" ",@ldoptions); - - if ( -e $diff && ! $force ) { - print STDERR "OK to overwrite existing file $diff (y/n)? "; - $answer = ; - unless ($answer =~ /^y/i ) { - unlink @tmpfiles; - die "Abort ... " ; - } - } - print "Running $latexdiff\n"; - unless ( system("$latexdiff $options $file1 $file2 > $diff") == 0 ) { - print STDERR "Something went wrong in $latexdiff. Deleting $diff and abort\n" ; unlink $diff ; exit(5) - }; - print "Generated difference file $diff\n"; - - if ( ( $postscript or $pdf ) and !( scalar(@revs) && greptex( qr/\\document(?:class|style)/ , $diff ) ) ) { - # save filename for later processing if postscript or pdf conversion is requested and either two-file mode was used (scalar(@revs)==0) or the diff file contains documentclass statement (ie. is a root document) - push @difffiles, $diff ; - } - - unlink @tmpfiles; -} - -foreach $diff ( @difffiles ) { - chomp($cwd=(`pwd`)); - if (defined($dir)) { - ( $diff =~ s/$dir\/?// ) ; - chdir $dir ; - } - @ptmpfiles=(); - ( $diffbase=$diff) =~ s/\.(tex)$// ; - - # adapt magically changebar styles to [pdftex] display driver if pdf output was selected - if ( $pdf ) { - system("sed \"s/Package\\[dvips\\]/Package[pdftex]/\" $diff > $diff.tmp$$ ; \\mv $diff.tmp$$ $diff"); - } - print STDERR "PDF: $pdf Postscript: $postscript cwd $cwd\n"; - - if ( system("grep -q \'^[^%]*\\\\bibliography\' $diff") == 0 ) { - if ( $postscript) { - system("latex --interaction=batchmode $diff; bibtex $diffbase"); - push @ptmpfiles, "$diffbase.bbl","$diffbase.bbl" ; - } elsif ( $pdf ) { - system("pdflatex --interaction=batchmode $diff; bibtex $diffbase"); - push @ptmpfiles, "$diffbase.bbl","$diffbase.bbl" ; - } - } - - if ( $postscript ) { - my $dvi="$diffbase.dvi"; - my $ps="$diffbase.ps"; - - system("latex --interaction=batchmode $diff; latex $diff; dvips -o $ps $dvi"); - push @ptmpfiles, "$diffbase.aux","$diffbase.log",$dvi ; - print "Generated postscript file $ps\n"; - } - elsif ( $pdf ) { - system("pdflatex --interaction=batchmode $diff; pdflatex $diff"); - push @ptmpfiles, "$diffbase.aux","$diffbase.log"; - } - unlink @ptmpfiles; - chdir $cwd; -} - -# greptex returns 1 if regex is not matched in filename -# 0 if there is a match -sub greptex { - my ($regex,$filename)=@_; - my ($i)=0; - open (FH, $filename) or die("Couldn't open $filename: $!"); - while () { - next if /^\s*%/; # skip comment lines - if ( m/$regex/ ) { - close(FH); - return(0); - } - # only scan 25 lines - $i++; - last if $i>25 ; - } - close(FH); - return(1); -} - - -=head1 NAME - -latexdiff-vc - wrapper script that calls latexdiff for different versions of a file under version management (CVS, RCS or SVN) - -=head1 SYNOPSIS - -B [ F ] [ F ] B<-r> [F] [B<-r> F] F [ F ...] - - or - -B [ F ] [ F ][ B<--postscript> | B<--pdf> ] F F - -=head1 DESCRIPTION - -I is a wrapper script that applies I to a -file, or multiple files under version control (CVS or RCS), and optionally runs the -sequence of C and C or C commands necessary to -produce pdf or postscript output of the difference tex file(s). It can -also be applied to a pair of files to automatise the generation of difference -file in postscript or pdf format. - -=head1 OPTIONS - -=over 4 - -=item B<--rcs>, B<--svn>, or B<--cvs> - -Set the version system. -If no version system is specified, latexdiff-vc will venture a guess. - -latexdiff-cvs and latexdiff-rcs are variants of latexdiff-vc which default to -the respective versioning system. However, this default can still be overridden using the options above. - -=item B<-r>, B<-r> F or B<--revision>, B<--revision=>F - -Choose revision (under RCS, CVS or SVN). One or two B<-r> options can be -specified, and the resulting in different behaviour: - -=over 4 - -=item B -r F ... - -compares F with the most recent version checked into RCS. - -=item B -r F F ... - -compares F with revision F. - -=item B -r F -r F F ... - -compares revisions F and F of F. - -Multiple files can be specified for all of the above options. All files must have the -extension C<.tex>, though. - -=item B F F - -compares two files. - -=back - -The name of the difference file is generated automatically and -reported to stdout. - -=item B<-d> or B<--dir> B<-d> F or B<--dir=>F - -Rather than appending the string C and optionally the version -numbers given to the output-file, this will prepend a directory name C -to the -original filename, creating the directory and subdirectories should they not exist already. This is particularly useful in order to clone a -complete directory hierarchy. Optionally, a pathname F can be specified, which is prepended instead of C. - -=item B<--ps> or B<--postscript> - -Generate postscript output from difference file. This will run the -sequence C on the difference file (do not use -this option in the rare cases, where three C commands are -required if you care about correct referencing). If the difference -file contains a C<\bibliography> tag, run the sequence C. - -=item B<--pdf> - -Generate pdf output from difference file using C. This will -run the sequence C on the difference file, or -C for files requiring bibtex. - -=item B<--force> - -Overwrite existing diff files without asking for confirmation. Default -behaviour is to ask for confirmation before overwriting an existing difference -file. - -=item B<--help> or -B<-h> - -Show help text - -=item B<--version> - -Show version number - -=back - -All other options are passed on to C. - -=head1 SEE ALSO - -L - -=head1 PORTABILITY - -I uses external commands and is therefore -limited to Unix-like systems. It also requires the RCS version control -system and latex to be installed on the system. Modules from Perl 5.8 -or higher are required. - - -=head1 AUTHOR - -Copyright (C) 2005 Frederik Tilmann - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License Version 2 -Contributors: S Utcke, H Bruyninckx - -=cut - diff --git a/Master/texmf-dist/scripts/latexdiff/latexdiff-vc.pl b/Master/texmf-dist/scripts/latexdiff/latexdiff-vc.pl new file mode 100755 index 00000000000..3e9a3f246de --- /dev/null +++ b/Master/texmf-dist/scripts/latexdiff/latexdiff-vc.pl @@ -0,0 +1,430 @@ +#!/usr/bin/perl -w +# Place the following 2 lines at beginning to make script independent of location of perl +#eval 'exec perl -w -S $0 ${1+"$@"}' +# if 0; # not running under some shell +# +# latexdiff-vc - wrapper script for applying latexdiff to rcs managed files +# and for automatised creation of postscript or pdf from difference file +# +# Copyright (C) 2005 F J Tilmann (tilmann@esc.cam.ac.uk) +# +# Contributors: S Utcke, H Bruyninckx +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License Version 2 as published by +# the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Detailed usage information at the end of the file +# +# version 0.25: +# - bbl is allowed as alternative extension (instead of .tex) +# +use Getopt::Long ; +use Pod::Usage qw/pod2usage/ ; +use File::Temp qw/tempdir/ ; +use File::Basename qw/dirname/; +use strict ; + +# Option names +my ($version,$help,$postscript,$pdf,$force,$dir,$cvs,$rcs,$svn,$diffcmd,$patchcmd,@revs); +# Preset Variables +my $latexdiff="latexdiff"; # Program for making the comparison +my $vc=""; +my $tempdir=tempdir(CLEANUP => 1); +# Variables +my ($file1,$file2,$diff,$diffbase,$answer,$options,$infile,$append,$dirname,$cwd); +my (@files,@ldoptions,@tmpfiles,@ptmpfiles,@difffiles); # , + + +Getopt::Long::Configure('pass_through','bundling'); + +GetOptions('revision|r:s' => \@revs, + 'cvs' => \$cvs, + 'rcs' => \$rcs, + 'svn' => \$svn, + 'dir|d:s' => \$dir, + 'postscript|ps' => \$postscript, + 'pdf' => \$pdf, + 'force' => \$force, + 'version' => \$version, + 'help|h' => \$help); + +if ( $help ) { + pod2usage(1) ; +} + +if ( $version ) { + die "This is LATEXDIFF-VC 0.25\n" ; +} + +if ( $cvs ) { + $vc="CVS"; +} +if ( $rcs ) { + die "Cannot specify more than one of --cvs, --rcs or --svn." if ($vc); + $vc="RCS"; +} +if ( $svn ) { + die "Cannot specify more than one of --cvs, --rcs or --svn." if ($vc); + $vc="SVN"; +} + +# check whether the first file name got misinterpreted as an option to an empty -r option +if ( @revs && -f $revs[$#revs] ) { + unshift @ARGV,$revs[$#revs]; + $revs[$#revs]=""; +} +# check whether the first file name got misinterpreted as an option to an empty -d option +if ( defined($dir) && -f $dir ) { + unshift @ARGV,$dir; + $dir=""; +} + +$file2=pop @ARGV; +( defined($file2) && $file2 =~ /\.(tex|bbl)$/ ) or pod2usage("Must specify at least one tex or bbl file"); + +if (! $vc && scalar(@revs)>0 ) { + # have to guess $vc + # check whether we have a special name + if ( $0 =~ /-cvs$/ ) { + $vc="CVS"; + } elsif ( $0 =~ /-rcs$/ ) { + $vc="RCS"; + } elsif ( $0 =~ /-svn$/ ) { + $vc="SVN"; + } elsif ( -e "CVSROOT" || defined($ENV{"CVSROOT"}) ) { + print STDERR "Guess you are using CVS ...\n"; + $vc="CVS"; + } elsif ( -e "$file2,v" ) { + print STDERR "Guess you are using RCS ...\n"; + $vc="RCS"; + } elsif ( -d ".svn" ) { + print STDERR "Guess you are using SVN ...\n"; + $vc="SVN"; + } else { + print STDERR "Cannot figure out version control system, so I default to CVS\n"; + $vc="CVS"; + } +} + +if (defined($dir) && $dir=~/^\.\/?/ ) { + print STDERR "You wrote selected -dir=. but you do not really like to do that, do you ?\n"; + exit 10 +} + +if ( scalar(@revs)>0 ) { + if ( $vc eq "CVS" ) { + $diffcmd = "cvs diff -u -r"; + $patchcmd = "patch -R -p0"; + } elsif ( $vc eq "RCS" ) { + $diffcmd = "rcsdiff -u -r"; + $patchcmd = "patch -R -p0"; + } elsif ( $vc eq "SVN" ) { + $diffcmd = "svn diff -r "; + $patchcmd = "patch -R -p0"; + } else { + print STDERR "Unknown versioning system $vc \n"; + exit 10; + } +} + + +# make file list (last arguments), initial arguments have to be passed to latexdiff +# We assume an argument is a valid file rather than a latexdiff argument +# if it has extension .tex or .bbl + +@files=($file2); +while( $file1=pop @ARGV ) { + if ( $file1 =~ /\.(tex|bbl)$/ ) { + # $file1 looks like a valid file name and is prepended to file list + unshift @files, $file1 ; + } else { + # $file1 looks like an option for latexdiff, push it back to argument stack + unshift @ldoptions, $file1 ; + } +} + +if ( scalar(@revs) == 0 ) { + pod2usage("When -r option is not used, two .tex files (old and new) must be given on the command line") unless @files==2; + # compare two files + $file1=shift @files ; +} + +if ( scalar(@revs) == 2 ) { + $append = "-diff$revs[0]-$revs[1]"; +} elsif ( scalar(@revs) == 1 || $revs[0] ) { + $append = "-diff$revs[0]"; +} else { + $append = "-diff"; +} + +if ( defined ($dir) && ! $dir ) { + # bare -d option => choose directory name + ($dir=$append) =~ s/^-//; +} + +if ( ($vc eq "SVN" || $vc eq "CVS") && scalar(@revs)) { + length($revs[$#revs]) > 0 or $revs[$#revs]="HEAD"; + length($revs[0]) > 0 or $revs[0]="HEAD"; +} + +#exit ; + + +# cycle through all files + +@difffiles=(); +while ( $infile=$file2=shift @files ) { + print STDERR "Working on $infile \n"; + if ( scalar(@revs) == 1 ) { + ($file1=$infile) =~ s/\.(tex|bbl)/-oldtmp-$$.$1/ ; + push @tmpfiles,$file1; + # compare file with previous version ($revs[0]="") or specified version + system("$diffcmd$revs[0] $infile| $patchcmd -o$file1") ; + } elsif ( scalar(@revs) == 2 ) { + ($file1=$infile) =~ s/\.(tex|bbl)/-oldtmp-$$.$1/ ; + $file2 =~ s/\.(tex|bbl)/-newtmp-$$.$1/ ; + push @tmpfiles,$file2; + system("$diffcmd$revs[1] $infile | $patchcmd -o$file2") ; + system("$diffcmd$revs[0] $infile | $patchcmd -o$file1") ; + } + + if ( -z $file1 || -z $file2) { + print STDERR "One or both of the files to compare are empty. Possibly something went wrong in the retrieval of older versions. Aborting ...\n" ; + exit(10); + } + + # Get name of difference file + if ( defined($dir) ) { + $diff="$dir/$infile" ; + } else { + ($diff=$infile) =~ s/\.(tex|bbl)$/$append.$1/ ; + } + # make directories if needed + $dirname=dirname($diff) ; + system("mkdir -p $dirname") unless ( -e $dirname ); + + # Remaining options are passed to latexdiff + $options = join(" ",@ldoptions); + + if ( -e $diff && ! $force ) { + print STDERR "OK to overwrite existing file $diff (y/n)? "; + $answer = ; + unless ($answer =~ /^y/i ) { + unlink @tmpfiles; + die "Abort ... " ; + } + } + print "Running $latexdiff\n"; + unless ( system("$latexdiff $options $file1 $file2 > $diff") == 0 ) { + print STDERR "Something went wrong in $latexdiff. Deleting $diff and abort\n" ; unlink $diff ; exit(5) + }; + print "Generated difference file $diff\n"; + + if ( ( $postscript or $pdf ) and !( scalar(@revs) && greptex( qr/\\document(?:class|style)/ , $diff ) ) ) { + # save filename for later processing if postscript or pdf conversion is requested and either two-file mode was used (scalar(@revs)==0) or the diff file contains documentclass statement (ie. is a root document) + push @difffiles, $diff ; + } + + unlink @tmpfiles; +} + +foreach $diff ( @difffiles ) { + chomp($cwd=(`pwd`)); + if (defined($dir)) { + ( $diff =~ s/$dir\/?// ) ; + chdir $dir ; + } + @ptmpfiles=(); + ( $diffbase=$diff) =~ s/\.(tex)$// ; + + # adapt magically changebar styles to [pdftex] display driver if pdf output was selected + if ( $pdf ) { + system("sed \"s/Package\\[dvips\\]/Package[pdftex]/\" $diff > $diff.tmp$$ ; \\mv $diff.tmp$$ $diff"); + } + print STDERR "PDF: $pdf Postscript: $postscript cwd $cwd\n"; + + if ( system("grep -q \'^[^%]*\\\\bibliography\' $diff") == 0 ) { + if ( $postscript) { + system("latex --interaction=batchmode $diff; bibtex $diffbase"); + push @ptmpfiles, "$diffbase.bbl","$diffbase.bbl" ; + } elsif ( $pdf ) { + system("pdflatex --interaction=batchmode $diff; bibtex $diffbase"); + push @ptmpfiles, "$diffbase.bbl","$diffbase.bbl" ; + } + } + + if ( $postscript ) { + my $dvi="$diffbase.dvi"; + my $ps="$diffbase.ps"; + + system("latex --interaction=batchmode $diff; latex $diff; dvips -o $ps $dvi"); + push @ptmpfiles, "$diffbase.aux","$diffbase.log",$dvi ; + print "Generated postscript file $ps\n"; + } + elsif ( $pdf ) { + system("pdflatex --interaction=batchmode $diff; pdflatex $diff"); + push @ptmpfiles, "$diffbase.aux","$diffbase.log"; + } + unlink @ptmpfiles; + chdir $cwd; +} + +# greptex returns 1 if regex is not matched in filename +# 0 if there is a match +sub greptex { + my ($regex,$filename)=@_; + my ($i)=0; + open (FH, $filename) or die("Couldn't open $filename: $!"); + while () { + next if /^\s*%/; # skip comment lines + if ( m/$regex/ ) { + close(FH); + return(0); + } + # only scan 25 lines + $i++; + last if $i>25 ; + } + close(FH); + return(1); +} + + +=head1 NAME + +latexdiff-vc - wrapper script that calls latexdiff for different versions of a file under version management (CVS, RCS or SVN) + +=head1 SYNOPSIS + +B [ F ] [ F ] B<-r> [F] [B<-r> F] F [ F ...] + + or + +B [ F ] [ F ][ B<--postscript> | B<--pdf> ] F F + +=head1 DESCRIPTION + +I is a wrapper script that applies I to a +file, or multiple files under version control (CVS or RCS), and optionally runs the +sequence of C and C or C commands necessary to +produce pdf or postscript output of the difference tex file(s). It can +also be applied to a pair of files to automatise the generation of difference +file in postscript or pdf format. + +=head1 OPTIONS + +=over 4 + +=item B<--rcs>, B<--svn>, or B<--cvs> + +Set the version system. +If no version system is specified, latexdiff-vc will venture a guess. + +latexdiff-cvs and latexdiff-rcs are variants of latexdiff-vc which default to +the respective versioning system. However, this default can still be overridden using the options above. + +=item B<-r>, B<-r> F or B<--revision>, B<--revision=>F + +Choose revision (under RCS, CVS or SVN). One or two B<-r> options can be +specified, and the resulting in different behaviour: + +=over 4 + +=item B -r F ... + +compares F with the most recent version checked into RCS. + +=item B -r F F ... + +compares F with revision F. + +=item B -r F -r F F ... + +compares revisions F and F of F. + +Multiple files can be specified for all of the above options. All files must have the +extension C<.tex>, though. + +=item B F F + +compares two files. + +=back + +The name of the difference file is generated automatically and +reported to stdout. + +=item B<-d> or B<--dir> B<-d> F or B<--dir=>F + +Rather than appending the string C and optionally the version +numbers given to the output-file, this will prepend a directory name C +to the +original filename, creating the directory and subdirectories should they not exist already. This is particularly useful in order to clone a +complete directory hierarchy. Optionally, a pathname F can be specified, which is prepended instead of C. + +=item B<--ps> or B<--postscript> + +Generate postscript output from difference file. This will run the +sequence C on the difference file (do not use +this option in the rare cases, where three C commands are +required if you care about correct referencing). If the difference +file contains a C<\bibliography> tag, run the sequence C. + +=item B<--pdf> + +Generate pdf output from difference file using C. This will +run the sequence C on the difference file, or +C for files requiring bibtex. + +=item B<--force> + +Overwrite existing diff files without asking for confirmation. Default +behaviour is to ask for confirmation before overwriting an existing difference +file. + +=item B<--help> or +B<-h> + +Show help text + +=item B<--version> + +Show version number + +=back + +All other options are passed on to C. + +=head1 SEE ALSO + +L + +=head1 PORTABILITY + +I uses external commands and is therefore +limited to Unix-like systems. It also requires the RCS version control +system and latex to be installed on the system. Modules from Perl 5.8 +or higher are required. + + +=head1 AUTHOR + +Copyright (C) 2005 Frederik Tilmann + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License Version 2 +Contributors: S Utcke, H Bruyninckx + +=cut + diff --git a/Master/texmf-dist/scripts/latexdiff/latexrevise b/Master/texmf-dist/scripts/latexdiff/latexrevise deleted file mode 100755 index 279dac1fc6a..00000000000 --- a/Master/texmf-dist/scripts/latexdiff/latexrevise +++ /dev/null @@ -1,523 +0,0 @@ -#!/usr/bin/perl -w -# latexrevise - takes output file of latexdiff and removes either discarded -# or appended passages, then deletes all other latexdiff markup -# -# Copyright (C) 2004 F J Tilmann (tilmann@esc.cam.ac.uk) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License Version 2 as published by -# the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Detailed usage information at the end of the file -# -# Version 0.1 First public release -# Version 0.3 Updated for compatibility with latexdiff 0.3 output (DIFAUXCMD removal) -# - -use Getopt::Long ; -use strict; - -# Markup strings (make sure that this are set to the same value as in -# latexdiff) -# If at all possible, do not change these as parts of the program -# depend on the actual name. -# At the very least adapt subroutine postprocess to new tokens. - -# note: have to use three backslashes to mean one literal one (reason -# unknown -my $ADDMARKOPEN='\\\DIFaddbegin(?:FL)? '; # Token to mark begin of appended text -my $ADDMARKCLOSE='\\\DIFaddend(?:FL)?(?: |\z)'; # Token to mark end of appended text (|\z only deals with the case of \DIFaddend right before \end{document} -my $ADDOPEN='\\\DIFadd(?:FL)?{'; # To mark begin of added text passage -my $ADDCLOSE='}'; # To mark end of added text passage -my $ADDCOMMENT='DIF > '; # To mark added comment line -my $DELMARKOPEN='\\\DIFdelbegin(?:FL)? '; # Token to mark begin of deleted text -my $DELMARKCLOSE='\\\DIFdelend(?:FL)?(?: |\z)'; # Token to mark end of deleted text -my $DELOPEN='\\\DIFdel(?:FL)?{'; # To mark begin of deleted text passage -my $DELCLOSE='}'; # To mark end of deleted text passage -my $ALTEXT='FL'; # string which might be appended to above commands -my $DELCMDOPEN='%DIFDELCMD < '; # To mark begin of deleted commands (must begin with %, i.e., be a comment -my $DELCMDCLOSE="%%%\n"; # To mark end of deleted commands (must end with a new line) -my $AUXCMD='%DIFAUXCMD' ; # follows auxiliary commands put in by latexdiff to make difference file legal -my $DELCOMMENT='DIF < '; # To mark deleted comment line - -my $PREAMBLEXTBEG='^%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF$'; -my $PREAMBLEXTEND='^%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF$'; - - -my $pat0 = '(?:[^{}]|\\\{|\\\})*'; -my $pat1 = '(?:[^{}]|\\\{|\\\}|\{'.$pat0.'\})*'; -my $pat2 = '(?:[^{}]|\\\{|\\\}|\{'.$pat1.'\})*'; -my $pat3 = '(?:[^{}]|\\\{|\\\}|\{'.$pat2.'\})*'; -my $pat4 = '(?:[^{}]|\\\{|\\\}|\{'.$pat3.'\})*'; -my $brat0 = '(?:[^\[\]]|\\\[|\\\])*'; - - -my ($input,$preamble,$body,$post); -my (@matches); -my ($cnt,$prematch,$postmatch); -my ($help); -my ($verbose,$quiet,$accept,$decline,$simplify)=(0,0,0,0,0); -my ($comment,$comenv,$markup,$markenv); - -# A word unlikely ever to be used in a real latex file -my $someword='gobbledegooksygook'; - -Getopt::Long::Configure('bundling'); -GetOptions('accept|a' => \$accept, - 'decline|d'=> \$decline, - 'simplify|s' => \$simplify, - 'comment|c=s' => \$comment, - 'comment-environment|e=s' => \$comenv, - 'markup|m=s' => \$markup, - 'markup-environment|n=s' => \$markenv, - 'no-warnings|q' => \$verbose, - 'verbose|V' => \$verbose, - 'help|h|H' => \$help); - -if ( $help ) { - usage() ; -} - -if ( ($accept && $decline) || ($accept && $simplify) || ($decline && $simplify) ) { - die '-a,-d and -s options are mutually axclusive. Type latexrevise -h to get more help.'; -} - - - -print STDERR "ACCEPT mode\n" if $verbose && $accept; -print STDERR "DECLINE mode\n" if $verbose && $decline; -print STDERR "SIMPLIFY mode. WARNING: The output will not normally be valid latex,\n" if $verbose && $simplify; - -# Slurp old and new files -{ - local $/ ; # locally set record operator to undefined, ie. enable whole-file mode - $input=<>; -} - -# split into parts -($preamble,$body,$post)=splitdoc($input,'\begin{document}','\end{document}'); - -if (length $preamble && ( $accept || $decline ) ) { - # - # WORK ON PREAMBLE - # - # (compare subroutine linediff in latexdiff to make sure correct strings are used) - - # remove extra commands added to preamble by latexdiff - $preamble =~ s/${PREAMBLEXTBEG}.*?${PREAMBLEXTEND}\n{0,1}//smg ; - - if ( $accept ) { - # delete mark up in appended lines - $preamble =~ s/^(.*) %DIF > $/$1/mg ; - } elsif ( $decline ) { - # delete appended lines - # $preamble =~ s/^(.*) %DIF > $//mg ; - $preamble =~ s/^(.*) %DIF > \n//mg ; - # delete markup in deleted lines - $preamble =~ s/^%DIF < //mg ; - } - # remove any remaining DIF markups - #$preamble =~ s/%DIF.*$//mg ; - $preamble =~ s/%DIF.*?\n//sg ; -} -#print $preamble ; - -# -# WORK ON BODY -# -if ($accept) { - # remove ADDMARKOPEN, ADDMARKCLOSE tokens - @matches= $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/sg; - checkpure(@matches); - $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/$1/sg; - # remove text flanked by DELMARKOPEN, DELMARKCLOSE tokens - @matches= $body =~ m/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/sg; - checkpure(@matches); - $body =~ s/${DELMARKOPEN}(.*?)${DELMARKCLOSE}//sg; - # remove markup of added comments - $body =~ s/%${ADDCOMMENT}(.*?)$/%$1/mg ; - # remove deleted comments (full line) - $body =~ s/^%${DELCOMMENT}.*?\n//mg ; - # remove deleted comments (part of line) - $body =~ s/%${DELCOMMENT}.*?$//mg ; -} -elsif ( $decline) { - # remove DELMARKOPEN, DELMARKCLOSE tokens - @matches= $body =~ m/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/sg; - checkpure(@matches); - $body =~ s/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/$1/sg; - # remove text flanked by ADDMARKOPEN, ADDMARKCLOSE tokens - # as latexdiff algorithm keeps the formatting and white spaces - # of the new text, sometimes whitespace might be inserted or - # removed inappropriately. We try to guess whether this has - # happened - - # Mop up tokens. This must be done already now as otherwise - # detection of white-space problems does not work - $cnt = $body =~ s/${DELOPEN}($pat4)${DELCLOSE}/$1/sg; - # remove markup of deleted commands - $cnt += $body =~ s/${DELCMDOPEN}(.*?)${DELCMDCLOSE}/$1/sg ; - $cnt += $body =~ s/${DELCMDOPEN}//g ; - # remove aux commands - $cnt += $body =~ s/^.*${AUXCMD}$/${someword}/mg; $body =~ s/${someword}\n//g; - - while ( $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/s ) { - $prematch=$`; - $postmatch=$'; - checkpure($1); - if ( $prematch =~ /\w$/s && $postmatch =~ /^\w/ ) { - # apparently no white-space between word=>Insert white space - $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/ /s ; - } - elsif ( $prematch =~ /\s$/s && $postmatch =~ /^[.,;:]/ ) { - # space immediately before one of ".,:;" => remove this space - $body =~ s/\s${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//s ; - } - else { - # do not insert or remove any extras - $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//s; - } - } -# Alternative without special cases treatment -# @matches= $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/sg; -# checkpure(@matches); -# $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//sg; - # remove markup of deleted comments - $body =~ s/%${DELCOMMENT}(.*?)$/%$1/mg ; - # remove added comments (full line) - $body =~ s/^%${ADDCOMMENT}.*?\n//mg ; - # remove added comments (part of line) - $body =~ s/%${ADDCOMMENT}.*?$//mg ; -} - -# remove any remaining tokens -if ( $accept || $decline || $simplify ) { - # first substitution command deals with special case of added paragraph - $cnt = $body =~ s/${ADDOPEN}($pat4)\n${ADDCLOSE}\n/$1\n/sg; - $cnt += $body =~ s/${ADDOPEN}($pat4)${ADDCLOSE}/$1/sg; - $cnt==0 || warn 'Remaining $ADDOPEN tokens in DECLINE mode\n' unless ( $quiet || $accept || $simplify ); -} -if ($accept || $simplify ) { - # Note: in decline mode these commands have already been removed above - $cnt = $body =~ s/${DELOPEN}($pat4)${DELCLOSE}/$1/sg; - #### remove markup of deleted commands - $cnt += $body =~ s/${DELCMDOPEN}(.*?)${DELCMDCLOSE}/$1/sg ; - $cnt += $body =~ s/${DELCMDOPEN}//g ; - # remove aux commands - # $cnt += - $body =~ s/^.*${AUXCMD}$/${someword}/mg; $body =~ s/${someword}\n//g; - - #### remove deleted comments - ###$cnt += $body =~ s/${DIFDELCMD}.*?$//mg ; - $cnt==0 || warn 'Remaining $DELOPEN or $DIFDELCMD tokens in ACCEPT mode\n' unless ( $quiet || $simplify ); -} - -# Remove comment commands -if (defined($comment)) { - print STDERR "Removing \\$comment\{..\} sequences ..." if $verbose; - # protect $comments in comments by making them look different - $body =~ s/(%.*)${comment}(.*)$/$1${someword}$2/mg ; - # carry out the substitution - $cnt = 0 + $body =~ s/\\${comment}(?:\[${brat0}\])?\{${pat4}\}//sg ; - print STDERR "$cnt matches found and removed.\n" if $verbose; - # and undo the protection substitution - $body =~ s/(%.*)${someword}(.*)$/$1${comment}$2/mg ; -} -if (defined($comenv)) { - print STDERR "Removing $comenv environments ..." if $verbose; - $body =~ s/(%.*)${comenv}/$1${someword}/mg ; -## $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{\$comenv\}.*?\\end\{\$comenv\}//sg ; - $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{${comenv}\}.*?\\end\{${comenv}\}\s*?\n//sg ; - print STDERR "$cnt matches found and removed.\n" if $verbose; - $body =~ s/(%.*)${someword}/$1${comenv}/mg ; -} - -if (defined($markup)) { - print STDERR "Removing \\$markup\{..\} cpmmands ..." if $verbose; - # protect $markups in comments by making them look different - $body =~ s/(%.*)${markup}(.*)$/$1${someword}$2/mg ; - # carry out the substitution - $cnt = 0 + $body =~ s/\\${markup}(?:\[${brat0}\])?\{(${pat4})\}/$1/sg ; - print STDERR "$cnt matches found and removed.\n" if $verbose; - # and undo the protection substitution - $body =~ s/(%.*)${someword}(.*)$/$1${markup}$2/mg ; -} -if (defined($markenv)) { - print STDERR "Removing $markenv environments ..." if $verbose; - $body =~ s/(%.*)${markenv}/$1${someword}/mg ; - $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{${markenv}\}\n?//sg; - $cnt += 0 + $body =~ s/\\end\{${markenv}\}\n?//sg; - print STDERR $cnt/2, " matches found and removed.\n" if $verbose; - $body =~ s/(%.*)${someword}/$1${markenv}/mg ; -} - - -if ( length $preamble ) { - print "$preamble\\begin{document}${body}\\end{document}$post"; -} else { - print $body; -} - -# checkpure(@matches) -# checks whether any of the strings in matches contains -# $ADDMARKOPEN, $ADDMARKCLOSE,$DELMARKOPEN, or $DELMARKCLOSE -# If so, die reporting nesting problems, otherwise return to caller -sub checkpure { - while (defined($_=shift)) { - if ( /$ADDMARKOPEN/ || /$ADDMARKCLOSE/ - || /$DELMARKOPEN/ || /$DELMARKCLOSE/ ) { - die <=0 && $j>$i ) { - $part1 = substr($text,0,$i) ; - $part2 = substr($text,$i+$l1,$j-$i-$l1); - $part3 = substr($text,$j+$l2) unless $j+$l2 >= length $text; - } else { - die "$word1 or $word2 not in the correct order or not present as a pair." - } - return ($part1,$part2,$part3); -} - - - -sub usage { - die <<"EOF"; -Usage: $0 [OPTIONS] [diff.tex] > revised.tex - -Read a file diff.tex (output of latexdiff), and remove its markup. -If no filename is given read from standard input. The command can be used -in ACCEPT, DECLINE, or SIMPLIFY mode, and be used to remove user-defined -latex commands from the input (see options -c, -e, -m, -n below). -In ACCEPT mode, all appended text fragments (or preamble lines) -are kept, and all discarded text fragments (or preamble lines) are -deleted. -In DECLINE mode, all discarded text fragments are kept, and all appended -text fragments are deleted. -If you wish to keep some changes, edit the diff.tex file in -advance, and manually remove those tokens which would otherwise be -deleted. Note that latexrevise only pays attention to the \\DIFaddbegin, -\\DIFaddend, \\DIFdelbegin, and \\DIFdelend tokens and corresponding FL -varieties. All \\DIFadd and \\DIFdel commands (but not their content) are -simply deleted. The commands added by latexdiff to the preamble are also -removed. -In SIMPLIFY mode all latexdiff markup is removed from the body of the text (after -\\begin{document}) except for \\DIFaddbegin, \\DIFaddend, \\DIFdelbegin, \\DIFdelend -tokens and the corresponding FL varieties of those commands. The result -will not in general be valid latex-code but might be easier to read and edit in -preparation for a subsequent run in ACCEPT or DECLINE mode. -In SIMPLIFY mode the preamble is left unmodified. - --a ---accept Run in ACCEPT mode (delete all blocks marked by \\DIFdelbegin - and \\DIFdelend). - --d ---decline Run in DECLINE mode (delete all blocks marked by \\DIFaddbegin - and \\DIFaddend). - --s ---simplify Run in SIMPLIFY mode (Keep all \\DIFaddbegin, \\DIFaddend, - \\DIFdelbegin, \\DIFdelend tokens, but remove all other latexdiff - markup from body. - -Note that the three mode options are mutually exclusive. If no mode option is given, -latexrevise simply removes user annotations and markup according to the following four -options. - - --c cmd ---comment=cmd Remove \\cmd{...}. cmd is supposed to mark some explicit - anotations which should be removed from the file before - release. - --e envir ---comment-environment=envir - Remove explicit annotation environments from the text, i.e. remove - \\begin{envir} - ... - \\end{envir} - blocks. - --m cmd ---markup=cmd Remove the markup command cmd but leave its argument, i.e. - turn \\cmd{abc} into abc. - --n envir ---markup-environment=envir - Similarly, remove \\begin{envir} and \\end{envir} commands, - but leave content of the environment in the text. - --q ---no-warnings Do not warn users about \\DIDadd{..} or \\DIFdel statements - which should not be there anymore - --V ---verbose Verbose output - -EOF -} - -=head1 NAME - -latexrevise - selectively remove markup and text from latexdiff output - -=head1 SYNOPSIS - -B [ B ] [ F ] > F - -=head1 DESCRIPTION - -I reads a file C (output of I), and remove the markup commands. -If no filename is given the input is read from standard input. The command can be used -in I, I, or I mode, or can be used to remove user-defined -latex commands from the input (see B<-c>, B<-e>, B<-m>, and B<-n> below). -In I mode, all appended text fragments (or preamble lines) -are kept, and all discarded text fragments (or preamble lines) are -deleted. -In I mode, all discarded text fragments are kept, and all appended -text fragments are deleted. -If you wish to keep some changes, edit the diff.tex file in -advance, and manually remove those tokens which would otherwise be -deleted. Note that I only pays attention to the C<\DIFaddbegin>, -C<\DIFaddend>, C<\DIFdelbegin>, and C<\DIFdelend> tokens and corresponding FL -varieties. All C<\DIFadd> and C<\DIFdel> commands (but not their contents) are -simply deleted. The commands added by latexdiff to the preamble are also -removed. -In I mode, C<\DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend> -tokens and their corresponding C varieties are kept but all other markup (e.g. C and <\DIFdel>) is removed. The result -will not in general be valid latex-code but it will be easier to read and edit in -preparation for a subsequent run in I or I mode. -In I mode the preamble is left unmodified. - -=head1 OPTIONS - -=over 4 - -=item B<-a> or B<--accept> - -Run in I mode (delete all blocks marked by C<\DIFdelbegin> and C<\DIFdelend>). - -=item B<-d> or B<--decline> - -Run in I mode (delete all blocks marked by C<\DIFaddbegin> -and C<\DIFaddend>). - -=item B<-s> or B<--simplify> - -Run in I mode (Keep all C<\DIFaddbegin>, C<\DIFaddend>, -C<\DIFdelbegin>, C<\DIFdelend> tokens, but remove all other latexdiff -markup from body). - -=back - -Note that the three mode options are mutually exclusive. If no mode option is given, -I simply removes user annotations and markup according to the following four -options. - -=over 4 - -=item B<-c cmd> or B<--comment=cmd> - -Remove C<\cmd{...}> sequences. C is supposed to mark some explicit -anotations which should be removed from the file before -release. - -=item B<-e envir> or B<--comment-environment=envir> - -Remove explicit annotation environments from the text, i.e. remove - - \begin{envir} - ... - \end{envir} - -blocks. - -=item B<-m cmd> or B<--markup=cmd> - -Remove the markup command C<\cmd> but leave its argument, i.e. -turn C<\cmd{abc}> into C. - -=item B<-n envir> or B<--markup-environment=envir> - -Similarly, remove C<\begin{envir}> and C<\end{envir}> commands but -leave content of the environment in the text. - - -=item B<-V> or B<--verbose> - -Verbose output - -=item B<-q> or B<--no-warnings> - -Do not warn users about C<\DIDadd{..}> or C<\DIFdel{..}> statements -which should have been removed already. - -=back - -=head1 BUGS - -The current version is a beta version which has not yet been -extensively tested, but worked fine locally. Please send bug reports -to I. Include the serial number of I -(from comments at the top of the source). If you come across latexdiff -output which is not processed correctly by I please include the -problem file as well as the old and new files on which it is based, -ideally edited to only contain the offending passage as long as that still -reproduces the problem. - -I gets confused by commented C<\begin{document}> or -C<\end{document}> statements - -=head1 SEE ALSO - -L - -=head1 PORTABILITY - -I does not make use of external commands and thus should run -on any platform supporting PERL v5 or higher. - -=head1 AUTHOR - -Copyright (C) 2004 Frederik Tilmann - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License Version 2 - -=cut diff --git a/Master/texmf-dist/scripts/latexdiff/latexrevise.pl b/Master/texmf-dist/scripts/latexdiff/latexrevise.pl new file mode 100755 index 00000000000..279dac1fc6a --- /dev/null +++ b/Master/texmf-dist/scripts/latexdiff/latexrevise.pl @@ -0,0 +1,523 @@ +#!/usr/bin/perl -w +# latexrevise - takes output file of latexdiff and removes either discarded +# or appended passages, then deletes all other latexdiff markup +# +# Copyright (C) 2004 F J Tilmann (tilmann@esc.cam.ac.uk) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License Version 2 as published by +# the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Detailed usage information at the end of the file +# +# Version 0.1 First public release +# Version 0.3 Updated for compatibility with latexdiff 0.3 output (DIFAUXCMD removal) +# + +use Getopt::Long ; +use strict; + +# Markup strings (make sure that this are set to the same value as in +# latexdiff) +# If at all possible, do not change these as parts of the program +# depend on the actual name. +# At the very least adapt subroutine postprocess to new tokens. + +# note: have to use three backslashes to mean one literal one (reason +# unknown +my $ADDMARKOPEN='\\\DIFaddbegin(?:FL)? '; # Token to mark begin of appended text +my $ADDMARKCLOSE='\\\DIFaddend(?:FL)?(?: |\z)'; # Token to mark end of appended text (|\z only deals with the case of \DIFaddend right before \end{document} +my $ADDOPEN='\\\DIFadd(?:FL)?{'; # To mark begin of added text passage +my $ADDCLOSE='}'; # To mark end of added text passage +my $ADDCOMMENT='DIF > '; # To mark added comment line +my $DELMARKOPEN='\\\DIFdelbegin(?:FL)? '; # Token to mark begin of deleted text +my $DELMARKCLOSE='\\\DIFdelend(?:FL)?(?: |\z)'; # Token to mark end of deleted text +my $DELOPEN='\\\DIFdel(?:FL)?{'; # To mark begin of deleted text passage +my $DELCLOSE='}'; # To mark end of deleted text passage +my $ALTEXT='FL'; # string which might be appended to above commands +my $DELCMDOPEN='%DIFDELCMD < '; # To mark begin of deleted commands (must begin with %, i.e., be a comment +my $DELCMDCLOSE="%%%\n"; # To mark end of deleted commands (must end with a new line) +my $AUXCMD='%DIFAUXCMD' ; # follows auxiliary commands put in by latexdiff to make difference file legal +my $DELCOMMENT='DIF < '; # To mark deleted comment line + +my $PREAMBLEXTBEG='^%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF$'; +my $PREAMBLEXTEND='^%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF$'; + + +my $pat0 = '(?:[^{}]|\\\{|\\\})*'; +my $pat1 = '(?:[^{}]|\\\{|\\\}|\{'.$pat0.'\})*'; +my $pat2 = '(?:[^{}]|\\\{|\\\}|\{'.$pat1.'\})*'; +my $pat3 = '(?:[^{}]|\\\{|\\\}|\{'.$pat2.'\})*'; +my $pat4 = '(?:[^{}]|\\\{|\\\}|\{'.$pat3.'\})*'; +my $brat0 = '(?:[^\[\]]|\\\[|\\\])*'; + + +my ($input,$preamble,$body,$post); +my (@matches); +my ($cnt,$prematch,$postmatch); +my ($help); +my ($verbose,$quiet,$accept,$decline,$simplify)=(0,0,0,0,0); +my ($comment,$comenv,$markup,$markenv); + +# A word unlikely ever to be used in a real latex file +my $someword='gobbledegooksygook'; + +Getopt::Long::Configure('bundling'); +GetOptions('accept|a' => \$accept, + 'decline|d'=> \$decline, + 'simplify|s' => \$simplify, + 'comment|c=s' => \$comment, + 'comment-environment|e=s' => \$comenv, + 'markup|m=s' => \$markup, + 'markup-environment|n=s' => \$markenv, + 'no-warnings|q' => \$verbose, + 'verbose|V' => \$verbose, + 'help|h|H' => \$help); + +if ( $help ) { + usage() ; +} + +if ( ($accept && $decline) || ($accept && $simplify) || ($decline && $simplify) ) { + die '-a,-d and -s options are mutually axclusive. Type latexrevise -h to get more help.'; +} + + + +print STDERR "ACCEPT mode\n" if $verbose && $accept; +print STDERR "DECLINE mode\n" if $verbose && $decline; +print STDERR "SIMPLIFY mode. WARNING: The output will not normally be valid latex,\n" if $verbose && $simplify; + +# Slurp old and new files +{ + local $/ ; # locally set record operator to undefined, ie. enable whole-file mode + $input=<>; +} + +# split into parts +($preamble,$body,$post)=splitdoc($input,'\begin{document}','\end{document}'); + +if (length $preamble && ( $accept || $decline ) ) { + # + # WORK ON PREAMBLE + # + # (compare subroutine linediff in latexdiff to make sure correct strings are used) + + # remove extra commands added to preamble by latexdiff + $preamble =~ s/${PREAMBLEXTBEG}.*?${PREAMBLEXTEND}\n{0,1}//smg ; + + if ( $accept ) { + # delete mark up in appended lines + $preamble =~ s/^(.*) %DIF > $/$1/mg ; + } elsif ( $decline ) { + # delete appended lines + # $preamble =~ s/^(.*) %DIF > $//mg ; + $preamble =~ s/^(.*) %DIF > \n//mg ; + # delete markup in deleted lines + $preamble =~ s/^%DIF < //mg ; + } + # remove any remaining DIF markups + #$preamble =~ s/%DIF.*$//mg ; + $preamble =~ s/%DIF.*?\n//sg ; +} +#print $preamble ; + +# +# WORK ON BODY +# +if ($accept) { + # remove ADDMARKOPEN, ADDMARKCLOSE tokens + @matches= $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/sg; + checkpure(@matches); + $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/$1/sg; + # remove text flanked by DELMARKOPEN, DELMARKCLOSE tokens + @matches= $body =~ m/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/sg; + checkpure(@matches); + $body =~ s/${DELMARKOPEN}(.*?)${DELMARKCLOSE}//sg; + # remove markup of added comments + $body =~ s/%${ADDCOMMENT}(.*?)$/%$1/mg ; + # remove deleted comments (full line) + $body =~ s/^%${DELCOMMENT}.*?\n//mg ; + # remove deleted comments (part of line) + $body =~ s/%${DELCOMMENT}.*?$//mg ; +} +elsif ( $decline) { + # remove DELMARKOPEN, DELMARKCLOSE tokens + @matches= $body =~ m/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/sg; + checkpure(@matches); + $body =~ s/${DELMARKOPEN}(.*?)${DELMARKCLOSE}/$1/sg; + # remove text flanked by ADDMARKOPEN, ADDMARKCLOSE tokens + # as latexdiff algorithm keeps the formatting and white spaces + # of the new text, sometimes whitespace might be inserted or + # removed inappropriately. We try to guess whether this has + # happened + + # Mop up tokens. This must be done already now as otherwise + # detection of white-space problems does not work + $cnt = $body =~ s/${DELOPEN}($pat4)${DELCLOSE}/$1/sg; + # remove markup of deleted commands + $cnt += $body =~ s/${DELCMDOPEN}(.*?)${DELCMDCLOSE}/$1/sg ; + $cnt += $body =~ s/${DELCMDOPEN}//g ; + # remove aux commands + $cnt += $body =~ s/^.*${AUXCMD}$/${someword}/mg; $body =~ s/${someword}\n//g; + + while ( $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/s ) { + $prematch=$`; + $postmatch=$'; + checkpure($1); + if ( $prematch =~ /\w$/s && $postmatch =~ /^\w/ ) { + # apparently no white-space between word=>Insert white space + $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/ /s ; + } + elsif ( $prematch =~ /\s$/s && $postmatch =~ /^[.,;:]/ ) { + # space immediately before one of ".,:;" => remove this space + $body =~ s/\s${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//s ; + } + else { + # do not insert or remove any extras + $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//s; + } + } +# Alternative without special cases treatment +# @matches= $body =~ m/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}/sg; +# checkpure(@matches); +# $body =~ s/${ADDMARKOPEN}(.*?)${ADDMARKCLOSE}//sg; + # remove markup of deleted comments + $body =~ s/%${DELCOMMENT}(.*?)$/%$1/mg ; + # remove added comments (full line) + $body =~ s/^%${ADDCOMMENT}.*?\n//mg ; + # remove added comments (part of line) + $body =~ s/%${ADDCOMMENT}.*?$//mg ; +} + +# remove any remaining tokens +if ( $accept || $decline || $simplify ) { + # first substitution command deals with special case of added paragraph + $cnt = $body =~ s/${ADDOPEN}($pat4)\n${ADDCLOSE}\n/$1\n/sg; + $cnt += $body =~ s/${ADDOPEN}($pat4)${ADDCLOSE}/$1/sg; + $cnt==0 || warn 'Remaining $ADDOPEN tokens in DECLINE mode\n' unless ( $quiet || $accept || $simplify ); +} +if ($accept || $simplify ) { + # Note: in decline mode these commands have already been removed above + $cnt = $body =~ s/${DELOPEN}($pat4)${DELCLOSE}/$1/sg; + #### remove markup of deleted commands + $cnt += $body =~ s/${DELCMDOPEN}(.*?)${DELCMDCLOSE}/$1/sg ; + $cnt += $body =~ s/${DELCMDOPEN}//g ; + # remove aux commands + # $cnt += + $body =~ s/^.*${AUXCMD}$/${someword}/mg; $body =~ s/${someword}\n//g; + + #### remove deleted comments + ###$cnt += $body =~ s/${DIFDELCMD}.*?$//mg ; + $cnt==0 || warn 'Remaining $DELOPEN or $DIFDELCMD tokens in ACCEPT mode\n' unless ( $quiet || $simplify ); +} + +# Remove comment commands +if (defined($comment)) { + print STDERR "Removing \\$comment\{..\} sequences ..." if $verbose; + # protect $comments in comments by making them look different + $body =~ s/(%.*)${comment}(.*)$/$1${someword}$2/mg ; + # carry out the substitution + $cnt = 0 + $body =~ s/\\${comment}(?:\[${brat0}\])?\{${pat4}\}//sg ; + print STDERR "$cnt matches found and removed.\n" if $verbose; + # and undo the protection substitution + $body =~ s/(%.*)${someword}(.*)$/$1${comment}$2/mg ; +} +if (defined($comenv)) { + print STDERR "Removing $comenv environments ..." if $verbose; + $body =~ s/(%.*)${comenv}/$1${someword}/mg ; +## $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{\$comenv\}.*?\\end\{\$comenv\}//sg ; + $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{${comenv}\}.*?\\end\{${comenv}\}\s*?\n//sg ; + print STDERR "$cnt matches found and removed.\n" if $verbose; + $body =~ s/(%.*)${someword}/$1${comenv}/mg ; +} + +if (defined($markup)) { + print STDERR "Removing \\$markup\{..\} cpmmands ..." if $verbose; + # protect $markups in comments by making them look different + $body =~ s/(%.*)${markup}(.*)$/$1${someword}$2/mg ; + # carry out the substitution + $cnt = 0 + $body =~ s/\\${markup}(?:\[${brat0}\])?\{(${pat4})\}/$1/sg ; + print STDERR "$cnt matches found and removed.\n" if $verbose; + # and undo the protection substitution + $body =~ s/(%.*)${someword}(.*)$/$1${markup}$2/mg ; +} +if (defined($markenv)) { + print STDERR "Removing $markenv environments ..." if $verbose; + $body =~ s/(%.*)${markenv}/$1${someword}/mg ; + $cnt = 0 + $body =~ s/\\begin(?:\[${brat0}\])?\{${markenv}\}\n?//sg; + $cnt += 0 + $body =~ s/\\end\{${markenv}\}\n?//sg; + print STDERR $cnt/2, " matches found and removed.\n" if $verbose; + $body =~ s/(%.*)${someword}/$1${markenv}/mg ; +} + + +if ( length $preamble ) { + print "$preamble\\begin{document}${body}\\end{document}$post"; +} else { + print $body; +} + +# checkpure(@matches) +# checks whether any of the strings in matches contains +# $ADDMARKOPEN, $ADDMARKCLOSE,$DELMARKOPEN, or $DELMARKCLOSE +# If so, die reporting nesting problems, otherwise return to caller +sub checkpure { + while (defined($_=shift)) { + if ( /$ADDMARKOPEN/ || /$ADDMARKCLOSE/ + || /$DELMARKOPEN/ || /$DELMARKCLOSE/ ) { + die <=0 && $j>$i ) { + $part1 = substr($text,0,$i) ; + $part2 = substr($text,$i+$l1,$j-$i-$l1); + $part3 = substr($text,$j+$l2) unless $j+$l2 >= length $text; + } else { + die "$word1 or $word2 not in the correct order or not present as a pair." + } + return ($part1,$part2,$part3); +} + + + +sub usage { + die <<"EOF"; +Usage: $0 [OPTIONS] [diff.tex] > revised.tex + +Read a file diff.tex (output of latexdiff), and remove its markup. +If no filename is given read from standard input. The command can be used +in ACCEPT, DECLINE, or SIMPLIFY mode, and be used to remove user-defined +latex commands from the input (see options -c, -e, -m, -n below). +In ACCEPT mode, all appended text fragments (or preamble lines) +are kept, and all discarded text fragments (or preamble lines) are +deleted. +In DECLINE mode, all discarded text fragments are kept, and all appended +text fragments are deleted. +If you wish to keep some changes, edit the diff.tex file in +advance, and manually remove those tokens which would otherwise be +deleted. Note that latexrevise only pays attention to the \\DIFaddbegin, +\\DIFaddend, \\DIFdelbegin, and \\DIFdelend tokens and corresponding FL +varieties. All \\DIFadd and \\DIFdel commands (but not their content) are +simply deleted. The commands added by latexdiff to the preamble are also +removed. +In SIMPLIFY mode all latexdiff markup is removed from the body of the text (after +\\begin{document}) except for \\DIFaddbegin, \\DIFaddend, \\DIFdelbegin, \\DIFdelend +tokens and the corresponding FL varieties of those commands. The result +will not in general be valid latex-code but might be easier to read and edit in +preparation for a subsequent run in ACCEPT or DECLINE mode. +In SIMPLIFY mode the preamble is left unmodified. + +-a +--accept Run in ACCEPT mode (delete all blocks marked by \\DIFdelbegin + and \\DIFdelend). + +-d +--decline Run in DECLINE mode (delete all blocks marked by \\DIFaddbegin + and \\DIFaddend). + +-s +--simplify Run in SIMPLIFY mode (Keep all \\DIFaddbegin, \\DIFaddend, + \\DIFdelbegin, \\DIFdelend tokens, but remove all other latexdiff + markup from body. + +Note that the three mode options are mutually exclusive. If no mode option is given, +latexrevise simply removes user annotations and markup according to the following four +options. + + +-c cmd +--comment=cmd Remove \\cmd{...}. cmd is supposed to mark some explicit + anotations which should be removed from the file before + release. + +-e envir +--comment-environment=envir + Remove explicit annotation environments from the text, i.e. remove + \\begin{envir} + ... + \\end{envir} + blocks. + +-m cmd +--markup=cmd Remove the markup command cmd but leave its argument, i.e. + turn \\cmd{abc} into abc. + +-n envir +--markup-environment=envir + Similarly, remove \\begin{envir} and \\end{envir} commands, + but leave content of the environment in the text. + +-q +--no-warnings Do not warn users about \\DIDadd{..} or \\DIFdel statements + which should not be there anymore + +-V +--verbose Verbose output + +EOF +} + +=head1 NAME + +latexrevise - selectively remove markup and text from latexdiff output + +=head1 SYNOPSIS + +B [ B ] [ F ] > F + +=head1 DESCRIPTION + +I reads a file C (output of I), and remove the markup commands. +If no filename is given the input is read from standard input. The command can be used +in I, I, or I mode, or can be used to remove user-defined +latex commands from the input (see B<-c>, B<-e>, B<-m>, and B<-n> below). +In I mode, all appended text fragments (or preamble lines) +are kept, and all discarded text fragments (or preamble lines) are +deleted. +In I mode, all discarded text fragments are kept, and all appended +text fragments are deleted. +If you wish to keep some changes, edit the diff.tex file in +advance, and manually remove those tokens which would otherwise be +deleted. Note that I only pays attention to the C<\DIFaddbegin>, +C<\DIFaddend>, C<\DIFdelbegin>, and C<\DIFdelend> tokens and corresponding FL +varieties. All C<\DIFadd> and C<\DIFdel> commands (but not their contents) are +simply deleted. The commands added by latexdiff to the preamble are also +removed. +In I mode, C<\DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend> +tokens and their corresponding C varieties are kept but all other markup (e.g. C and <\DIFdel>) is removed. The result +will not in general be valid latex-code but it will be easier to read and edit in +preparation for a subsequent run in I or I mode. +In I mode the preamble is left unmodified. + +=head1 OPTIONS + +=over 4 + +=item B<-a> or B<--accept> + +Run in I mode (delete all blocks marked by C<\DIFdelbegin> and C<\DIFdelend>). + +=item B<-d> or B<--decline> + +Run in I mode (delete all blocks marked by C<\DIFaddbegin> +and C<\DIFaddend>). + +=item B<-s> or B<--simplify> + +Run in I mode (Keep all C<\DIFaddbegin>, C<\DIFaddend>, +C<\DIFdelbegin>, C<\DIFdelend> tokens, but remove all other latexdiff +markup from body). + +=back + +Note that the three mode options are mutually exclusive. If no mode option is given, +I simply removes user annotations and markup according to the following four +options. + +=over 4 + +=item B<-c cmd> or B<--comment=cmd> + +Remove C<\cmd{...}> sequences. C is supposed to mark some explicit +anotations which should be removed from the file before +release. + +=item B<-e envir> or B<--comment-environment=envir> + +Remove explicit annotation environments from the text, i.e. remove + + \begin{envir} + ... + \end{envir} + +blocks. + +=item B<-m cmd> or B<--markup=cmd> + +Remove the markup command C<\cmd> but leave its argument, i.e. +turn C<\cmd{abc}> into C. + +=item B<-n envir> or B<--markup-environment=envir> + +Similarly, remove C<\begin{envir}> and C<\end{envir}> commands but +leave content of the environment in the text. + + +=item B<-V> or B<--verbose> + +Verbose output + +=item B<-q> or B<--no-warnings> + +Do not warn users about C<\DIDadd{..}> or C<\DIFdel{..}> statements +which should have been removed already. + +=back + +=head1 BUGS + +The current version is a beta version which has not yet been +extensively tested, but worked fine locally. Please send bug reports +to I. Include the serial number of I +(from comments at the top of the source). If you come across latexdiff +output which is not processed correctly by I please include the +problem file as well as the old and new files on which it is based, +ideally edited to only contain the offending passage as long as that still +reproduces the problem. + +I gets confused by commented C<\begin{document}> or +C<\end{document}> statements + +=head1 SEE ALSO + +L + +=head1 PORTABILITY + +I does not make use of external commands and thus should run +on any platform supporting PERL v5 or higher. + +=head1 AUTHOR + +Copyright (C) 2004 Frederik Tilmann + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License Version 2 + +=cut diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 26b2a93c371..b377754827b 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -3777,6 +3777,8 @@ sub POSTlatexdiff # to avoid special case in w32 wrapper my $dir = "$DEST/scripts/$package"; &SYSTEM ("$MV $dir/latexdiff-so $dir/latexdiff.pl"); + &SYSTEM ("$MV $dir/latexrevise $dir/latexrevise.pl"); + &SYSTEM ("$MV $dir/latexdiff-vc $dir/latexdiff-vc.pl"); } sub POSTlithuanian -- cgit v1.2.3