diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/currfile/currfile.sty | 133 |
2 files changed, 123 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty b/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty index f598d5d6ccb..0b733d0a2af 100644 --- a/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty +++ b/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty @@ -1,7 +1,7 @@ \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{currfile-abspath}[% - 2012/05/06 - v0.6 + 2012/05/15 + v0.7 Provides absolute file paths, the parent working directory and the main file name] \newcommand*\thepwd{} \newcommand*\theabspath{} diff --git a/Master/texmf-dist/tex/latex/currfile/currfile.sty b/Master/texmf-dist/tex/latex/currfile/currfile.sty index e73708167d2..6bb2bf48b73 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}[% - 2012/05/06 - v0.6 + 2012/05/15 + v0.7 Provides the file path elements of the current input file] \RequirePackage{kvoptions} \SetupKeyvalOptions{family=currfile,prefix=currfile@} @@ -20,6 +20,8 @@ \DeclareBoolOption[false]{fink}% }% \DeclareVoidOption{force}{\PassOptionsToPackage{force}{filehook}} +\DeclareBoolOption[false]{parent} +\DeclareBoolOption[false]{parents} \DeclareBoolOption[false]{realmainfile}% \let\ifcurrfile@realmainfile\relax \DeclareBoolOption[false]{abspath}% @@ -43,8 +45,6 @@ \fi \fi -\let\currfileabspath\@empty -\let\currfileabsdir\@empty \ifcurrfile@abspath \RequirePackage{currfile-abspath} \else @@ -60,6 +60,7 @@ } \def\currfile@set#1{% \begingroup + \currfile@setparent \edef\@filef@und{#1}% \ifx\input@path\@undefined\else \currfile@checkpath @@ -78,8 +79,32 @@ \global\let\currfileabspath\theabspath \xdef\currfileabsdir{\theabsdir\currfiledir}% \fi + \addtocounter{currfiledepth}\@ne \endgroup } +\ifcurrfile@parent +\ifcurrfile@abspath +\def\currfile@setparent{% + \global\let\parentfiledir\currfiledir + \global\let\parentfilebase\currfilebase + \global\let\parentfileext\currfileext + \global\let\parentfilename\currfilename + \global\let\parentfilepath\currfilepath + \global\let\parentfileabspath\currfileabspath + \global\let\parentfileabsdir\currfileabsdir +} +\else +\def\currfile@setparent{% + \global\let\parentfiledir\currfiledir + \global\let\parentfilebase\currfilebase + \global\let\parentfileext\currfileext + \global\let\parentfilename\currfilename + \global\let\parentfilepath\currfilepath +} +\fi +\else +\let\currfile@setparent\relax +\fi \def\currfile@checkpath{% \openin\@inputcheck\@filef@und\relax \ifeof\@inputcheck @@ -135,15 +160,21 @@ } \fi \def\currfile@pop{% - \ifx\currfile@stack\empty + \ifcase0% + \ifx\currfile@stack\empty 1\else + \ifnum\value{currfiledepth}<\@ne 1\fi\fi + \relax + \addtocounter{currfiledepth}\m@ne + \else \PackageWarning{currfile}{File stack underflow!}% \global\let\currfile@stack\currfile@stackinit + \setcounter{currfiledepth}\z@ \fi \expandafter\currfile@pop@\currfile@stack\relax - \relax\relax\relax + \relax\relax\relax\relax\relax\relax\relax } \ifcurrfile@abspath -\def\currfile@pop@#1#2#3#4#5\relax{% +\def\currfile@pop@#1#2#3#4{% \gdef\currfiledir{#1}% \gdef\currfilebase{#2}% \gdef\currfileext{#3}% @@ -151,19 +182,98 @@ \xdef\currfilepath{\currfiledir\currfilename}% \gdef\currfileabsdir{#4}% \xdef\currfileabspath{\ifx\currfileabsdir\@empty\else\currfileabsdir\currfilename\fi}% - \gdef\currfile@stack{#5}% + \currfile@updatestack } \else -\def\currfile@pop@#1#2#3#4\relax{% +\def\currfile@pop@#1#2#3{% \gdef\currfiledir{#1}% \gdef\currfilebase{#2}% \gdef\currfileext{#3}% \xdef\currfilename{\currfilebase\ifx\currfileext\empty\else.\currfileext\fi}% \xdef\currfilepath{\currfiledir\currfilename}% - \gdef\currfile@stack{#4}% + \currfile@updatestack +} +\fi +\ifcurrfile@parent +\ifcurrfile@abspath +\def\currfile@updatestack#1#2#3#4#5\relax{% + \gdef\parentfiledir{#1}% + \gdef\parentfilebase{#2}% + \gdef\parentfileext{#3}% + \xdef\parentfilename{\parentfilebase\ifx\parentfileext\empty\else.\parentfileext\fi}% + \xdef\parentfilepath{\parentfiledir\parentfilename}% + \gdef\parentfileabsdir{#4}% + \xdef\parentfileabspath{\ifx\parentfileabsdir\@empty\else\parentfileabsdir\parentfilename\fi}% + \gdef\currfile@stack{{#1}{#2}{#3}{#4}#5}% +} +\else +\def\currfile@updatestack#1#2#3#4\relax{% + \gdef\parentfiledir{#1}% + \gdef\parentfilebase{#2}% + \gdef\parentfileext{#3}% + \xdef\parentfilename{\parentfilebase\ifx\parentfileext\empty\else.\parentfileext\fi}% + \xdef\parentfilepath{\parentfiledir\parentfilename}% + \gdef\currfile@stack{{#1}{#2}{#3}#4}% +} +\fi +\else +\def\currfile@updatestack#1\relax{% + \gdef\currfile@stack{#1}% } \fi -\def\currfile@stack{} +\ifcurrfile@parents +\newcommand*\currfilegetparents{% + \@tempcnta\@ne + \expandafter\currfile@getparents\currfile@stack\relax + \relax\relax\relax\relax\relax\relax\relax +} +\ifcurrfile@abspath +\def\currfile@getparents#1#2#3#4{% + \@namedef{parentfiledir\romannumeral\@tempcnta}{#1}% + \@namedef{parentfilebase\romannumeral\@tempcnta}{#2}% + \@namedef{parentfileext\romannumeral\@tempcnta}{#3}% + \expandafter\edef\csname parentfilename\romannumeral\@tempcnta\endcsname{#2\ifx\empty#3\empty\else.#3\fi}% + \expandafter\edef\csname parentfilepath\romannumeral\@tempcnta\endcsname{#1\csname parentfilename\romannumeral\@tempcnta\endcsname}% + \@namedef{parentfileabsdir\romannumeral\@tempcnta}{#4}% + \expandafter\edef\csname parentfileabspath\romannumeral\@tempcnta\endcsname{% + \expandafter\ifx\csname parentfileabsdir\romannumeral\@tempcnta\endcsname\@empty\else + \csname parentfileabsdir\romannumeral\@tempcnta\endcsname + \csname parentfilename\romannumeral\@tempcnta\endcsname + \fi + }% + \ifnum\@tempcnta<\c@currfiledepth + \advance\@tempcnta\@ne + \expandafter\currfile@getparents + \fi +} +\else +\def\currfile@getparents#1#2#3{% + \@namedef{parentfiledir\romannumeral\@tempcnta}{#1}% + \@namedef{parentfilebase\romannumeral\@tempcnta}{#2}% + \@namedef{parentfileext\romannumeral\@tempcnta}{#3}% + \expandafter\edef\csname parentfilename\romannumeral\@tempcnta\endcsname{#2\ifx\empty#3\empty\else.#3\fi}% + \expandafter\edef\csname parentfilepath\romannumeral\@tempcnta\endcsname{#1\csname parentfilename\romannumeral\@tempcnta\endcsname}% + \ifnum\@tempcnta<\c@currfiledepth + \advance\@tempcnta\@ne + \expandafter\currfile@getparents + \fi +} +\fi +\newcommand\parentfile[2]{% + \csname parentfile#1\romannumeral#2\endcsname +} +\fi +\let\currfile@stack\@empty +\let\currfiledir\@empty +\let\currfilebase\@empty +\let\currfileext\@empty +\let\currfilename\@empty +\let\currfilepath\@empty +\let\currfileabspath\@empty +\let\currfileabsdir\@empty +\newcounter{currfiledepth} +\setcounter{currfiledepth}\m@ne +\currfile@push \ifcurrfile@realmainfile \getmainfile \ifx\themainfile\@empty @@ -174,7 +284,6 @@ \else \currfile@set{\currfile@maindir\jobname.\currfile@mainext} \fi -\currfile@push \let\currfile@stackinit\currfile@stack \let\currfile@abspathfalse\relax \let\currfile@abspathtrue\relax |