texlive[44656] Master/texmf-dist: texosquery (20jun17)

commits+karl at tug.org commits+karl at tug.org
Wed Jun 21 00:18:21 CEST 2017


Revision: 44656
          http://tug.org/svn/texlive?view=revision&revision=44656
Author:   karl
Date:     2017-06-21 00:18:21 +0200 (Wed, 21 Jun 2017)
Log Message:
-----------
texosquery (20jun17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/support/texosquery/CHANGES
    trunk/Master/texmf-dist/doc/support/texosquery/texosquery.pdf
    trunk/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar
    trunk/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar
    trunk/Master/texmf-dist/scripts/texosquery/texosquery.jar
    trunk/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java
    trunk/Master/texmf-dist/source/support/texosquery/texosquery.dtx
    trunk/Master/texmf-dist/tex/latex/texosquery/texosquery.sty
    trunk/Master/texmf-dist/tex/latex/texosquery/texosquery.tex

Modified: trunk/Master/texmf-dist/doc/support/texosquery/CHANGES
===================================================================
--- trunk/Master/texmf-dist/doc/support/texosquery/CHANGES	2017-06-20 22:18:03 UTC (rev 44655)
+++ trunk/Master/texmf-dist/doc/support/texosquery/CHANGES	2017-06-20 22:18:21 UTC (rev 44656)
@@ -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:

Modified: trunk/Master/texmf-dist/doc/support/texosquery/texosquery.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/texosquery/texosquery.jar
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java
===================================================================
--- trunk/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java	2017-06-20 22:18:03 UTC (rev 44655)
+++ trunk/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java	2017-06-20 22:18:21 UTC (rev 44656)
@@ -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.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,13 +1843,22 @@
     */ 
    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)
       {
          // If conversion is required, change to lower case
@@ -3737,6 +3741,16 @@
 
       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 @@
             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 @@
            "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 @@
             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 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 @@
    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.)

Modified: trunk/Master/texmf-dist/source/support/texosquery/texosquery.dtx
===================================================================
--- trunk/Master/texmf-dist/source/support/texosquery/texosquery.dtx	2017-06-20 22:18:03 UTC (rev 44655)
+++ trunk/Master/texmf-dist/source/support/texosquery/texosquery.dtx	2017-06-20 22:18:21 UTC (rev 44656)
@@ -127,7 +127,7 @@
 %\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 @@
 %\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,27 +682,16 @@
 %\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.
+%or for all documents by editing the \file{texosquery.cfg} file to
+%include the option in the invoker command.
 %
-%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.
-%
 %\subsection{Locales}
 %\label{sec:locales}
 %The options that have a locale identifier as an argument need the
@@ -802,6 +791,20 @@
 %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 @@
 % 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,7 +960,31 @@
 %\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}}
 %
 %(New to version 1.2.)
@@ -967,9 +997,14 @@
 %\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 @@
 %\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 @@
 %    \end{macrocode}
 % Version info.
 %    \begin{macrocode}
-\expandafter\def\csname ver at texosquery.tex\endcsname{2017/05/23 v1.5 (NLCT)}
+\expandafter\def\csname ver at texosquery.tex\endcsname{2017/06/20 v1.6 (NLCT)}
 %    \end{macrocode}
 %
 %\begin{macro}{\@texosquery at warn}
@@ -7905,7 +7941,7 @@
 %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}

Modified: trunk/Master/texmf-dist/tex/latex/texosquery/texosquery.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/texosquery/texosquery.sty	2017-06-20 22:18:03 UTC (rev 44655)
+++ trunk/Master/texmf-dist/tex/latex/texosquery/texosquery.sty	2017-06-20 22:18:21 UTC (rev 44656)
@@ -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
 %%

Modified: trunk/Master/texmf-dist/tex/latex/texosquery/texosquery.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/texosquery/texosquery.tex	2017-06-20 22:18:03 UTC (rev 44655)
+++ trunk/Master/texmf-dist/tex/latex/texosquery/texosquery.tex	2017-06-20 22:18:21 UTC (rev 44656)
@@ -55,7 +55,7 @@
   \@texosquery at restore@at
   \expandafter\endinput
 \fi
-\expandafter\def\csname ver at texosquery.tex\endcsname{2017/05/23 v1.5 (NLCT)}
+\expandafter\def\csname ver at texosquery.tex\endcsname{2017/06/20 v1.6 (NLCT)}
 \ifx\@tracklang at pkgwarn\undefined
   \ifx\PackageWarning\undefined
     \def\@texosquery at warn#1{%



More information about the tex-live-commits mailing list