diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-ctx.tex')
-rw-r--r-- | Master/texmf-dist/tex/context/base/core-ctx.tex | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-ctx.tex b/Master/texmf-dist/tex/context/base/core-ctx.tex new file mode 100644 index 00000000000..ba47f07fd1a --- /dev/null +++ b/Master/texmf-dist/tex/context/base/core-ctx.tex @@ -0,0 +1,173 @@ +%D \module +%D [ file=core-ctx, +%D version=2006.08.16, % old stuff +%D title=\CONTEXT\ Core Macros, +%D subtitle=Job Control, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{Context Core Macros / Ctx Job Files} + +%D After some experimenting this code moved into the core. It +%D overloades a few file reading macros and permits runtime +%D conversion and job control. + +\unprotect + +\chardef\preprocessmethod 2 % 0=no check 1=present_check 2=log_check +\chardef\preprocessstate 0 % 1=found 2=not_present (skip) +\def \preprocesssuffix {.prep} + +\def\loadctxpreplist + {\ifcase\preprocessmethod + % no checking + \or + % simple checking + \or + \doiffileexistselse{./\jobname.ctl} + {\bgroup + \defineXMLenvironment[ctx:preplist] + {\writestatus\m!systems{loading ctx log file}} + {}% + \defineXMLenvironmentsave[ctx:prepfile][done=no] + {} + {\writestatus\m!systems{registering \XMLflush{ctx:prepfile} -> \XMLop{done}}% + \setxvalue{fp..\XMLflush{ctx:prepfile}}{\XMLop{done}}}% + \processXMLfile{./\jobname.ctl}% + \egroup}% + {\global\chardef\preprocessmode\plusone}% + \fi + \global\let\loadctxpreplist\relax} + +\appendtoks\loadctxpreplist\to\everystarttext % will become: \prependtoks\loadctxpreplist\to\everyjob + +\def\docheckprepfile + {\ifcase\preprocessmethod + \iftracefiles\writestatus\m!systems{preprocessing - not needed}\fi + % no preprocessing + \or + % only check for existence + \iftracefiles\writestatus\m!systems{preprocessing - check exitence of \readfilename\preprocesssuffix}\fi + \doiffileexistselse{\readfilename\preprocesssuffix} + {\chardef\preprocessstate\plusone} + \donothing + \or + % check when in list, otherwise assume normal file + \bgroup + \splitfilename\readfilename + \ifx\splitofftype\empty + % saveguard and speed up + \iftracefiles\writestatus\m!systems{preprocessing - no suffix}\fi + \egroup + \else + \iftracefiles\writestatus\m!systems{preprocessing - check presence of \readfilename\preprocesssuffix}\fi + \doifdefinedelse{fp..\readfilename} + {\egroup + \doiffileexistselse{\readfilename\preprocesssuffix} + {\chardef\preprocessstate\plusone} + {\chardef\preprocessstate\plustwo}}% + {\doifdefinedelse{fp..\splitoffname.\splitofftype} + {\egroup + \doiffileexistselse{\readfilename\preprocesssuffix} + {\chardef\preprocessstate\plusone} + {\chardef\preprocessstate\plustwo}}% + {\egroup}}% + \fi + \fi} + +% beware, \readfilename keeps the original one, but we load and store the +% suffixed with .prep file (if present) + +\def\doreadfile#1#2#3#4% beware, this one already works at format generation time! + {\sanitizefilename#2\to\readfilename + \ifx\readfilename\empty + % silently ignore + \else + \let\trackedfilename\readfilename + \chardef\preprocessstate\zerocount + \ifconditional\trackfilenames + \doifundefinedelse{fn..\trackedfilename}\donetrue\donefalse + \else + \donetrue + \fi + \ifdone + \checkfilename\readfilename + \ifcase\kindoffile + % not a full path or url, check for existence + \doifelsenothing{#1} + {\iftracefiles\writestatus\m!systems{searching for \readfilename\space on tex path}\fi + \def\next{\redoreadfile\readfilename{#3}{#4}}}% + {\iftracefiles\writestatus\m!systems{searching for \readfilename\space on #1}\fi + \def\next{\redoreadfile{\pathplusfile{#1}{\readfilename}}{#3}{#4}}}% + \else + % a full path or url, no further checking done + \docheckprepfile + \ifcase\preprocessstate + \doiffileexistselse\readfilename + {\iftracefiles\writestatus\m!systems{located \readfilename}\fi + \def\next{#3\dodoreadfile}}% + {\iftracefiles\writestatus\m!systems{not found \readfilename}\fi + \def\next{#4}}% + \or + \iftracefiles\writestatus\m!systems{located \readfilename\preprocesssuffix}\fi + \def\next{#3\dodoreadfile}% + \or + \iftracefiles\writestatus\m!systems{not found \readfilename\preprocesssuffix}\fi + \def\next{#4}% + \fi + \fi + \else + \edef\readfilename{\getvalue{fn..\readfilename}}% + \iftracefiles\writestatus\m!systems{already located \readfilename}\fi + \def\next{#3\dodoreadfile}% + \fi + \expandafter\next + \fi} + +\def\redoreadfile#1#2#3% + {\docheckprepfile + \ifcase\preprocessstate + \doiffileexistselse{#1}% + {\edef\readfilename{#1}% + \iftracefiles\writestatus\m!systems{#1 located}\fi + \def\next{#2\dodoreadfile}}% + {\iftracefiles\writestatus\m!systems{cannot locate #1}\fi + \decrement\readlevel\relax + \ifnum\readlevel>\zerocount + \edef\readfilename{\pathplusfile{\f!parentpath}{\readfilename}}% + \def\next{\redoreadfile\readfilename{#2}{#3}}% + \else + \def\next{#3}% + \fi}% + \or + \edef\readfilename{#1}% + \iftracefiles\writestatus\m!systems{#1\preprocesssuffix\space located}\fi + \def\next{#2\dodoreadfile}% + \or + \def\next{#3}% + \fi + \next} + +\def\dodoreadfile % we provide hooks, for instance for \enableXML + {\ifconditional\trackfilenames + \setxvalue{fn..\trackedfilename}{\readfilename\ifcase\preprocessstate\or\preprocesssuffix\fi}% + \fi + \the\everybeforereadfile + \ifcase\preprocessstate + % no checking or not found when using method 1 + \normalinput\readfilename + \or + % found when using method 1 or 2 + \normalinput\readfilename\preprocesssuffix + \or + % not found when using method 2 + \fi + \relax + \the\everyafterreadfile} + +\protect \endinput |