From 2c0ff5f9ce5bec465a644eff6e17169c8e37479e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 6 Jun 2017 21:55:13 +0000 Subject: texosquery (23may17) git-svn-id: svn://tug.org/texlive/trunk@44509 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/support/texosquery/CHANGES | 14 ++ .../doc/support/texosquery/texosquery.pdf | Bin 499507 -> 504391 bytes .../scripts/texosquery/texosquery-jre5.jar | Bin 62916 -> 64238 bytes .../scripts/texosquery/texosquery-jre5.sh | 8 +- .../scripts/texosquery/texosquery-jre8.jar | Bin 67211 -> 68617 bytes .../scripts/texosquery/texosquery-jre8.sh | 8 +- .../texmf-dist/scripts/texosquery/texosquery.jar | Bin 66194 -> 67602 bytes Master/texmf-dist/scripts/texosquery/texosquery.sh | 8 +- .../source/support/texosquery/java/TeXOSQuery.java | 256 ++++++++++++++++++++- .../source/support/texosquery/texosquery.dtx | 166 ++++++++++--- .../texmf-dist/tex/latex/texosquery/texosquery.cfg | 47 ++-- .../texmf-dist/tex/latex/texosquery/texosquery.sty | 2 +- .../texmf-dist/tex/latex/texosquery/texosquery.tex | 2 +- 13 files changed, 445 insertions(+), 66 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/support/texosquery/CHANGES b/Master/texmf-dist/doc/support/texosquery/CHANGES index 4c143633004..7ad4e4b80fa 100644 --- a/Master/texmf-dist/doc/support/texosquery/CHANGES +++ b/Master/texmf-dist/doc/support/texosquery/CHANGES @@ -1,3 +1,17 @@ +1.5 (2017/05/23): + + * Added new command line options: + --strip-path-prefix (-sp) + --nostrip-path-prefix + --strip-uri-prefix (-su) + --nostrip-uri-prefix + --replace-path (-rp) + --noreplace-path + --replace-uri (-ru) + --noreplace-uri + + * Bash scripts now check for cygwin + 1.4 (2017/05/05): * The fallback value for 'openin_any' for texosquery-jre8 diff --git a/Master/texmf-dist/doc/support/texosquery/texosquery.pdf b/Master/texmf-dist/doc/support/texosquery/texosquery.pdf index 92b576339ee..de4af936863 100644 Binary files a/Master/texmf-dist/doc/support/texosquery/texosquery.pdf and b/Master/texmf-dist/doc/support/texosquery/texosquery.pdf differ diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar index d5155d40690..079a82eeb12 100755 Binary files a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar and b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar differ diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.sh b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.sh index e841a0ea7d2..a72924f360a 100755 --- a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.sh +++ b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.sh @@ -1,5 +1,11 @@ #!/bin/sh -jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre5.jar` +kernel=`uname -s` +if test "${kernel#*CYGWIN}" != "$kernel" +then + jarpath=`cygpath -w $(kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre5.jar)` +else + jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre5.jar` +fi java -jar "$jarpath" "$@" diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar index 6c1090e737d..8bd7ccec1f9 100755 Binary files a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar and b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar differ diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.sh b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.sh index d13f8eeff5a..f68a09c8660 100755 --- a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.sh +++ b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.sh @@ -1,5 +1,11 @@ #!/bin/sh -jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre8.jar` +kernel=`uname -s` +if test "${kernel#*CYGWIN}" != "$kernel" +then + jarpath=`cygpath -w $(kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre8.jar)` +else + jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre8.jar` +fi java -Djava.locale.providers=CLDR,JRE -jar "$jarpath" "$@" diff --git a/Master/texmf-dist/scripts/texosquery/texosquery.jar b/Master/texmf-dist/scripts/texosquery/texosquery.jar index cff38782dae..e615b37761c 100755 Binary files a/Master/texmf-dist/scripts/texosquery/texosquery.jar and b/Master/texmf-dist/scripts/texosquery/texosquery.jar differ diff --git a/Master/texmf-dist/scripts/texosquery/texosquery.sh b/Master/texmf-dist/scripts/texosquery/texosquery.sh index db9f8addfab..d230c4c1999 100755 --- a/Master/texmf-dist/scripts/texosquery/texosquery.sh +++ b/Master/texmf-dist/scripts/texosquery/texosquery.sh @@ -1,5 +1,11 @@ #!/bin/sh -jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery.jar` +kernel=`uname -s` +if test "${kernel#*CYGWIN}" != "$kernel" +then + jarpath=`cygpath -w $(kpsewhich --progname=texosquery --format=texmfscripts texosquery.jar)` +else + jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery.jar` +fi java -jar "$jarpath" "$@" diff --git a/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java b/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java index 5e371b56ab2..5641b6546f4 100644 --- a/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java +++ b/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java @@ -790,6 +790,17 @@ public class TeXOSQuery implements Serializable filename = filename.replaceAll("\\\\", "/"); } + // Does a prefix need stripping? + + if (stripFilePrefix != null && filename.startsWith(stripFilePrefix)) + { + filename = filename.substring(stripFilePrefix.length()); + } + else if (pathRegExp != null && pathReplacement != null) + { + filename = filename.replaceFirst(pathRegExp, pathReplacement); + } + return escapeFileName(filename); } @@ -1553,7 +1564,18 @@ public class TeXOSQuery implements Serializable try { - return escapeFileName(file.getCanonicalFile().toURI().toString()); + String uri = file.getCanonicalFile().toURI().toString(); + + if (stripURIPrefix != null && uri.startsWith("file:/"+stripURIPrefix)) + { + uri = "file:/"+uri.substring(6+stripURIPrefix.length()); + } + else if (uriRegExp != null && uriReplacement != null) + { + uri = uri.replaceFirst(uriRegExp, uriReplacement); + } + + return escapeFileName(uri); } catch (Exception exception) { @@ -3713,6 +3735,47 @@ public class TeXOSQuery implements Serializable System.out.println(String.format("\t%d: version 1.%d", i, i)); } + System.out.println(); + + System.out.println("--strip-path-prefix or -sp "); + System.out.println("\tStrip the given prefix from returned path names."); + System.out.println("\tCan't be used with --replace-path."); + System.out.println(); + + System.out.println("--nostrip-path-prefix"); + System.out.println("\tCancel the effect of --strip-path-prefix."); + System.out.println(); + + System.out.println("--replace-path or -rp "); + System.out.println("\tSubstitutes the first occurrence of with"); + System.out.println("\t in any returned path names."); + System.out.println("\tCan't be used with --strip-path-prefix."); + System.out.println(); + + System.out.println("--noreplace-path"); + System.out.println("\tCancel the effect of --replace-path."); + System.out.println(); + + System.out.println("--strip-uri-prefix or -su "); + System.out.println("\tReplace 'file:/' with 'file:/'"); + System.out.println("\tfrom returned URIs."); + System.out.println("\tCan't be used with --replace-uri."); + System.out.println(); + + System.out.println("--nostrip-uri-prefix"); + System.out.println("\tCancel the effect of --strip-uri-prefix."); + System.out.println(); + + System.out.println("--replace-uri or -ru "); + System.out.println("\tSubstitutes the first occurrence of with"); + System.out.println("\t in any returned URIs."); + System.out.println("\tCan't be used with --strip-uri-prefix."); + System.out.println(); + + System.out.println("--noreplace-uri"); + System.out.println("\tCancel the effect of --replace-uri."); + System.out.println(); + System.out.println(); System.out.println("General actions:"); System.out.println(); @@ -3959,7 +4022,7 @@ public class TeXOSQuery implements Serializable } } } - else if (args[i].equals("--compatible") || args[i].equals("-compat")) + else if (isArg(args[i], "compat", "compatible")) { if (actions.size() > 0) { @@ -3993,6 +4056,166 @@ public class TeXOSQuery implements Serializable } } } + else if (isArg(args[i], "sp", "strip-path-prefix")) + { + if (actions.size() > 0) + { + throw new IllegalArgumentException(String.format( + "Options must come before actions. Found option: %s", args[i])); + } + + if (pathRegExp != null) + { + throw new IllegalArgumentException(String.format( + "Option clash: %s and --replace-path", args[i])); + } + + i = parseArgVal(args, i, argVal); + + if (argVal[1] == null) + { + throw new IllegalArgumentException(String.format( + " expected after: %s", args[i])); + } + + stripFilePrefix = (String)argVal[1]; + } + else if (isArg(args[i], "nostrip-path-prefix")) + { + if (actions.size() > 0) + { + throw new IllegalArgumentException(String.format( + "Options must come before actions. Found option: %s", args[i])); + } + + stripFilePrefix = null; + } + else if (isArg(args[i], "rp", "replace-path")) + { + if (actions.size() > 0) + { + throw new IllegalArgumentException(String.format( + "Options must come before actions. Found option: %s", args[i])); + } + + if (stripFilePrefix != null) + { + throw new IllegalArgumentException(String.format( + "Option clash: --strip-path-prefix and %s", args[i])); + } + + i = parseArgVal(args, i, argVal); + + pathRegExp = (String)argVal[1]; + + if (pathRegExp == null) + { + throw new IllegalArgumentException(String.format( + " expected after: %s", args[i])); + } + + i = parseArgVal(args, i, argVal); + + pathReplacement = (String)argVal[1]; + + if (pathReplacement == null) + { + throw new IllegalArgumentException(String.format( + " expected after: %s %s", args[i], pathRegExp)); + } + + } + else if (isArg(args[i], "noreplace-path")) + { + if (actions.size() > 0) + { + throw new IllegalArgumentException(String.format( + "Options must come before actions. Found option: %s", args[i])); + } + + pathRegExp = null; + pathReplacement = null; + } + else if (isArg(args[i], "su", "strip-uri-prefix")) + { + if (actions.size() > 0) + { + throw new IllegalArgumentException(String.format( + "Options must come before actions. Found option: %s", args[i])); + } + + if (uriRegExp != null) + { + throw new IllegalArgumentException(String.format( + "Option clash: %s and --replace-uri", args[i])); + } + + i = parseArgVal(args, i, argVal); + + if (argVal[1] == null) + { + throw new IllegalArgumentException(String.format( + " expected after: %s", args[i])); + } + + stripURIPrefix = (String)argVal[1]; + } + else if (isArg(args[i], "nostrip-uri-prefix")) + { + if (actions.size() > 0) + { + throw new IllegalArgumentException(String.format( + "Options must come before actions. Found option: %s", args[i])); + } + + stripURIPrefix = null; + } + else if (isArg(args[i], "ru", "replace-uri")) + { + if (actions.size() > 0) + { + throw new IllegalArgumentException(String.format( + "Options must come before actions. Found option: %s", args[i])); + } + + if (stripURIPrefix != null) + { + throw new IllegalArgumentException(String.format( + "Option clash: --strip-uri-prefix and %s", args[i])); + } + + i = parseArgVal(args, i, argVal); + + uriRegExp = (String)argVal[1]; + + if (uriRegExp == null) + { + throw new IllegalArgumentException(String.format( + " expected after: %s", args[i])); + } + + i = parseArgVal(args, i, argVal); + + uriReplacement = (String)argVal[1]; + + if (uriReplacement == null) + { + throw new IllegalArgumentException(String.format( + " expected after: %s %s", args[i], uriRegExp)); + } + + } + else if (isArg(args[i], "noreplace-uri")) + { + if (actions.size() > 0) + { + throw new IllegalArgumentException(String.format( + "Options must come before actions. Found option: %s", args[i])); + } + + uriRegExp = null; + uriReplacement = null; + } else { throw new IllegalArgumentException(String.format( @@ -4312,8 +4535,8 @@ public class TeXOSQuery implements Serializable public static final int DEFAULT_COMPATIBLE=2; - private static final String VERSION_NUMBER = "1.4"; - private static final String VERSION_DATE = "2017-05-05"; + private static final String VERSION_NUMBER = "1.5"; + private static final String VERSION_DATE = "2017-05-23"; private static final char BACKSLASH = '\\'; private static final long ZERO = 0L; @@ -4335,6 +4558,31 @@ public class TeXOSQuery implements Serializable private File texmfoutput = null; + /** + * If not null, strip from the start of returned path names. + * @since 1.5 + */ + private String stripFilePrefix = null; + + /** + *Instead of using the above, provide a regular expression and replacement. + * @since 1.5 + */ + private String pathRegExp=null, pathReplacement=null; + + /** + * If not null, strip from the start of returned URI path names + * (after file:/). + * @since 1.5 + */ + private String stripURIPrefix = null; + + /** + *Instead of using the above, provide a regular expression and replacement. + * @since 1.5 + */ + private String uriRegExp=null, uriReplacement=null; + /** * Debug level. (0 = no debugging, 1 or more print error messages to * STDERR, 2 or more include stack trace, 3 or more include diff --git a/Master/texmf-dist/source/support/texosquery/texosquery.dtx b/Master/texmf-dist/source/support/texosquery/texosquery.dtx index b3ec60201a0..d85b92ad1dd 100644 --- a/Master/texmf-dist/source/support/texosquery/texosquery.dtx +++ b/Master/texmf-dist/source/support/texosquery/texosquery.dtx @@ -81,6 +81,8 @@ \newcommand*{\longarg}[1]{\longargfmt{#1}% \index{texosquery options=\app{texosquery} options>#1=\protect\longargfmt{#1}|hyperpage}} +\newcommand*{\Index}[1]{#1\index{#1|hyperpage}} + \newenvironment{important} {\begin{quote}\textbf{Important Note:}} {\end{quote}} @@ -125,7 +127,7 @@ Organization for Standardization} %\author{Nicola L. C. Talbot\\ %\href{http://www.dickimaw-books.com/}{\nolinkurl{dickimaw-books.com}} %\and Paulo Cereda} -%\date{2017-05-05 (v1.4)} +%\date{2017-05-23 (v1.5)} %\maketitle % %\begin{abstract} @@ -646,6 +648,21 @@ Organization for Standardization} %For the full list of shortcut commands, see the %definition of \hyperlink{enableshortcs}{\cs{@texosquery@enableshortcs}}. % +%If the operating system uses a backslash \verb|\| as a directory +%divider, returned path names will always replace this with a +%forward slash \verb|/| (which is then converted to \cs{fslh}, as +%described above). This is designed to make the result as compatible +%as possible with \TeX\ file commands (such as \cs{input}) which +%require a forward slash. However, for some systems, +%further modification may need to be done. For example, with \TeX\ +%on \Index{Cygwin}, the Windows path name +%\verb|c:\cygwin64\usr\local\texlive| may correspond to the \TeX\ path +%name \file{/usr/local/texlive}. This path is returned by +%\app{texosquery} as \file{c:/cygwin64/usr/local/texlive} (\cs{fcln} and +%\cs{fslh} replaced for clarity). You can use +%\longargfmt{strip-path-prefix} to strip the leading +%\file{c:/cygwin64} for convenience (see section~\ref{sec:invocation}). +% %The output produced by the \app{texosquery} application %will be returned using the system's default input %encoding. (For example, \gls{UTF}-8.) You will need to ensure that your \TeX\ @@ -739,7 +756,7 @@ Organization for Standardization} %provided by Java. For example, Java currently doesn't %provide any methods to access telephone codes. % -%\subsection{Command line invocation} +%\subsection{Command line invocation}\label{sec:invocation} %The syntax for the command line invocation of \app{texosquery} %is: %\begin{definition} @@ -760,10 +777,13 @@ Organization for Standardization} %\begin{description} %\item[\shortarg{h} or \longarg{help} or \shortarg{help}] Displays help message and %exits. +% %\item[\shortarg{v} or \longarg{version} or \shortarg{version}] Displays version %information and exits. +% %\item[\longarg{nodebug}] No debugging information. Only command %line syntax errors are written to STDERR. (Default.) +% %\item[\longarg{debug} \oarg{n} or \shortarg{debug} \oarg{n}] Set the debugging level, where %\meta{n} is a non-negative integer. %If \meta{n} is omitted, 3 is assumed. If \meta{n} is 0, then @@ -772,10 +792,11 @@ Organization for Standardization} %written to STDERR. If \meta{n} $\geq 2$, any exceptions encountered %will additionally write the stack trace to STDERR. If \meta{n} %$\geq 3$ non-error informational messages are included. +% %\item[\longarg{compatible} \meta{n} or \shortarg{compat} \meta{n}] %Set the compatibility mode. %The argument should be either a non-negative integer (0 for version -%1.0, 1 for version 1.1, etc) or the keyword \texttt{latest} to +%1.0, 1 for version 1.1, 2 for version 1.2 onwards) or the keyword \texttt{latest} to %indicate the latest version (default). Note that the compatibility %mode only affects the available actions and the display style of the %result, and does not change security features. For example, the check for the @@ -783,6 +804,65 @@ Organization for Standardization} %is still checked even if the compatibility mode is set to 0 or 1. %\end{description} % +%The following options (introduced in v1.5) allow returned paths or URIs +%to be altered (for example, if a mount point needs to be removed). +%Note that these options only affect \emph{returned} paths, not +%path names provided in the command line. The substitution is +%performed after any backslash directory dividers +%\verb|\| are changed to forward slashes \texttt{/} (if applicable) but before +%non-alphanumerics are changed to control sequences (such as +%\cs{fcln} or \cs{fslh}). If there's no match, the path is returned +%without alteration. +% +%\begin{description} +%\item[\longarg{strip-path-prefix} \meta{prefix} or \shortarg{sp} +%\meta{prefix}] +%Strip \meta{prefix} from the start of returned path names (but +%not URIs, see below). For example: +%\begin{verbatim} +%texosquery --strip-path-prefix c:/cygwin64 -p article.cls +%\end{verbatim} +%This will strip the \texttt{c:/cygwin64} mount point. Note that +%\meta{prefix} isn't an expression. For a regular expression, use +%\longarg{replace-path}. (This option can't be +%used with \longarg{replace-path}.) +% +%\item[\longarg{nostrip-path-prefix}] +%Cancels the effect of \longarg{strip-path-prefix}. +% +%\item[\longarg{replace-path} \meta{regex} \meta{replacement} +%or \shortarg{rp} \meta{regex} \meta{replacement}] +%This replaces the \emph{first} occurrence of the regular +%expression \meta{regex} in any returned path (but not URI) and replaces it with +%\meta{replacement}. +% +%\item[\longarg{noreplace-path}] +%Cancels the effect of the \longarg{replace-path}. +% +%\item[\longarg{strip-uri-prefix} \meta{prefix} or \shortarg{su} +%\meta{prefix}] +%Replace initial \texttt{file:/}\meta{prefix} with just +%\texttt{file:/} from returned URIs. Note that +%\meta{prefix} isn't an expression. For a regular expression, use +%\longarg{replace-uri}. (This option can't be +%used with \longarg{replace-uri}.) +% +%\item[\longarg{nostrip-uri-prefix}] +%Cancels the effect of \longarg{strip-uri-prefix}. +% +%\item[\longarg{replace-uri} \meta{regex} \meta{replacement} +%or \shortarg{ru} \meta{regex} \meta{replacement}] +%This replaces the \emph{first} occurrence of the regular +%expression \meta{regex} in any returned URI and replaces it with +%\meta{replacement}. For example: +%\begin{verbatim} +%texosquery -ru file:/C: file://cgwin64/c -u filename +%\end{verbatim} +% +%\item[\longarg{noreplace-uri}] +%Cancels the effect of the \longarg{replace-uri}. +%\end{description} +% %If multiple actions are given, they will be processed in the %order specified in the command line invocation. Each result will %be displayed on a separate line. As from v1.1, if there are @@ -2547,7 +2627,7 @@ Organization for Standardization} % \end{macrocode} % Version info. % \begin{macrocode} -\expandafter\def\csname ver@texosquery.tex\endcsname{2017/05/05 v1.4 (NLCT)} +\expandafter\def\csname ver@texosquery.tex\endcsname{2017/05/23 v1.5 (NLCT)} % \end{macrocode} % %\begin{macro}{\@texosquery@warn} @@ -7825,7 +7905,7 @@ Organization for Standardization} %Identify package: % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{texosquery}[2017/05/05 v1.4 (NLCT)] +\ProvidesPackage{texosquery}[2017/05/23 v1.5 (NLCT)] % \end{macrocode} %Load \file{texosquery.tex}: % \begin{macrocode} @@ -7846,37 +7926,38 @@ Organization for Standardization} % \end{macrocode} %\fi % \begin{macrocode} - % This configuration file must be edited to match your system. - % Copy the file to your TEXMFLOCAL or TEXMFHOME tree to prevent it - % from being overwritten by updates. - - % 1. Check your version of Java. To do this run - % java -version - % from your command line. +%<