From 5f24b7cfebd86d4ec19ff264e850d9e14c193fed Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 22 Nov 2007 18:58:32 +0000 Subject: new latex package ifplatform (20nov07) git-svn-id: svn://tug.org/texlive/trunk@5555 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/ifplatform/README | 22 ++ .../texmf-dist/doc/latex/ifplatform/ifplatform.pdf | Bin 0 -> 101106 bytes .../source/latex/ifplatform/ifplatform.dtx | 293 +++++++++++++++++++++ .../source/latex/ifplatform/ifplatform.ins | 50 ++++ .../texmf-dist/tex/latex/ifplatform/ifplatform.sty | 83 ++++++ 5 files changed, 448 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/ifplatform/README create mode 100644 Master/texmf-dist/doc/latex/ifplatform/ifplatform.pdf create mode 100644 Master/texmf-dist/source/latex/ifplatform/ifplatform.dtx create mode 100644 Master/texmf-dist/source/latex/ifplatform/ifplatform.ins create mode 100644 Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/ifplatform/README b/Master/texmf-dist/doc/latex/ifplatform/README new file mode 100644 index 00000000000..698aa3f76af --- /dev/null +++ b/Master/texmf-dist/doc/latex/ifplatform/README @@ -0,0 +1,22 @@ +_____________________ +The ifplatform package +v0.2 2007/11/18 + +This package uses -shell-escape to establish whether +the document is being processed on Windows or a *NIX +platform (Mac OS X, Linux, etc.). + +Booleans provided are: + - ifwindows + - iflinux + - ifmacosx +Please request more platforms if you need them. + +Finally, the \platformname macro is also provided that +expands to a string of the platform name. + +Will Robertson wspr 81 at gmail dot com +Johannes Große + +Copyright 2007 +Distributed under the LaTeX Project Public License diff --git a/Master/texmf-dist/doc/latex/ifplatform/ifplatform.pdf b/Master/texmf-dist/doc/latex/ifplatform/ifplatform.pdf new file mode 100644 index 00000000000..d253aab20e6 Binary files /dev/null and b/Master/texmf-dist/doc/latex/ifplatform/ifplatform.pdf differ diff --git a/Master/texmf-dist/source/latex/ifplatform/ifplatform.dtx b/Master/texmf-dist/source/latex/ifplatform/ifplatform.dtx new file mode 100644 index 00000000000..a220e684bb6 --- /dev/null +++ b/Master/texmf-dist/source/latex/ifplatform/ifplatform.dtx @@ -0,0 +1,293 @@ +%\iffalse +%<*internal> +\iffalse +% +%<*readme> +_____________________ +The ifplatform package +v0.2 2007/11/18 + +This package uses -shell-escape to establish whether +the document is being processed on Windows or a *NIX +platform (Mac OS X, Linux, etc.). + +Booleans provided are: + - ifwindows + - iflinux + - ifmacosx +Please request more platforms if you need them. + +Finally, the \platformname macro is also provided that +expands to a string of the platform name. + +Will Robertson wspr 81 at gmail dot com +Johannes Große + +Copyright 2007 +Distributed under the LaTeX Project Public License +% +%<*internal> +\fi +\begingroup +% +%<*batchfile> +\input docstrip.tex +\keepsilent +\preamble + ___________________________________________________ + Copyright (C) 2007 Will Robertson & Johannes Große + License information appended. +\endpreamble +\postamble +Copyright (C) 2007 by Will Robertson & Johannes Große + +Distributable under the LaTeX Project Public License, +version 1.3c or higher (your choice). The latest version of +this license is at: http://www.latex-project.org/lppl.txt + +This work is "maintained" (as per LPPL maintenance status) +by Will Robertson. + +This work consists of the file ifplatform.dtx + and the derived files ifplatform.pdf, + ifplatform.sty, and + ifplatform.ins. +\endpostamble +\askforoverwritefalse +\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}} +% +%\endbatchfile +%<*internal> +\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}} +\nopreamble\nopostamble +\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}} +\generate{\file{prepare.sh}{\from{\jobname.dtx}{prepare}}} +\endgroup +% +%<*driver> +\documentclass{ltxdoc} +\errorcontextlines=999 +\EnableCrossrefs +\CodelineIndex +\RecordChanges +%\OnlyDescription +\usepackage{array,booktabs,color,enumitem,hyperref} +\usepackage[sc,osf]{mathpazo} +\linespread{1.1} % A bit more space between lines +\frenchspacing % Remove ugly extra space after punctuation +\definecolor{niceblue}{rgb}{0.2,0.4,0.8} +\def\theCodelineNo{\textcolor{niceblue}{\sffamily\tiny\arabic{CodelineNo}}} +\newcommand*\pkg[1]{\textsf{#1}} +\hfuzz2pt +\usepackage{ifplatform}% for version info +\begin{document} +\DocInput{ifplatform.dtx} +\end{document} +% +%\fi +% +% \GetFileInfo{\jobname.sty} +% \CheckSum{0} +% \makeatletter +% +% \title{The \pkg{\jobname} package} +% \author{Code by Johannes Gro\ss{}e\\ +% Package by Will Robertson\\ +% \color[gray]{0.5} +% \texttt{wspr\,81\,at\,gmail\,dot\,com}} +% \date{\fileversion \qquad \filedate} +% +% \maketitle +% +% \section{About} +% This package provides the following conditionals to test +% which operating system is being used to run \TeX: +% \begin{itemize}[nolistsep,label=--] +% \item \cs{ifwindows} +% \item \cs{iflinux} +% \item \cs{ifmacosx} +% \end{itemize} +% +% \TeX\ must be invoked with the |-shell-escape| option (or equivalent) for the +% package to work. \cs{ifshellescape} is also provided to check +% whether this is the case. +% +% Also, the \cmd\platformname\ command is defined to expand to a +% macro that represents the operating system. Default definitions are (respectively): +% +% \begin{tabular}{@{}l@{\quad$\to$\quad}l} +% \cmd\windowsname & `Windows' \\ +% \cmd\linuxname & `Linux' \\ +% \cmd\macosxname & `Mac\,OS\,X' \\ +% \cmd\unknownplatform & \emph{whatever is returned by} |uname| \\ +% \end{tabular} +% +% \noindent Redefine these macros to customise +% the output of \cmd\platformname. +% \ifshellescape +% This documentation was compiled on \platformname. +% \fi +% +% \section{Other platforms} +% +% If greater granularity is required to differentiate between various \textsc{unix}-like operating systems, then \cmd\unknownplatform\ can be interrogated for the platform based on the output of |uname|. Table~\ref{table} lists possible outputs for a range of operating systems. +% +% For example, to test whether the AIX operating system is being used, you could use the following code: +% \begin{verbatim} +% \def\@tempa{aix6} +% \ifx\unknownplatform\@tempa +% ... AIX is being used .... +% \else +% ... or not ... +% \fi +% \end{verbatim} +% The \pkg{ifthen} and \pkg{xifthen} packages might be of interest to those who prefer more \LaTeX-like methods of conditional testing. +% +% \begin{table}[hp] +% \centering +% \begin{tabular}{@{}l>{\ttfamily}c@{}} +% \toprule +% Platform & uname \textrm{string} \\ +% \midrule +% AIX & {aix6} \\ +% Cray UNICOS & {sn5176} \\ +% FreeBSD & {FreeBSD} \\ +% HPUX & {HP-UX} \\ +% IRIX & {IRIX64} \\ +% Solaris & {SunOS} \\ +% OpenBSD & {OpenBSD} \\ +% \bottomrule +% \end{tabular} +% \caption{List of operating systems and their \texttt{uname} strings. Adapted from % \url{http://en.wikipedia.org/wiki/Uname}.} +% \label{table} +% \end{table} +% +% \clearpage +% \section{Implementation} +%\iffalse +%<*package> +%\fi +% \begin{macrocode} +\ProvidesPackage{ifplatform} + [2007/11/18 v0.2 Testing for the operating system] +% \end{macrocode} +% Conditionals we provide: +% \begin{macrocode} +\newif\ifshellescape +\newif\ifwindows +\newif\ifmacosx +\newif\iflinux +% \end{macrocode} +% Names of operating systems: +% \begin{macrocode} +\newcommand\windowsname{Windows} +\newcommand\linuxname{Linux} +\newcommand\macosxname{Mac\,OS\,X} +\newcommand\unknownplatform{[Unknown]} +% \end{macrocode} +% Define test file name and define a hopefully unique string: +% \begin{macrocode} +\edef\ip@file{\jobname.w18} +\edef\ip@sig{write18-test-\the\year\the\month\the\day\the\time} +\edef\ip@win{'\ip@sig'} +% \end{macrocode} +% Macro to read in a one-line file into a temporary location: +% \begin{macrocode} +\def\ip@read@file{% + \newread\instream + \openin\instream=\ip@file + \@tempcnta=\endlinechar + \endlinechar=-1 + \read\instream to\@tempa + \endlinechar=\@tempcnta + \closein\instream} +% \end{macrocode} +% Use echo to (maybe) write a test file. If it succeeds, continue; else, bail. +% \begin{macrocode} +\immediate\write18{echo \ip@win >"\ip@file"} +\IfFileExists{\ip@file}{\shellescapetrue}{\shellescapefalse\endinput} +% \end{macrocode} +% Now read the test file into a macro: +% \begin{macrocode} +\ip@read@file +% \end{macrocode} +% The contents of the test file reveals several things: +% \begin{itemize}[nolistsep,label=--] +% \item test string correct with single quotes: Windows, +% \item test string correct without single quotes: Linux/Mac OS X, +% \item test string not correct: did not really write test file, so \cmd\write18\ is not enabled. (This should never happen.) +% \end{itemize} +% \begin{macro}{\ifwindows} +% First test for Windows. +% \begin{macrocode} +\ifx\@tempa\ip@sig + \windowsfalse +\else + \ifx\@tempa\ip@win + \windowstrue + \else + \PackageError{ifplatform} + {There is a problem. Please delete the file \ip@file.} + {Somehow an old file is lying around telling me the wrong things. + \MessageBreak This should never happen. Please let us know when it does!} + \fi +\fi +% \end{macrocode} +% \end{macro} +% \begin{macro}{\iflinux} +% \begin{macro}{\ifmacosx} +% Now test for the others; directly test for Linux and Mac~OS~X; but what about Solaris or FreeBSD or \dots\ ? +% Define \cmd\unknownplatform\ as the output of |uname| rather than enumerate the possibilities. +% \begin{macrocode} +\ifwindows\else + \immediate\write18{uname -s > "\ip@file"} + \ip@read@file + \def\@tempb{Linux} + \ifx\@tempa\@tempb + \linuxtrue + \else + \def\@tempb{Darwin} + \ifx\@tempa\@tempb + \macosxtrue + \else + \edef\unknownplatform{\@tempa} + \fi + \fi +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\platformname} +% Defined in terms of macros so the output is user-customisable. +% \begin{macrocode} +\edef\platformname{% + \ifwindows\noexpand\windowsname\else + \iflinux \noexpand\linuxname\else + \ifmacosx \noexpand\macosxname\else + \noexpand\unknownplatform + \fi\fi\fi} +% \end{macrocode} +% \end{macro} +% Clean up: +% \begin{macrocode} +\immediate\write18{\ifwindows del \else rm -- \fi "\ip@file"} +% \end{macrocode} +%\iffalse +% +%<*prepare> +% \begin{macrocode} +rm ifplatform.zip +mv README.txt README +zip ifplatform.zip ifplatform.dtx ifplatform.ins ifplatform.pdf README +% \end{macrocode} +% +%\fi +% +% \typeout{------------------------------------------------------} +% \typeout{ To finish the installation please move the following} +% \typeout{ file into a directory searched by XeTeX:} +% \typeout{ \space- ifplatform.sty} +% \typeout{------------------------------------------------------} +% +\endinput diff --git a/Master/texmf-dist/source/latex/ifplatform/ifplatform.ins b/Master/texmf-dist/source/latex/ifplatform/ifplatform.ins new file mode 100644 index 00000000000..775c63664a7 --- /dev/null +++ b/Master/texmf-dist/source/latex/ifplatform/ifplatform.ins @@ -0,0 +1,50 @@ +%% +%% This is file `ifplatform.ins', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% ifplatform.dtx (with options: `batchfile') +%% ___________________________________________________ +%% Copyright (C) 2007 Will Robertson & Johannes Große +%% License information appended. +\input docstrip.tex +\keepsilent +\preamble + ___________________________________________________ + Copyright (C) 2007 Will Robertson & Johannes Große + License information appended. +\endpreamble +\postamble +Copyright (C) 2007 by Will Robertson & Johannes Große + +Distributable under the LaTeX Project Public License, +version 1.3c or higher (your choice). The latest version of +this license is at: http://www.latex-project.org/lppl.txt + +This work is "maintained" (as per LPPL maintenance status) +by Will Robertson. + +This work consists of the file ifplatform.dtx + and the derived files ifplatform.pdf, + ifplatform.sty, and + ifplatform.ins. +\endpostamble +\askforoverwritefalse +\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}} +\endbatchfile +%% Copyright (C) 2007 by Will Robertson & Johannes Große +%% +%% Distributable under the LaTeX Project Public License, +%% version 1.3c or higher (your choice). The latest version of +%% this license is at: http://www.latex-project.org/lppl.txt +%% +%% This work is "maintained" (as per LPPL maintenance status) +%% by Will Robertson. +%% +%% This work consists of the file ifplatform.dtx +%% and the derived files ifplatform.pdf, +%% ifplatform.sty, and +%% ifplatform.ins. +%% +%% End of file `ifplatform.ins'. diff --git a/Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty b/Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty new file mode 100644 index 00000000000..ed0f046fcde --- /dev/null +++ b/Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty @@ -0,0 +1,83 @@ +%% +%% This is file `ifplatform.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% ifplatform.dtx (with options: `package') +%% ___________________________________________________ +%% Copyright (C) 2007 Will Robertson & Johannes Große +%% License information appended. +\ProvidesPackage{ifplatform} + [2007/11/18 v0.2 Testing for the operating system] +\newif\ifshellescape +\newif\ifwindows +\newif\ifmacosx +\newif\iflinux +\newcommand\windowsname{Windows} +\newcommand\linuxname{Linux} +\newcommand\macosxname{Mac\,OS\,X} +\newcommand\unknownplatform{[Unknown]} +\edef\ip@file{\jobname.w18} +\edef\ip@sig{write18-test-\the\year\the\month\the\day\the\time} +\edef\ip@win{'\ip@sig'} +\def\ip@read@file{% + \newread\instream + \openin\instream=\ip@file + \@tempcnta=\endlinechar + \endlinechar=-1 + \read\instream to\@tempa + \endlinechar=\@tempcnta + \closein\instream} +\immediate\write18{echo \ip@win >"\ip@file"} +\IfFileExists{\ip@file}{\shellescapetrue}{\shellescapefalse\endinput} +\ip@read@file +\ifx\@tempa\ip@sig + \windowsfalse +\else + \ifx\@tempa\ip@win + \windowstrue + \else + \PackageError{ifplatform} + {There is a problem. Please delete the file \ip@file.} + {Somehow an old file is lying around telling me the wrong things. + \MessageBreak This should never happen. Please let us know when it does!} + \fi +\fi +\ifwindows\else + \immediate\write18{uname -s > "\ip@file"} + \ip@read@file + \def\@tempb{Linux} + \ifx\@tempa\@tempb + \linuxtrue + \else + \def\@tempb{Darwin} + \ifx\@tempa\@tempb + \macosxtrue + \else + \edef\unknownplatform{\@tempa} + \fi + \fi +\fi +\edef\platformname{% + \ifwindows\noexpand\windowsname\else + \iflinux \noexpand\linuxname\else + \ifmacosx \noexpand\macosxname\else + \noexpand\unknownplatform + \fi\fi\fi} +\immediate\write18{\ifwindows del \else rm -- \fi "\ip@file"} +%% Copyright (C) 2007 by Will Robertson & Johannes Große +%% +%% Distributable under the LaTeX Project Public License, +%% version 1.3c or higher (your choice). The latest version of +%% this license is at: http://www.latex-project.org/lppl.txt +%% +%% This work is "maintained" (as per LPPL maintenance status) +%% by Will Robertson. +%% +%% This work consists of the file ifplatform.dtx +%% and the derived files ifplatform.pdf, +%% ifplatform.sty, and +%% ifplatform.ins. +%% +%% End of file `ifplatform.sty'. -- cgit v1.2.3