diff options
author | Karl Berry <karl@freefriends.org> | 2008-05-18 22:12:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-05-18 22:12:36 +0000 |
commit | b5f54dc06c1ff962aa8b875303ddd2b96c49fee4 (patch) | |
tree | 7a55fd41a9c79250721c460717cdbfa28edfa9aa /Build | |
parent | ddc42005fd361c839fe2cd769c089282395f11fa (diff) |
remove scripts now linked and/or maintained in texmf/scripts (found by vvv)
git-svn-id: svn://tug.org/texlive/trunk@8213 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/tetex/ChangeLog | 4 | ||||
-rwxr-xr-x | Build/source/texk/tetex/texdoc | 207 | ||||
-rw-r--r-- | Build/source/texk/texlive/ChangeLog | 8 | ||||
-rw-r--r-- | Build/source/texk/texlive/Makefile.in | 2 | ||||
-rw-r--r-- | Build/source/texk/texlive/pdfthumb | 29 | ||||
-rwxr-xr-x | Build/source/texk/texlive/texdoc | 345 | ||||
-rw-r--r-- | Build/source/texk/texlive/vpe | 421 |
7 files changed, 13 insertions, 1003 deletions
diff --git a/Build/source/texk/tetex/ChangeLog b/Build/source/texk/tetex/ChangeLog index 52180a035a1..f06df2cbbae 100644 --- a/Build/source/texk/tetex/ChangeLog +++ b/Build/source/texk/tetex/ChangeLog @@ -1,3 +1,7 @@ +2008-05-19 Karl Berry <karl@tug.org> + + * texdoc: remove, master is now the lua version in texmf/scripts. + 2008-05-11 Norbert Preining <preining@logic.at> * Makefile.in: do not install texdoc(.man) since we will use the diff --git a/Build/source/texk/tetex/texdoc b/Build/source/texk/tetex/texdoc deleted file mode 100755 index 74cbe72c6da..00000000000 --- a/Build/source/texk/tetex/texdoc +++ /dev/null @@ -1,207 +0,0 @@ -#!/bin/sh -# $Id$ -# -# Thomas Esser, David Aspinall, Simon Wilkinson. -# Public domain. -# -# Simple script to attempt to find documentation for tex files. -# Uses kpsewhich to find a .dvi, .pdf or .ps file along the -# 'TeX system documentation' ($TEXDOCS, default: $TEXMF/doc) search path. -# -# Original version by David Aspinall <da@dcs.ed.ac.uk> -# -# This version rewritten for use with bash 2 and teTeX under Linux by -# Simon Wilkinson <sxw@dcs.ed.ac.uk> -# -# Changes for web2c-7.2 resp. teTeX-0.9 and portability fixes by -# Thomas Esser <te@dbs.uni-hannover.de>, Jun 14 1998 -# -# Support for compressed documentation implemented by adopting changes -# made by debian. Thomas Esser, Dec. 2004. - -test -f /bin/sh5 && test -z "$RUNNING_SH5" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -export PATH - -needsCleanup=false -progname=texdoc -tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$ - -############################################################################### -# setupTmpDir() -# set up a temp directory and a trap to remove it -############################################################################### -setupTmpDir() -{ - $needsCleanup && return - - trap 'cleanup --force' 1 2 3 7 13 15 - needsCleanup=true - mkdir "$tmpdir" || abort "could not create directory \`$tmpdir'" -} - -############################################################################### -# abort(errmsg) -# print `errmsg' to stderr and exit with error code 1 -############################################################################### -abort() -{ - warn "$progname: $1." - cleanup - (exit 1) - exit 1 -} - -############################################################################### -# cleanup() -# clean up the temp area -############################################################################### -cleanup() -{ - case $1 in - --force) - $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ - && { rm -f "$tmpdir"/*; cd /; rmdir "$tmpdir"; } - ;; - *) # directory might not be empty if some other viewer is still - # running, so be quiet about it - rmdir $tmpdir >/dev/null 2>&1;; - esac -} - - -# Viewing programs, according to filename extension. (You can -# override or add to them by setting environment variables). -# MacOS X: does not have X11 by default, so give dvi a low priority -case `(uname -s) 2>/dev/null` in - Darwin) - : ${TEXDOCVIEW_dvi='(open %s >/dev/console 2>&1 || xdvi %s &) || echo "Method for opening %s did not work"'} - : ${TEXDOCVIEW_ps='open %s'} - : ${TEXDOCVIEW_pdf='open %s'} - : ${TEXDOCVIEW_html='open %s'} - : ${TEXDOCVIEW_txt="open -a TextEdit.app %s"} - : ${TEXDOCVIEW_="open -a TextEdit.app %s"} # no extension, default to pager - extlist='.pdf .ps .txt .dvi .html' - ;; - *) - : ${TEXDOCVIEW_dvi='(xdvi %s) &'} - : ${TEXDOCVIEW_pdf='(acroread %s) &'} - : ${TEXDOCVIEW_ps='(gv %s) &'} - : ${TEXDOCVIEW_html='firefox -remote openURL'"'(%s)'"' 2>/dev/null || firefox %s &'} - : ${TEXDOCVIEW_txt="${PAGER-more} %s"} - : ${TEXDOCVIEW_="${PAGER-more} %s"} # no extension, default to pager - extlist='.dvi .dvi.gz .dvi.bz2 .pdf .pdf.gz .pdf.bz2 .ps .ps.gz .ps.bz2 .txt .txt.gz .txt.bz2 .html' - - # Commands run to uncompress files, according to filename extension. - : ${TEXDOCUNZIP_gz='gzip -d -c'} - : ${TEXDOCUNZIP_bz2='bzip2 -d -c'} - ;; -esac - -mode=viewer -help='Usage: texdoc [OPTION]... [NAME]... - Search for NAME in the TeX documentation and start a viewer. - - --help show this help - -v verbose mode: show viewer command - -l just list all matching files. Do not start a viewer. - -s search the disk. remaining arguments will be passed - as egrep patterns to filter the find output.' - -verbosemode=false -while - case $1 in - -s) mode=search; shift; break;; - -l) mode=list;; - -v) verbosemode=true;; - *-help) - echo "$help" >&2 - exit 1;; - -*) echo "texdoc: option $1 not recognized" 1>&2;; - *) break;; - esac -do shift; done - -case $# in - 0) - echo "$help" >&2 - exit 1 - ;; -esac - -for name -do - case $mode in - search) - find `kpsewhich --expand-path='$TEXDOCS' | tr : ' '` -type f -print | - egrep $name - continue - ;; - esac - - case $name in - texdoc) - man texdoc; continue;; - esac - - found=false - for ext in "" $extlist; do - - filename=`kpsewhich -format='TeX system documentation' $name$ext 2>/dev/null` - test -z "$filename" && continue - found=true - - if test $mode = list; then - echo $filename - else - dir=`echo $filename | sed 's%/[^/]*$%%'` - ext=`echo $filename | sed -n 's%.*\.\([^/]*\)$%\1%p'` - - eval uncompress="\$TEXDOCUNZIP_$ext" - if test -n "$uncompress" - then - ext=`echo $filename | sed -e "s|\\.$ext\$||" | sed 's%.*\.%%'` - fi - viewer=\$"TEXDOCVIEW_$ext" - if test -n "$uncompress"; then - src=`echo "$filename" | sed -e 's%.*/%%' -e 's%\.[^.]*$%%'` - - # only one viewer per file, if the same file is given more - # than once - test -f "$tmpdir/$src" && break - - setupTmpDir - eval "$uncompress $filename > $tmpdir/$src" - filename=$tmpdir/$src - viewer=`eval echo $viewer | sed -e "s|%s|$filename; rm -f $filename; cleanup|"` - else - viewer=`eval echo $viewer | sed -e "s|%s|$filename|g"` - fi - - if test -z "$viewer" - then - echo "Don't know how to view file type $ext" 1>&2 - echo "(matching file was $filename)" 1>&2 - else - $verbosemode && echo $viewer - test -n "$dir" && test -d "$dir" && cd "$dir" - eval $viewer - break # just stop after the first usable extension - fi - fi - - done - $found || echo "Can't find documentation for \`$name'" 1>&2 -done - -cleanup -(exit 0) -exit 0 diff --git a/Build/source/texk/texlive/ChangeLog b/Build/source/texk/texlive/ChangeLog index 0283ad127f6..8318aa2246c 100644 --- a/Build/source/texk/texlive/ChangeLog +++ b/Build/source/texk/texlive/ChangeLog @@ -1,3 +1,11 @@ +2008-05-19 Karl Berry <karl@tug.org> + + * Makefile.in (LIVESCRIPTS): remove pdfthumb, we want the one in + LINKED_SCRIPTS. + * vpe, + * texdoc: remove, the masters are in texmf/scripts now. + * pdfthumb: remove, we use the lua wrapper now. + 2008-05-18 Karl Berry <karl@tug.org> * Makefile.in (install-linked-scripts): change from Peter M to diff --git a/Build/source/texk/texlive/Makefile.in b/Build/source/texk/texlive/Makefile.in index 63afdc66cbf..ede4ac19662 100644 --- a/Build/source/texk/texlive/Makefile.in +++ b/Build/source/texk/texlive/Makefile.in @@ -9,7 +9,7 @@ kpse_include ../make/programs.mk LIVESCRIPTS = simpdftex \ ebong getnonfreefonts giftopng \ - pdfthumb wordcount.sh + wordcount.sh # These scripts do not exist here in /source/ at all, the instances # in texmf are the masters (except when it is CTAN). diff --git a/Build/source/texk/texlive/pdfthumb b/Build/source/texk/texlive/pdfthumb deleted file mode 100644 index 98fcf307468..00000000000 --- a/Build/source/texk/texlive/pdfthumb +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# -# pdfthumb shell script file last update: 13 Sep 2002 -# -# minimal usage: -# pdfthumb input.pdf output.pdf -# -# Note: input.pdf and output.pdf must be different. -# GhostScript (gs) must me available to create the images. -# Unfortunately it fails on some input files for unknown reasons. -# -# It is assumed that you have at least Java 1.2.x installed -# and can call it with the command java. Otherwise specify the -# path for your Java runtime system. -# -# Modify this script such that jarfile contains the full path -# of the pp4p.jar file. -# -#jarfile=/common/Java/lib/ppower4/pp4p.jar -# -# If you use a web2c distribution, you can place pp4p.jar -# e.g. into the directory texmf/java/ppower4, run mktexlsr, -# comment the assignment above and uncomment the assignment below. -# Thanks to Reinhard Kotucha for contributing this suggestion. -# -jarfile=`kpsewhich -progname=java -format='other binary files' pp4p.jar` -# -# -java -cp ${jarfile} de.tu_darmstadt.sp.pdftools.ThumbGen "$@" diff --git a/Build/source/texk/texlive/texdoc b/Build/source/texk/texlive/texdoc deleted file mode 100755 index 7c66896497d..00000000000 --- a/Build/source/texk/texlive/texdoc +++ /dev/null @@ -1,345 +0,0 @@ -#!/usr/bin/env texlua --- $Id$ ---[[ Written in lua by Frank Küster (2007) based on the shell script by -Thomas Esser, David Aspinall, and Simon Wilkinson. -Public domain.]] ---[[ Changelog - 0.3 2007-06-28 - - added changelog - - better OS detection for default viewer settings - - removed some debugging code - - -s now works in dirs without ls-R, too - - 0.2 2007-06-28 - - implemented reading of configuration from texmf.cnf - - fixed "-s" option - - 0.1 - - initial public release -]] - -progname = 'texdoc'; -version = '0.3'; -usage = ' Usage: ' .. progname ..' [-h|--help] name\ - -h|--help\t\t Show this help\ - -V|--version\t\t Print the version of the program\ - -v|--verbose\t\t Show the command being used to display the documentation\ - -l|--list\t\t List matching files, do not start a viewer.\ - -s|--search\t\t search for name as a pattern'; - - -if not arg[1] then - print (usage); - return -end - -mode = 'view'; -verbose = false; -while table.maxn(arg) > 0 and string.match(arg[1],'^%-') do - curr_arg = table.remove(arg,1) - if string.match (curr_arg,'-h') or string.match (curr_arg,'--help') then - print (usage); - os.exit(0); - elseif string.match (curr_arg,'-V') or string.match (curr_arg,'--version') then - print (progname .. ' version: ' .. version ); - os.exit(0); - elseif string.match (curr_arg,'-v') or string.match (curr_arg,'--verbose') then - verbose = true; - elseif string.match (curr_arg,'-l') or string.match (curr_arg,'--list' ) then - mode = 'list'; - elseif string.match (curr_arg,'-s') or string.match (curr_arg,'--search' ) then - mode = 'search'; - end -end - ---[[ function definitions ]] -function list_iter (t) - local i = 0 - local n = table.getn(t) - return function () - i = i + 1 - if i <= n then return t[i] end - end -end - - --- [[ functions for the search option ]] -no_lsr_doctrees = {}; -function get_lsr_files () - local lsr_files = {}; - local pathlist = kpse.expand_braces('$TEXDOCS'); - for path in string.gmatch(pathlist, "[^:;]+") do - path = string.gsub(path,'//$','') - local tree_root - tree_root = string.gsub(path,'doc$','') - tree_root = string.gsub(tree_root,'^!!','') - if lfs.isfile(tree_root .. "ls-R") then - table.insert(lsr_files,tree_root .. "ls-R") - else - if not string.match(path,'^%.$') and lfs.isdir(path) then - table.insert(no_lsr_doctrees,path) - end - end -- does lsRfile exist? - end -- for path - local i = 0 - local n = table.getn(lsr_files) - -- TODO: We completely ignore trees without ls-R files. Since I - -- don't know how to get the output of "find" without resorting to - -- temporary files, anyway, I don't care. - return function () - i = i +1 - if i <= n then return lsr_files[i] end - end - -end -- get_lsr_files() - -function deluaficate(oldpat) - local newpat - -- better use long strings here, no escaping of \ needed there. - newpat = string.gsub(oldpat,'([^\\])%-','%1%%%-') - newpat = string.gsub(newpat,'\\','') - return newpat -end --deluaficate - -docdirs = {} -docfiles = {} -function pattern_search (pattern) - pattern = deluaficate(pattern) - -- populate docdirs and doclines list - for database in get_lsr_files() do - local texmf_tree = string.gsub(database,'ls%-R$','') - is_docline = false - local this_dir -- changed to each individual docdir - for line in io.lines(database) do - if string.match(line,'^./') then - -- a directory - this_dir = string.gsub(line,'^./',texmf_tree) - this_dir = string.gsub(this_dir,':$','/') - if string.match(line,'^./doc') then - -- the next file lines are in docdir "this_dir" - is_docline = true - -- save it in the docdirs table - table.insert(docdirs,this_dir) - else - is_docline = false - end -- docdir - elseif string.match(line,'^%s*$') then - -- empty line, do nothing - -- now we have only file lines left, are they a docline? - elseif is_docline then - local fullpath = this_dir .. line --- print(fullpath) - table.insert(docfiles,fullpath) - end -- line starting with ./ - end -- for line - end -- for database - for no_lsr_dir in list_iter(no_lsr_doctrees) do - recurse_tree(no_lsr_dir) - end - - print("Directories that match:") - for dir in list_iter(docdirs) do - if string.match(dir,pattern) then - print (dir) - end - end -- for dir - print() - print("Files that match:") - for file in list_iter(docfiles) do - if string.match(file,pattern) then - print (file) - end - end -- for file - -end -- function pattern_search() - -function recurse_tree (path) - for file in lfs.dir(path) do - if file ~= "." and file ~= ".." then - local f = path..'/'..file - local attr = lfs.attributes (f) - if attr then -- else stale symlink - if attr.mode == "directory" then - table.insert(docdirs,f) - recurse_tree (f) - else - table.insert(docfiles,f) - end - end - end - end - end --function recurse_tree - - ---[[ functions for parsing texmf.cnf ]] -function set_var_from_texmf(oldvalue,texmfvar) - local newvalue - newvalue = kpse.var_value(texmfvar) - if newvalue then - return newvalue - else - return oldvalue - end -end -function set_listvar_from_texmf(oldvalue,texmfvar) - local list_as_string - local templist = {} - list_as_string = set_var_from_texmf('',texmfvar) - for element in string.gmatch(list_as_string,'[^,;:]+') do - table.insert(templist,element) - end - if table.maxn(templist) > 0 then - return templist - else - return oldvalue - end -end -- set_listvar_from_texmf - -function set_listvar_from_expand_braces(oldvalue,texmfvar) - local list_as_string - local templist = {} - list_as_string = kpse.expand_braces(texmfvar) - for element in string.gmatch(list_as_string,'[^,;:]*:') do - element = string.gsub(element,':','') - table.insert(templist,element) - end - if table.maxn(templist) > 0 then - return templist - else - return oldvalue - end -end -- set_listvar_from_expand_braces - ---[[ initialize kpathsea ]] -kpse.set_program_name("texdoc") - --- [[ initialize some variables ]] -texdoc_formats = {'dvi','pdf','ps','txt','html'} - --- can be done with: if (os.type == "windows") then -if string.find(os.getenv("PATH"),";") then - -- probably Windows (or OS/2) - -- which commands should we use for unzipping? - texdoc_unzip = { - gz = "gzip -d -c ", - bz2 = "bzip2 -d -c " - }; - texdoc_viewer = { - dvi = '(start /wait %s ) &', - html = '(start /wait %s) &', - pdf = '(start /wait %s) &', - ps = '(start /wait %s) &', - txt = '(start /wait %s) &', - tex = '(start /wait %s) &' - }; - rmfile_command = 'del /F '; - rmdir_command = 'rmdir '; -else - -- probably UNIX-like - texdoc_unzip = { - gz = "gzip -d -c ", - bz2 = "bzip2 -d -c " - }; - texdoc_viewer = { - dvi = '(xdvi %s ) &', - html = '(see %s) &', - pdf = '(xpdf %s) &', - ps = '(gv %s) &', - txt = '(less %s )', - tex = '(less %s )' - }; - rmfile_command = 'rm -f '; - rmdir_command = 'rmdir '; -end - -texdoc_zipformats = {'','gz','bz2'}; -texdoc_formats = {'','dvi','html','pdf','ps','txt','tex'}; -extlist = {'','.dvi', '.dvi.gz', '.dvi.bz2', '.pdf', '.pdf.gz', '.pdf.bz2', '.ps', '.ps.gz', '.ps.bz2', '.txt', '.txt.gz', '.txt.bz2', '.html'}; - --- [[ override hardcoded variables with values from texmf.cnf ]] -rmfile_command = set_var_from_texmf(rmfile_command,'TEXDOC_RMFILE') -rmdir_command = set_var_from_texmf(rmdir_command,'TEXDOC_RMDIR') -texdoc_formats = set_listvar_from_texmf(texdoc_formats,'TEXDOC_FORMATS') -for format in list_iter(texdoc_formats) do - viewer_var = 'TEXDOC_VIEWER_' .. string.upper(format) - texdoc_viewer[format] = set_var_from_texmf(texdoc_viewer[format],viewer_var) -end -texdoc_zipformats = set_listvar_from_texmf(texdoc_zipformats,'TEXDOC_ZIPFORMATS') -for zipext in list_iter(texdoc_zipformats) do - viewer_var = 'TEXDOC_UNZIP_' .. string.upper(zipext) - texdoc_unzip[zipext] = set_var_from_texmf(texdoc_unzip[zipext],viewer_var) -end -extlist = set_listvar_from_expand_braces(extlist,'$TEXDOCEXT'); --- we want an empty string for ext at the beginning, so that it works --- to specify the complete filename. Doesn't matter when there's one --- more empty string, but we can easily avoid two in a row -if not extlist[1] == '' then - insert(extlist,1,'') -end - - -for docname in list_iter (arg) do - if string.match(mode,'search') then - pattern_search(docname); - elseif string.match(mode,'view') or string.match(mode,'list') then - for ext in list_iter(extlist) do - filename = kpse.find_file(docname .. ext , "TeX system documentation") - - if filename then - if string.match (mode, 'list') then - print(filename); - else - -- mode is view, is unzipping needed? - zipext = string.match(ext,'%..*%.(.*)'); - if zipext then - unzip_command = texdoc_unzip[zipext]; - viewext = string.match(ext,'%.(.*)%..*$'); - basebame_pattern = '.*/(.*%.' .. viewext .. ')'; - basename = string.match(filename,basebame_pattern); - - -- uncompress only once per file, in case it is given more - -- than once (dvi besides ps or so) - -- TODO: to be done - - tmpdir = os.tmpdir("/tmp/texdoc.XXXXXX"); - - unzip_commandline = unzip_command .. filename .. " > " .. tmpdir .. "/" .. basename; - if os.execute(unzip_commandline) then - filename = tmpdir .. "/" .. basename; - else - print("Error executing \n" .. unzip_commandline); - end - viewer_replacement = filename .. ';' .. rmfile_command .. filename .. ';' .. rmdir_command .. tmpdir; - else - if ext == '' then - -- fallback if complete filename has been specified - ext = string.match(filename,'.*(%..*)$') - if not ext then - -- still no extension for filenames like README - ext = 'txt'; - end - end - viewer_replacement = filename; - viewext = string.match(ext,'%.(.*)$'); - if not viewext or not texdoc_viewer[viewext] then - -- complete filename specified, unknown extension, use "txt" - viewext = 'txt' - end - end -- zipped or not - view_command = string.gsub(texdoc_viewer[viewext],'%%s',viewer_replacement) - if verbose then - print(view_command); - end - view_result = os.execute(view_command); - if view_result then - do break end; - else - print("Error executing \n" .. view_command); - end - end -- list or view - end -- found a filename with that extension or not? - end -- for ext - end -- if construct "case mode in" -end -- for docname - --- cleanup_tmpdir(); diff --git a/Build/source/texk/texlive/vpe b/Build/source/texk/texlive/vpe deleted file mode 100644 index 9eb52b69e3c..00000000000 --- a/Build/source/texk/texlive/vpe +++ /dev/null @@ -1,421 +0,0 @@ -eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' - if 0; -use strict; -# -# vpe.pl -# -# Copyright (C) 2000 Heiko Oberdiek. -# -# This program may be distributed and/or modified under the -# conditions of the LaTeX Project Public License, either version 1.2 -# of this license or (at your option) any later version. -# The latest version of this license is in -# http://www.latex-project.org/lppl.txt -# and version 1.2 or later is part of all distributions of LaTeX -# version 1999/12/01 or later. -# -# See file "vpe.txt" for a list of files that belong to this project. -# -# This file "vpe.pl" may be renamed to "vpe" -# for installation purposes. -# -my $file = "vpe.pl"; -my $program = uc($&) if $file =~ /^\w+/; -my $version = "0.1"; -my $date = "2000/09/15"; -my $author = "Heiko Oberdiek"; -my $copyright = "Copyright (c) 2000 by $author."; -# -# History: -# 2000/09/15 v0.1: First release. -# - -### program identification -my $title = "$program $version, $date - $copyright\n"; - -### editor call -# %F: file name -# %L: line number -my $EditorCall = "xterm -e joe +%d %s"; -$EditorCall = $ENV{TEXEDIT} if $ENV{TEXEDIT}; -$EditorCall = $ENV{VPE} if $ENV{VPE}; - -### error strings -my $Error = "!!! Error:"; # error prefix - -my $usage = <<"END_OF_USAGE"; -${title} -Depending on the name of the script `vpe' works in four modes: - -* [vpe] Syntax: vpe <pdf file>[.pdf] - The pdf file is scanned for actions created by VTeX, - that start an editor with the source file at the - specified line under Windows. - A symbol link is made from the source file name - extended by the extension `.vpe' to this script. - The line number is encoded in the path and the - action is changed to start this script. - -* [sty] Internal for vpe.sty: - Syntax: vpe --sty [--progname=...] <latex file> <vpe file> - -* [system] Internal for vpe.sty: - Syntax: vpe --system <vpe file> - -* [launch] Syntax: <source file name>.vpe - The script decodes the line number in the path of - the source file name and starts an editor with - this file at that line number. - -Options: - --help: print usage. - --verbose: print additional informations during running. - --force: force symbol links - --delete: delete symbol links - --sty: internal for `vpe.sty' (get absolute file name and lines) - --system: internal for `vpe.sty' (get system info linux or win) - --progname: latex, pdflatex, elatex, pdfelatex -END_OF_USAGE - -### options -$::opt_verbose = 0; -$::opt_help = 0; -$::opt_force = 0; -$::opt_delete = 0; -$::opt_sty = 0; -$::opt_system = 0; -$::opt_progname = "latex"; -use Getopt::Long; -GetOptions( - "help!", - "verbose!", - "force!", - "delete!", - "sty!", - "system!", - "progname=s", -) or die $usage; -if ($::opt_help) { - die $usage; -} - -if ($::opt_sty and $::opt_system) { - die "$usage" . - "$Error Options --sty and --system cannot used together!\n"; -} - -################### -### launch mode ### -################### -if ($0 =~ /\.vpe/) { - - @ARGV == 0 or - die "$usage$Error Too many arguments [launch mode]!\n"; - - my $file = ""; - $0 =~ m|(^[\./]+\./)(.+)\.vpe$| or - die "$Error Cannot extract line number ($0)!\n"; - my $str = $1; - $file = "/$2"; - - my $line = ""; - while ($str ne "") { - $str =~ m|^(/*)(\.?)\./(.*)$| or - die "$Error Parse error!\n"; - $line .= length($1) + (($2 eq ".") ? 5 : 0); - $str = $3; - } - - my $callstr = $EditorCall; - $EditorCall =~ s/%s/$file/; - $EditorCall =~ s/%d/$line/; - print "File: $file, line: $line\n" if $::opt_verbose; - exec($EditorCall); - exit 1; -} - -### -### used by both sty and system mode: -### -my $system = "linux"; -$system = "" if $^O =~ /os2/i; -$system = "" if $^O =~ /mac/i; -$system = "win" if $^O =~ /dos/i; -$system = "win" if $^O =~ /win/i; - -################ -### sty mode ### -################ -if ($::opt_sty) { - - @ARGV == 2 or - die "$usage$Error Wrong arguments [sty mode]!\n"; - - my $vpefile = $ARGV[1]; - print "VPE file: $vpefile\n" if $::opt_verbose; - - my $file = `kpsewhich -progname=$::opt_progname $ARGV[0]`; - chomp $file; - if (!($file =~ m|^/| or $file =~ m|^\w:|)) { - use Cwd; - $file = cwd() . "/" . $file; - $file =~ s|/[^/]+/\.\./|/|g; - $file =~ s|/\./|/|g; - } - -f $file or - die "$Error Cannot find file `$file' [sty mode]!\n"; - print "File: $file\n" if $::opt_verbose; - - my $last = 0; - if (open(IN, $file)) { - while (<IN>) { - $last++; - } - } - if ($last == 0) { - $last = 10000; - } - print "Last line: $last\n" if $::opt_verbose; - - open(OUT, ">>$vpefile") or - die "$Error Cannot open file `$vpefile`!\n"; - print OUT "\\vpeentry{$file}{$last}\n"; - - exit 1; -} - -################### -### system mode ### -################### -if ($::opt_system) { - - @ARGV == 1 or - die "$usage$Error Wrong arguments [system mode]!\n"; - - my $vpefile = $ARGV[0]; - print "VPE file: $vpefile\n" if $::opt_verbose; - - open(OUT, ">>$vpefile") or - die "$Error Cannot open file `$vpefile`!\n"; - print OUT "\\vpesystem{$system}\n"; - - exit 1; -} - -################ -### vpe mode ### -################ -if (@ARGV < 1) { - die "$usage$Error Missing pdf file [vpe mode]!\n"; -} -if (@ARGV > 2) { - die "$usage$Error Too many arguments [vpe mode]!\n"; -} - -my $pdffile = $ARGV[0]; -if (!-f $pdffile) { - my $name = $pdffile; - $pdffile .= ".pdf"; - -f $pdffile or - die "$Error File `$name' not found [vpe mode]!\n"; -} - -open(IN, "+<$pdffile") or - die "$Error Cannot open `$pdffile' [vpe mode]!\n"; -binmode(IN); -my %symlinks = (); -while (<IN>) { - - if (m|/F\([\./]*(/.*)\.vpe\)|) { - $symlinks{$1} = 1; - next; - } - - my $do = 0; - my ($action, $file, $line, $type); - # my $color; # only for debugging - - if (m|^ - /A \s* << \s* - /Type \s* /Action \s* - /S \s* /Launch \s* - /Win \s* << \s* - /F \s* \(aftcomp.exe\) \s* - /P \s* \("(.*)\" \s+ \d+\-(\d+)\) \s* - >> \s* - >> \s* - $ - |x - ) { - $action = $_; - $file = $1; - $line = $2; - # $color = "/C[0 0 1]"; # only for debugging - $type = "aftcomp"; - $do = 1; - } - - if (m|^ - /A \s* << \s* - /Type \s* /Action \s* - /S \s* /Launch \s* - /Win \s* << \s* - /F \s* \(repos.exe\) \s* - /P \s* \( - "(.*)" \s* - "(\d+)" \s* - "(.*)" \s* - "(\d+)" - \) \s* - >> \s* - >> \s* - $ - |x - ) { - $action = $_; - if ($3 eq "") { - $file = $1; - $line = $2; - } - else { - # ??? - $file = $1; - $line = $2; - } - # $color = "/C[1 0 0]"; # only for debugging - $type = "repos"; - $do = 1; - } - - if ($do) { - my $length = length($action); - print "* File: $file, line: $line, type: $type\n" if $::opt_verbose; - - if (!($file =~ m|^/|)) { - print STDERR "$Error File `$file' lacks of absolute path!\n"; - next; - } - - if (!$::opt_delete) { - if ($line <= 0) { - $line = 1; - } - - my $newaction = ""; - { - my $digit = substr($line, 0, 1); - if ($digit <= 5) { - $newaction .= "/" x $digit; - } - else { - $newaction .= "/" x ($digit - 5) . "."; - } - $newaction .= "./"; - my $rest = $line; - while (($rest = substr($rest, 1)) ne "") { - $digit = substr($rest, 0, 1); - if ($digit < 5) { - $newaction .= "/" x $digit; - } - else { - $newaction .= "/" x ($digit - 5) . "."; - } - $newaction .= "./"; - } - } - $newaction .= substr($file, 1) . ".vpe"; - $newaction = # $color . # only for debugging - "/A<</Type/Action/S/Launch/F($newaction)>>"; - $newaction .= " " x ($length - length($newaction) - 1); - if (length($newaction) > $length) { - print STDERR "$Error Action too long!\n"; - next; - } - - seek(IN, -length($action), 1); - print IN $newaction; - } - - $symlinks{$file} = 1; - } -} - -if (keys(%symlinks)) { - - my $this = $0; - if (!$::opt_delete) { - if (!-f $0 or !-x $0) { - $this = `which $0`; - ($this ne "") or die "$Error Cannot find this script!\n"; - } - if (!($this =~ m|^/|)) { - use Cwd; - $this = cwd() . "/" . $this; - } - $this =~ s|/[^/]+/\.\./|/|g; - $this =~ s|/\./|/|g; - } - - if ($::opt_delete) { - print "Delete symlinks:\n"; - } - else { - if ($::opt_force) { - print "Forced symlinks to $this:\n"; - } - else { - print "Symlinks to $this:\n"; - } - } - - foreach (keys(%symlinks)) { - my $sym = $_ . ".vpe"; - print " $sym ["; - - if ($::opt_delete) { - if (!-l $sym) { - print "ok, not existing]\n"; - next; - } - unlink($sym); - if (!-l $sym) { - print "ok, deleted]\n"; - next; - } - print "failed]\n"; - next; - } - if ($::opt_force) { - if (-l $sym) { - unlink($sym); - if (-l $sym) { - print "deletion failed]\n"; - next; - } - if (symlink($this, $sym)) { - print "ok, deleted and created]\n"; - next; - } - print "deleted, creation failed]\n"; - next; - } - if (symlink($this, $sym)) { - print "ok, created]\n"; - next; - } - print "creation failed]\n"; - next; - } - if (-f $sym) { - print "exists]\n"; - next; - } - if (symlink($this, $sym)) { - print "ok, created]\n"; - next; - } - print "failed]\n"; - next; - } -} -__END__ |