diff options
author | Karl Berry <karl@freefriends.org> | 2010-07-19 23:16:46 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-07-19 23:16:46 +0000 |
commit | 277ca449c86a187fe858defdcd6aa1830d3b2d0d (patch) | |
tree | a804dd4e397504655fc225e6f582554780c4115d /Master/texmf-dist/source/latex/stex/bin/convert-paths | |
parent | d515f1120311798486a522c56170bd519d9c6a7a (diff) |
reinstate stex via new .tds.zip
git-svn-id: svn://tug.org/texlive/trunk@19538 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/stex/bin/convert-paths')
-rwxr-xr-x | Master/texmf-dist/source/latex/stex/bin/convert-paths | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/stex/bin/convert-paths b/Master/texmf-dist/source/latex/stex/bin/convert-paths new file mode 100755 index 00000000000..55ee72a2370 --- /dev/null +++ b/Master/texmf-dist/source/latex/stex/bin/convert-paths @@ -0,0 +1,56 @@ +#!/usr/bin/perl -w +# +# A script that converts paths in sTeX files from the old \Foosnipppath{bar} +# to \snippets{foo/bar}, according to the definition of those path macros in +# paths.sty. +# +# Syntax: convert-paths path/to/paths.sty FILES +# +# © 2008 Christoph Lange, KWARC, Jacobs University + +use File::Copy; + +my %map; + +my $SNIPPATHRE = '\\\\[[:alnum:]]+(?i:snip|pic)path'; + +if (open(P, shift(@ARGV))) { + print STDERR "Mapping:\n"; + while (<P>) { + if (/^\\def($SNIPPATHRE)#1\{(\\KWARCslides\{[^#]+)#1\}/o) { + printf STDERR "\t%s -> %s\n", $1, $2; + $map{$1} = $2; + } + } + close(P); +} +else { + die "Could not open paths.sty"; +} + +print STDERR "Processing files:\n"; +while ($#ARGV >= 0) { + my $filename = shift(@ARGV); + print STDERR "\t$filename\n"; + copy($filename, "$filename~") || print STDERR "\t\tWARN: could not create backup\n"; + if (open(T, $filename)) { + # slurp the file into a string + local $/; + $data = <T>; + $data =~ s/($SNIPPATHRE)\{([^}]+)\}/ + $map{$1} ? "$map{$1}$2\}" + : ((print STDERR "\t\tWARN: could not replace $1\n"), "$1\{$2}") + /oxge; + close T; + if (open(T, ">$filename")) { + print T $data; + close T; + } + else { + print STDERR "\t\tWARN: could not save replacement\n"; + } + } + else { + print STDERR "\t\tWARN: could not open file\n"; + } +} |