diff options
author | Hans Hagen <pragma@wxs.nl> | 2005-10-27 00:00:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2005-10-27 00:00:00 +0200 |
commit | 28ba5960fc4486f4e667ee0cbd802335483e1c99 (patch) | |
tree | 364430fa36f4d3b1b254a10874b4ed369469d4c9 /tex/context/base/cont-new.tex | |
parent | a35805505d72f60e25a5d9b96dcc5c0a83cc1ed0 (diff) | |
download | context-28ba5960fc4486f4e667ee0cbd802335483e1c99.tar.gz |
stable 2005.10.27
Diffstat (limited to 'tex/context/base/cont-new.tex')
-rw-r--r-- | tex/context/base/cont-new.tex | 231 |
1 files changed, 144 insertions, 87 deletions
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index c8c84b4c8..87d53cb68 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -24,103 +24,160 @@ \writestatus{\m!systems}{beware: some patches loaded from cont-new.tex} -\def\headparameter#1% to do: everywhere in core-sec - {\csname\??ko\currenthead#1\endcsname} - -% supp-fil.tex - -% <?xml version='1.0' standalone='yes'?> -% <ctx:job> -% <ctx:message>loading preprocessor definition</ctx:message> -% <ctx:preprocessor>texmfstart --direct iconv "--binary -f CP1250 -t UTF-8 kpse:&ctx:oldfilename; > &ctx:newfilename;"</ctx:preprocessor> -% </ctx:job> - -\let\preprocessfile\gobbleoneargument - -\def\dodoreadfile % we provide hooks, for instance for \enableXML - {\ifconditional\trackfilenames - \setxvalue{fn..\trackedfilename}{\readfilename}% - \fi - \preprocessfile\readfilename % new - \the\everybeforereadfile - \normalinput\readfilename\relax - \the\everyafterreadfile} - -% core-fil.tex - -% \let\checkpreprocessor\relax +% \tracefilestrue % -% \appendtoks\relax{\appendtoks \checkpreprocessor \to \everyjob}\to\everydump - -% core-job.tex +% \unexpanded\def\readfile#1#2#3% +% {\readlocfile{#1}{#2} +% {\readjobfile{#1}{#2} +% {\readsysfile{#1}{#2}{#3}}}} -\definesystemvariable {fz} % file preprocessing - -\definefileconstant {prepprefix} {prep-} - -\chardef\preprocessmode\zerocount +\unexpanded\def\readfile#1#2#3% + {\readlocfile{#1}{#2}{\readsysfile{#1}{#2}{#3}}} + +\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\processlocalfile#1#2% - {% #1=\readlocfile|\readsetfile{dir} #2=filename - % #1{#2}\donothing\donothing - \chardef\preprocessmode\plusone - #1{#2}\donothing{\readfile{#2}\donothing\donothing}} +\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} -\beginETEX +\appendtoks\loadctxpreplist\to\everystarttext % will become: \prependtoks\loadctxpreplist\to\everyjob -\let\oldfilename\empty -\let\newfilename\empty - -\def\preprocessfile#1% - {\ifcase\preprocessmode\else - \chardef\preprocessmode\zerocount % one time shot - \doifsomething{\filepreprocessor} - {\def\oldfilename{#1}% - \splitfilename\oldfilename % whatever path - \ifx\splitofftype\empty - \let\splitofftype\c!tex - \edef\oldfilename{\oldfilename.\splitofftype}% - \fi - \edef\newfilename{\f!prepprefix\splitoffname.\splitofftype}% local path - \doifundefined{fp..\oldfilename} - {\doifmode{\systemmodeprefix\v!first} - {\bgroup - \enableXML - \let\executeXMLentity\expandedXMLentity - \defineXMLentity[gt]\lettermore - \defineXMLentity[lt]\letterless - \writestatus\m!systems{\filepreprocessor}% - \executesystemcommand{\filepreprocessor}% - \egroup}% - \setxvalue{fp..\oldfilename}{\newfilename}}% - \let#1\newfilename}% +\def\docheckprepfile + {\ifcase\preprocessmethod + % no preprocessing + \or + % only check for existence + \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 + \egroup + \else + \doifdefinedelse{fp..\splitoffname.\splitofftype} + {\egroup + \doiffileexistselse{\readfilename\preprocesssuffix} + {\chardef\preprocessstate\plusone} + {\chardef\preprocessstate\plustwo}}% + {\egroup}% + \fi \fi} -\def\filepreprocessor{\XMLflush{ctx:preprocessor}} - -\defineXMLenvironment[ctx:job] \startXMLignore \stopXMLignore -\defineXMLgsave [ctx:preprocessor] -\defineXMLargument [ctx:message] {\writestatus\m!systems} -\defineXMLentity [ctx:oldfilename] \oldfilename -\defineXMLentity [ctx:newfilename] \newfilename +% beware, \readfilename keeps the original one, but we load and store the +% suffixed with .prep file (if present) -\def\checkpreprocessor - {\global\let\checkpreprocessor\empty - \processXMLfilegrouped{./\jobname.ctx}% - \doifsomething\filepreprocessor - {\chardef\preprocessmode\plusone - \preprocessfile\inputfilename - \endinput - \normalinput\inputfilename\relax}} - -\endETEX - -\beginTEX +\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\preprocessfile#1% - {\chardef\preprocessmode\zerocount} +\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} -\endTEX +\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} + +\def\headparameter#1% to do: everywhere in core-sec + {\csname\??ko\currenthead#1\endcsname} % The following may be a solution for the fact that one cannot % change catcodes of characters like : and ; inside an environment. |