diff options
author | Karl Berry <karl@freefriends.org> | 2012-05-07 22:49:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-05-07 22:49:57 +0000 |
commit | 6dec32fb82f9e57953655c2dbddb68c5120c4322 (patch) | |
tree | 3d61735f257c8afab559b631f9401aded3a5fa24 /Master/texmf-dist/tex/latex/currfile | |
parent | 00594439f07c4918772b72ae22786fb762b93f37 (diff) |
currfile (7may12)
git-svn-id: svn://tug.org/texlive/trunk@26244 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/currfile')
-rw-r--r-- | Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty | 171 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/currfile/currfile.sty | 73 |
2 files changed, 240 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty b/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty new file mode 100644 index 00000000000..f598d5d6ccb --- /dev/null +++ b/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty @@ -0,0 +1,171 @@ +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{currfile-abspath}[% + 2012/05/06 + v0.6 + Provides absolute file paths, the parent working directory and the main file name] +\newcommand*\thepwd{} +\newcommand*\theabspath{} +\newcommand*\theabsdir{} +\newcommand*\themainfile{} +\newif\ifcurrfile@abspath@windows +\providecommand\currfile@mainext{tex} +\ifx\currfile@mainext\@empty + \PackageError{currfile-abspath} + {Empty main file extension is not supported}{}% +\fi +\def\currfile@abspath@noflswarning{% + \PackageWarning{currfile-abspath} + {The required recorder file (.fls) was not found.\MessageBreak + Please compile with the '-recorder' option.\MessageBreak + Note that MikTeX requires two compiler runs.\MessageBreak + Occurred}% + \global\let\currfile@abspath@noflswarning\relax + \global\csname currfile@abspathfalse\endcsname +}% +\newcommand\getpwd{% + \begingroup + \let\thepwd\@empty + \IfFileExists{\jobname.fls}{% + \openin\@inputcheck=\jobname.fls\relax + \endlinechar\m@ne + \loop + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@checkpwd\line\relax\relax\relax\relax\relax + \ifeof\@inputcheck\else + \repeat + \closein\@inputcheck + } + \currfile@abspath@noflswarning + \edef\@tempa{% + \def\noexpand\thepwd{\thepwd}% + }% + \expandafter + \endgroup + \@tempa +} +\def\currfile@checkpwd#1#2#3#4#5\relax{% + \edef\@tempa{#1#2#3}% + \edef\@tempb{PWD}% + \@onelevel@sanitize\@tempb + \ifx\@tempa\@tempb + \edef\thepwd{#4#5/}% + \def\@tempa{#4}% + \def\@tempb{/}% + \ifx\@tempa\@tempb + \currfile@abspath@windowsfalse + \else + \currfile@abspath@windowstrue + \fi + \let\iterate\relax + \fi +} +\newcommand\getabspath[1]{% + \begingroup + \edef\filename{#1}% + \@onelevel@sanitize\filename% + \let\theabspath\@empty + \let\theabsdir\@empty + \IfFileExists{\filename}{% + \IfFileExists{\jobname.fls}{% + \openin\@inputcheck=\jobname.fls\relax + \endlinechar\m@ne + \expandafter\currfile@abspath@defs\expandafter{\filename}% + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@checkpwd\line\relax\relax\relax\relax\relax + \loop + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@abspath@getabspath\expandafter{\line}% + \ifeof\@inputcheck\else + \repeat + \closein\@inputcheck + }\currfile@abspath@noflswarning + }{}% + \edef\@tempa{% + \def\noexpand\theabspath{\theabspath}% + \def\noexpand\theabsdir{\theabsdir}% + \def\noexpand\thepwd{\thepwd}% + }% + \expandafter + \endgroup + \@tempa +} +\newcommand\getmainfile{% + \begingroup + \let\themainfile\@empty + \IfFileExists{\jobname.fls}{% + \openin\@inputcheck=\jobname.fls\relax + \endlinechar\m@ne + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@checkpwd\line\relax\relax\relax\relax\relax + \loop + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@abspath@getmainfile\expandafter{\line}% + \ifeof\@inputcheck\else + \repeat + \closein\@inputcheck + }% + \currfile@abspath@noflswarning + \edef\@tempa{% + \def\noexpand\themainfile{\themainfile}% + \def\noexpand\thepwd{\thepwd}% + }% + \expandafter + \endgroup + \@tempa +} +\def\currfile@abspath@testfname#1#2#3\relax{% + \ifcurrfile@abspath@windows + \def\@tempa{#2}% + \def\@tempb{:}% + \else + \def\@tempa{#1}% + \def\@tempb{/}% + \fi + \ifx\@tempa\@tempb\else + \let\theabsdir\thepwd + \fi +} +\begingroup +\catcode`I=12 +\catcode`N=12 +\catcode`P=12 +\catcode`U=12 +\catcode`T=12 +\gdef\currfile@abspath@defs#1{% + \def\currfile@abspath@checkabspath ##1INPUT ##2#1\relax##3\relax##4\@nnil{% + \ifx\@empty##4\@empty\else + \def\theabsdir{##2}% + \ifx\theabsdir\@empty + \currfile@abspath@testfname#1\@empty\@empty\relax + \fi + \edef\theabspath{\theabsdir#1}% + \let\iterate\relax + \fi + }% + \def\currfile@abspath@getabspath##1{% + \currfile@abspath@checkabspath##1\relax INPUT \@empty#1\relax{}\relax\@nnil + }% +} +\def\@tempa#1{% + \gdef\currfile@abspath@checkmainfile ##1INPUT ##2#1\relax##3\relax##4\@nnil{% + \ifx\@empty##4\@empty\else + \def\themainfile{##2#1}% + \let\iterate\relax + \fi + }% + \gdef\currfile@abspath@getmainfile##1{% + \currfile@abspath@checkmainfile##1\relax INPUT \@empty#1\relax{}\relax\@nnil + }% +} +\edef\@tempb{.\currfile@mainext} +\@onelevel@sanitize\@tempb +\expandafter\@tempa\expandafter{\@tempb} +\endgroup +\endinput +%% +%% End of file `currfile-abspath.sty'. diff --git a/Master/texmf-dist/tex/latex/currfile/currfile.sty b/Master/texmf-dist/tex/latex/currfile/currfile.sty index 9697d4679c2..01ed8381aee 100644 --- a/Master/texmf-dist/tex/latex/currfile/currfile.sty +++ b/Master/texmf-dist/tex/latex/currfile/currfile.sty @@ -1,7 +1,7 @@ \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{currfile}[% - 2011/09/18 - v0.5 + 2012/05/06 + v0.6 ydoc package to describe macros, environments, options etc.] \RequirePackage{kvoptions} \SetupKeyvalOptions{family=currfile,prefix=currfile@} @@ -20,6 +20,9 @@ \DeclareBoolOption[false]{fink}% }% \DeclareVoidOption{force}{\PassOptionsToPackage{force}{filehook}} +\DeclareBoolOption[false]{realmainfile}% +\let\ifcurrfile@realmainfile\relax +\DeclareBoolOption[false]{abspath}% \RequirePackage{filehook}[2011/01/09] \ProcessKeyvalOptions*\relax @@ -28,9 +31,26 @@ \xdef\currfile@maindir{\currfile@maindir}% \def\@tempa{./}% \ifx\@tempa\currfile@maindir - \global\let\currfile@maindir\empty + \global\let\currfile@maindir\@empty \fi \endgroup + +\expandafter\ifx\csname ifcurrfile@realmainfile\endcsname\relax + \ifcurrfile@abspath + \currfile@realmainfiletrue + \else + \currfile@realmainfilefalse + \fi +\fi + +\let\currfileabspath\@empty +\let\currfileabsdir\@empty +\ifcurrfile@abspath + \RequirePackage{currfile-abspath} +\else +\ifcurrfile@realmainfile + \RequirePackage{currfile-abspath} +\fi\fi \filehook@prefixwarg\filehook@every@atbegin{% \currfile@push \currfile@set{#1}% @@ -53,6 +73,11 @@ \global\let\currfileext\filename@ext \xdef\currfilename{\currfilebase\ifx\currfileext\@empty\else.\currfileext\fi}% \xdef\currfilepath{\currfiledir\currfilename}% + \ifcurrfile@abspath + \getabspath\currfilepath + \global\let\currfileabspath\theabspath + \xdef\currfileabsdir{\theabsdir\currfiledir}% + \fi \endgroup } \def\currfile@checkpath{% @@ -89,6 +114,17 @@ \endgroup \def\currfile@defaultext{tex} \@onelevel@sanitize\currfile@defaultext +\ifcurrfile@abspath +\def\currfile@push{% + \xdef\currfile@stack{% + {\currfiledir}% + {\currfilebase}% + {\currfileext}% + {\currfileabsdir}% + \currfile@stack + }% +} +\else \def\currfile@push{% \xdef\currfile@stack{% {\currfiledir}% @@ -97,6 +133,7 @@ \currfile@stack }% } +\fi \def\currfile@pop{% \ifx\currfile@stack\empty \PackageWarning{currfile}{File stack underflow!}% @@ -105,6 +142,18 @@ \expandafter\currfile@pop@\currfile@stack\relax \relax\relax\relax } +\ifcurrfile@abspath +\def\currfile@pop@#1#2#3#4#5\relax{% + \gdef\currfiledir{#1}% + \gdef\currfilebase{#2}% + \gdef\currfileext{#3}% + \xdef\currfilename{\currfilebase\ifx\currfileext\empty\else.\currfileext\fi}% + \xdef\currfilepath{\currfiledir\currfilename}% + \gdef\currfileabsdir{#4}% + \xdef\currfileabspath{\ifx\currfileabsdir\@empty\else\currfileabsdir\currfilename\fi}% + \gdef\currfile@stack{#5}% +} +\else \def\currfile@pop@#1#2#3#4\relax{% \gdef\currfiledir{#1}% \gdef\currfilebase{#2}% @@ -113,15 +162,31 @@ \xdef\currfilepath{\currfiledir\currfilename}% \gdef\currfile@stack{#4}% } +\fi \def\currfile@stack{} -\currfile@set{\currfile@maindir\jobname.\currfile@mainext} +\ifcurrfile@realmainfile + \getmainfile + \ifx\themainfile\@empty + \currfile@set{\currfile@maindir\jobname.\currfile@mainext} + \else + \currfile@set{\themainfile} + \fi +\else + \currfile@set{\currfile@maindir\jobname.\currfile@mainext} +\fi \currfile@push \let\currfile@stackinit\currfile@stack +\let\currfile@abspathfalse\relax +\let\currfile@abspathtrue\relax \newcommand*\ifcurrfilename{\begingroup\currfile@if\currfilename} \newcommand*\ifcurrfilebase{\begingroup\currfile@if\currfilebase} \newcommand*\ifcurrfileext{\begingroup\currfile@if\currfileext} \newcommand*\ifcurrfiledir{\begingroup\currfile@if\currfiledir} \newcommand*\ifcurrfilepath{\begingroup\currfile@if\currfilepath} +\ifcurrfile@abspath +\newcommand*\ifcurrfileabspath{\begingroup\currfile@if\currfileabspath} +\newcommand*\ifcurrfileabsdir{\begingroup\currfile@if\currfileabsdir} +\fi \newcommand*\ifcurrfile[1]{% \begingroup \edef\@tempb{#1}% |