summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-06-20 22:18:21 +0000
committerKarl Berry <karl@freefriends.org>2017-06-20 22:18:21 +0000
commit381a2772b732af0410b61e1ececa1af3a84a2068 (patch)
treebd7c9df3443fa42370c8757f8e40fb14ad8916a9
parentd1d17eb787a0c0122a9180855c1b73f0d9a87416 (diff)
texosquery (20jun17)
git-svn-id: svn://tug.org/texlive/trunk@44656 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/support/texosquery/CHANGES9
-rw-r--r--Master/texmf-dist/doc/support/texosquery/texosquery.pdfbin504391 -> 505685 bytes
-rwxr-xr-xMaster/texmf-dist/scripts/texosquery/texosquery-jre5.jarbin64238 -> 65360 bytes
-rwxr-xr-xMaster/texmf-dist/scripts/texosquery/texosquery-jre8.jarbin68617 -> 69775 bytes
-rwxr-xr-xMaster/texmf-dist/scripts/texosquery/texosquery.jarbin67602 -> 68756 bytes
-rw-r--r--Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java111
-rw-r--r--Master/texmf-dist/source/support/texosquery/texosquery.dtx86
-rw-r--r--Master/texmf-dist/tex/latex/texosquery/texosquery.sty2
-rw-r--r--Master/texmf-dist/tex/latex/texosquery/texosquery.tex2
9 files changed, 170 insertions, 40 deletions
diff --git a/Master/texmf-dist/doc/support/texosquery/CHANGES b/Master/texmf-dist/doc/support/texosquery/CHANGES
index 7ad4e4b80fa..90a16eff9f4 100644
--- a/Master/texmf-dist/doc/support/texosquery/CHANGES
+++ b/Master/texmf-dist/doc/support/texosquery/CHANGES
@@ -1,3 +1,12 @@
+1.6 (2017/06/20):
+
+ * Added new command line options:
+ --encoding (-enc)
+ --default-encoding (-defenc)
+
+ * Added new command line action:
+ --codeset (-cs)
+
1.5 (2017/05/23):
* Added new command line options:
diff --git a/Master/texmf-dist/doc/support/texosquery/texosquery.pdf b/Master/texmf-dist/doc/support/texosquery/texosquery.pdf
index de4af936863..51aee9d372d 100644
--- a/Master/texmf-dist/doc/support/texosquery/texosquery.pdf
+++ b/Master/texmf-dist/doc/support/texosquery/texosquery.pdf
Binary files differ
diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar
index 079a82eeb12..bab442ce48a 100755
--- a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar
+++ b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar
Binary files differ
diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar
index 8bd7ccec1f9..c3bb8f54e6c 100755
--- a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar
+++ b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar
Binary files differ
diff --git a/Master/texmf-dist/scripts/texosquery/texosquery.jar b/Master/texmf-dist/scripts/texosquery/texosquery.jar
index e615b37761c..39230459621 100755
--- a/Master/texmf-dist/scripts/texosquery/texosquery.jar
+++ b/Master/texmf-dist/scripts/texosquery/texosquery.jar
Binary files differ
diff --git a/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java b/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java
index 5641b6546f4..9f97e858862 100644
--- a/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java
+++ b/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java
@@ -12,7 +12,7 @@
*/
package com.dickimawbooks.texosquery;
-import java.io.BufferedReader;
+import java.io.*;
import java.util.Locale;
import java.util.Calendar;
import java.util.Date;
@@ -28,12 +28,7 @@ import java.text.SimpleDateFormat;
import java.text.DateFormatSymbols;
import java.text.NumberFormat;
import java.text.DecimalFormat;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Serializable;
+import java.nio.charset.*;
/**
* Application functions. These methods need to be Java version 1.5
@@ -1848,12 +1843,21 @@ public class TeXOSQuery implements Serializable
*/
public String getCodeSet(boolean convertCodeset)
{
- // Get the OS default file encoding or "UTF-8" if not set.
+ String codeset;
- String codeset = getSystemProperty("file.encoding", "UTF-8");
+ if (fileEncoding != null)
+ {
+ codeset = fileEncoding;
+ }
+ else
+ {
+ // Get the OS default file encoding or "UTF-8" if not set.
- // The codeset should not be null here as a default has
- // been provided if the property is missing.
+ codeset = getSystemProperty("file.encoding", "UTF-8");
+
+ // The codeset should not be null here as a default has
+ // been provided if the property is missing.
+ }
if (convertCodeset)
{
@@ -3737,6 +3741,16 @@ public class TeXOSQuery implements Serializable
System.out.println();
+ System.out.println("--encoding <charset> or -enc <charset>");
+ System.out.println("\tSet the file encoding to <charset>.");
+
+ System.out.println();
+
+ System.out.println("--default-encoding or -defenc");
+ System.out.println("\tUse the default file encoding.");
+
+ System.out.println();
+
System.out.println("--strip-path-prefix <prefix> or -sp <prefix>");
System.out.println("\tStrip the given prefix from returned path names.");
System.out.println("\tCan't be used with --replace-path.");
@@ -4216,6 +4230,34 @@ public class TeXOSQuery implements Serializable
uriRegExp = null;
uriReplacement = null;
}
+ else if (isArg(args[i], "enc", "encoding"))
+ {
+ if (actions.size() > 0)
+ {
+ throw new IllegalArgumentException(String.format(
+ "Options must come before actions. Found option: %s", args[i]));
+ }
+
+ i = parseArgVal(args, i, argVal);
+
+ if (argVal[1] == null)
+ {
+ throw new IllegalArgumentException(String.format(
+ "<charset> expected after: %s", args[i]));
+ }
+
+ fileEncoding = (String)argVal[1];
+ }
+ else if (isArg(args[i], "defenc", "default-encoding"))
+ {
+ if (actions.size() > 0)
+ {
+ throw new IllegalArgumentException(String.format(
+ "Options must come before actions. Found option: %s", args[i]));
+ }
+
+ fileEncoding = null;
+ }
else
{
throw new IllegalArgumentException(String.format(
@@ -4231,6 +4273,35 @@ public class TeXOSQuery implements Serializable
"One or more actions required.%nTry %s --help", name));
}
+ if (fileEncoding != null)
+ {
+ // new to v1.6
+ try
+ {
+ // Change the encoding of STDOUT.
+ // This is done by setting STDOUT to the original system
+ // STDOUT (FileDescription.out) within a print stream that
+ // has the appropriate file encoding.
+
+ // (This is more useful that setting file.encoding when
+ // the Java virtual machine starts up as this can be done on
+ // a per-document basis. Otherwise it requires editing
+ // the script that invokes the JVM.)
+
+ PrintStream stream = new PrintStream(
+ new FileOutputStream(FileDescriptor.out),
+ true, // auto flush
+ fileEncoding);
+
+ System.setOut(stream);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new IllegalArgumentException("VM does not support encoding "
+ +fileEncoding, e);
+ }
+ }
+
for (QueryAction action : actions)
{
try
@@ -4333,6 +4404,14 @@ public class TeXOSQuery implements Serializable
return getLocale(Locale.getDefault(), true);
}
},
+ new QueryAction("codeset", "cs", QueryActionType.GENERAL_ACTION,
+ "Display the codeset", 2)
+ {// new to v1.6
+ public String action()
+ {
+ return escapeFileName(getCodeSet(false));
+ }
+ },
new QueryAction("codeset-lcs", "C", QueryActionType.GENERAL_ACTION,
"Lower case codeset with hyphens stripped", 2)
{
@@ -4535,8 +4614,8 @@ public class TeXOSQuery implements Serializable
public static final int DEFAULT_COMPATIBLE=2;
- private static final String VERSION_NUMBER = "1.5";
- private static final String VERSION_DATE = "2017-05-23";
+ private static final String VERSION_NUMBER = "1.6";
+ private static final String VERSION_DATE = "2017-06-20";
private static final char BACKSLASH = '\\';
private static final long ZERO = 0L;
@@ -4584,6 +4663,12 @@ public class TeXOSQuery implements Serializable
private String uriRegExp=null, uriReplacement=null;
/**
+ *Charset for stdout (allows user to override default)
+ * @since 1.6
+ */
+ private String fileEncoding=null;
+
+ /**
* Debug level. (0 = no debugging, 1 or more print error messages to
* STDERR, 2 or more include stack trace, 3 or more include
* informational messages.)
diff --git a/Master/texmf-dist/source/support/texosquery/texosquery.dtx b/Master/texmf-dist/source/support/texosquery/texosquery.dtx
index d85b92ad1dd..e35098d78d9 100644
--- a/Master/texmf-dist/source/support/texosquery/texosquery.dtx
+++ b/Master/texmf-dist/source/support/texosquery/texosquery.dtx
@@ -127,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-23 (v1.5)}
+%\date{2017-06-20 (v1.6)}
%\maketitle
%
%\begin{abstract}
@@ -664,7 +664,7 @@ Organization for Standardization}
%\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
+%will be returned using the system's default file
%encoding. (For example, \gls{UTF}-8.) You will need to ensure that your \TeX\
%document uses the same encoding if you want to typeset any of the
%results that may contain non-ASCII characters. You can determine
@@ -682,26 +682,15 @@ Organization for Standardization}
%\sty{inputenc} and \sty{fontenc}. \XeLaTeX\ and \LuaLaTeX\ users may need to load
%\sty{fontspec}.
%
-%You can change the default encoding by invoking the Java Virtual
-%Machine with the option \texttt{-Dfile.encoding=}\meta{codeset}.
-%For example, bash users can modify the \file{texosquery} script to set the encoding to \gls*{UTF}-8 as follows:
+%As from version 1.6, you can now override the default encoding
+%using the \longarg{encoding} option. This can be set on a document basis,
+%for example:
%\begin{verbatim}
-%#!/bin/sh
-%
-%jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery.jar`
-%java -Dfile.encoding=UTF-8 -jar "$jarpath" "$@"
+%\usepackage[utf8]{inputenc}
+%\TeXOSQuery{\result}{--encoding UTF-8 -N}
%\end{verbatim}
-%Similarly for the corresponding \file{.bat} file for Windows users.
-%
-%If the script file can't be modified or you have only \file{.exe}
-%instead of \file{.jar} files then you can set the
-%\href{https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#tooloptions}{\texttt{JAVA\_TOOL\_OPTIONS} environment variable}.
-%For example:
-%\begin{verbatim}
-%declare -x JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
-%\end{verbatim}
-%Note that, unlike the edit to the bash or \file{.bat} file, this will
-%affect all your Java applications.
+%or for all documents by editing the \file{texosquery.cfg} file to
+%include the option in the invoker command.
%
%\subsection{Locales}
%\label{sec:locales}
@@ -802,6 +791,20 @@ Organization for Standardization}
%result, and does not change security features. For example, the check for the
%\texttt{openin\_any} setting was only introduced to version 1.2, but this
%is still checked even if the compatibility mode is set to 0 or 1.
+%
+%\item[\longarg{encoding} \meta{charset} or \shortarg{enc}
+%\meta{charset}]
+%(New to version 1.6.) This option may be used to override the
+%default file encoding. For example, if your native file encoding is
+%CP1250, but your document uses UTF-8 then you'll need to use
+%\longarg{encoding}\texttt{ UTF-8}.
+%
+%\item[\longarg{default-encoding} or \shortarg{defenc}]
+%(New to version 1.6.) This option is the default, but may
+%be used to cancel the effect of \longarg{encoding}. (For example, if
+%you have added \longarg{encoding} to the invoker command in the
+%\file{texosquery.cfg} file, but you want to cancel it in a
+%particular document.)
%\end{description}
%
%The following options (introduced in v1.5) allow returned paths or URIs
@@ -946,6 +949,9 @@ Organization for Standardization}
% returned using the control sequences \cs{fhyn} (hyphen), \cs{fdot}
% (dot) and \cs{fatc} (at).
%
+%If the \longarg{encoding} option is used, the codeset will reflect
+%that value.
+%
%\subsubsection{Action \shortarg{l} or \longarg{locale-lcs}}
%
%This action is similar to \longarg{locale}, but the codeset is converted to
@@ -954,6 +960,30 @@ Organization for Standardization}
%\texttt{en-GB.utf8}. As above, the punctuation characters will actually be
% returned using the control sequences \cs{fhyn} (hyphen), \cs{fdot}
% (dot) and \cs{fatc} (at).
+%Again, if the \longarg{encoding} option is used, the codeset will reflect
+%that value.
+%
+%\subsubsection{Action \shortarg{cs} or \longarg{codeset}}
+%
+%(New to version 1.6.) This action returns just the codeset.
+%For example, my default file encoding is \gls{UTF}-8, so
+%\begin{verbatim}
+%texosquery --codeset
+%\end{verbatim}
+%returns
+%\begin{verbatim}
+%UTF-8
+%\end{verbatim}
+%whereas
+%\begin{verbatim}
+%texosquery --encoding ISO-8859-1 --codeset
+%\end{verbatim}
+%returns
+%\begin{verbatim}
+%ISO-8859-1
+%\end{verbatim}
+%(In both the above examples, the hyphen character is actually
+%returned as the control sequence \cs{fhyn}.)
%
%\subsubsection{Action \shortarg{C} or \longarg{codeset-lcs}}
%
@@ -967,9 +997,14 @@ Organization for Standardization}
%\begin{verbatim}
%utf8
%\end{verbatim}
-%This action is used by the \sty{locale} package to determine the
-%option to use when it needs to automatically load the
-%\sty{inputenc} package.
+%whereas
+%\begin{verbatim}
+%texosquery --encoding ISO-8859-1 -C
+%\end{verbatim}
+%returns
+%\begin{verbatim}
+%iso88591
+%\end{verbatim}
%
%\subsubsection{Action \shortarg{o} or \longarg{osname}}
%
@@ -2094,6 +2129,7 @@ Organization for Standardization}
%\begin{definition}
%\cs{TeXOSQuery}\marg{cs}\{\shortarg{C}\}
%\end{definition}
+%Similarly for the unprocessed codeset (\longarg{encoding}).
%
%The \gls{IETF} \gls{BCP}~47 language tag (\shortarg{b} or \longarg{bcp47})
%can be obtained using:
@@ -2627,7 +2663,7 @@ Organization for Standardization}
% \end{macrocode}
% Version info.
% \begin{macrocode}
-\expandafter\def\csname ver@texosquery.tex\endcsname{2017/05/23 v1.5 (NLCT)}
+\expandafter\def\csname ver@texosquery.tex\endcsname{2017/06/20 v1.6 (NLCT)}
% \end{macrocode}
%
%\begin{macro}{\@texosquery@warn}
@@ -7905,7 +7941,7 @@ Organization for Standardization}
%Identify package:
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{texosquery}[2017/05/23 v1.5 (NLCT)]
+\ProvidesPackage{texosquery}[2017/06/20 v1.6 (NLCT)]
% \end{macrocode}
%Load \file{texosquery.tex}:
% \begin{macrocode}
diff --git a/Master/texmf-dist/tex/latex/texosquery/texosquery.sty b/Master/texmf-dist/tex/latex/texosquery/texosquery.sty
index 2f7432f43b3..3d7638ae000 100644
--- a/Master/texmf-dist/tex/latex/texosquery/texosquery.sty
+++ b/Master/texmf-dist/tex/latex/texosquery/texosquery.sty
@@ -44,7 +44,7 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{texosquery}[2017/05/23 v1.5 (NLCT)]
+\ProvidesPackage{texosquery}[2017/06/20 v1.6 (NLCT)]
\input{texosquery}
\endinput
%%
diff --git a/Master/texmf-dist/tex/latex/texosquery/texosquery.tex b/Master/texmf-dist/tex/latex/texosquery/texosquery.tex
index d490c4566d8..ebda9b227af 100644
--- a/Master/texmf-dist/tex/latex/texosquery/texosquery.tex
+++ b/Master/texmf-dist/tex/latex/texosquery/texosquery.tex
@@ -55,7 +55,7 @@
\@texosquery@restore@at
\expandafter\endinput
\fi
-\expandafter\def\csname ver@texosquery.tex\endcsname{2017/05/23 v1.5 (NLCT)}
+\expandafter\def\csname ver@texosquery.tex\endcsname{2017/06/20 v1.6 (NLCT)}
\ifx\@tracklang@pkgwarn\undefined
\ifx\PackageWarning\undefined
\def\@texosquery@warn#1{%