From 9b2db6d4800d0edf3e03f9ebff38c3e4ecada25b Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 17 Aug 2007 00:39:27 +0000 Subject: xfor 1.02 git-svn-id: svn://tug.org/texlive/trunk@4750 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/xfor/xfor.dtx | 73 +++++++++++++++++++++++----- Master/texmf-dist/source/latex/xfor/xfor.ins | 2 +- 2 files changed, 62 insertions(+), 13 deletions(-) (limited to 'Master/texmf-dist/source/latex/xfor') diff --git a/Master/texmf-dist/source/latex/xfor/xfor.dtx b/Master/texmf-dist/source/latex/xfor/xfor.dtx index 863efb923cc..eda8dbe5802 100644 --- a/Master/texmf-dist/source/latex/xfor/xfor.dtx +++ b/Master/texmf-dist/source/latex/xfor/xfor.dtx @@ -1,12 +1,12 @@ %\iffalse -% xfor.dtx generated using makedtx version 0.91b (c) Nicola Talbot +% xfor.dtx generated using makedtx version 0.93b (c) Nicola Talbot % Command line args: % -src "xfor.sty=>xfor.sty" % -doc "manual.tex" % -author "Nicola Talbot" % -dir "source" % xfor -% Created on 2007/7/11 12:25 +% Created on 2007/8/16 15:55 %\fi %\iffalse %<*package> @@ -34,6 +34,7 @@ % \iffalse %<*driver> \documentclass[a4paper]{ltxdoc} +\usepackage{xfor} \usepackage{ifthen} \usepackage{alltt} \usepackage[colorlinks, @@ -43,7 +44,7 @@ pdftitle={xfor: redefinition of '@for}, pdfkeywords={LaTeX,package development}]{hyperref} -\CheckSum{104} +\CheckSum{117} \PageIndex \RecordChanges \newcommand*{\sty}[1]{\textsf{#1}} @@ -55,7 +56,7 @@ %\fi %\MakeShortVerb{"} % -% \title{xfor v1.01: Reimplementation of \cs{@for} to allow +% \title{xfor v1.02: Reimplementation of \cs{@for} to allow %premature termination of the loop} % \author{Nicola L.C. Talbot\\[10pt] %School of Computing Sciences\\ @@ -64,7 +65,7 @@ %NR4 7TJ. United Kingdom.\\ %\url{http://theoval.cmp.uea.ac.uk/~nlct/}} % -%\date{11th July 2007} +%\date{16th August 2007} %\maketitle %\tableofcontents % @@ -90,6 +91,19 @@ %whether the loop was prematurely terminated using the conditional %\DescribeMacro{\if@endfor}\cs{if@endfor}. % +%As from version 1.02, there is also provision for looking ahead. +%At each iteration in the loop, the next element is stored in +%\cs{@xfor@nextelement}\DescribeMacro{\@xfor@nextelement}. +%On the last iteration, this value +%will be \cs{@nil}, and so can be checked using +%\begin{verbatim} +%\ifx\@xfor@nextelement\@nnil +%% last iteration +%\else +%% not last iteration +%\fi +%\end{verbatim} +% %\subsection{Example (ordered insertion)} % %Suppose you have list of sorted numbers stored in the command @@ -199,9 +213,30 @@ %\end{verbatim} %at the end of the definition of \cs{insertinto} will fix that. % -%\changes{1.0}{2007 June 27}{Initial version} +%\subsection{Example (looking ahead)} % -% \StopEventually{\phantomsection\addcontentsline{toc}{section}{Index}\PrintIndex} +%This example checks the next value to determine if the loop +%is on the last iteration, if it is, it does nothing, otherwise +%it does a semi-colon: +%\begin{verbatim} +%\makeatletter +%\def\mylist{1,2,3,4,5}% +%\@for\val:=\mylist\do{\val +%\ifx\@xfor@nextelement\@nnil \else ;\fi} +%\makeatother +%\end{verbatim} +%which produces: +%\makeatletter +%\def\mylist{1,2,3,4,5}\relax +%\@for\val:=\mylist\do{\val +%\ifx\@xfor@nextelement\@nnil \else ;\fi} +%\makeatother +% +% \StopEventually{\clearpage\phantomsection +%\addcontentsline{toc}{section}{Change History} +%\PrintChanges\phantomsection +%\addcontentsline{toc}{section}{Index} +%\PrintIndex} % % % @@ -214,7 +249,7 @@ % Declare package: % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{xfor}[2007/07/11 v1.01 (NLCT)] +\ProvidesPackage{xfor}[2007/08/16 v1.02 (NLCT)] % \end{macrocode} % Define a switch to determine if the for loop should be % terminated: @@ -251,6 +286,7 @@ \def#4{#1}% \ifx#4\@nnil \else + \@xfor@storenext#2,#3\@@% #5% \if@endfor \@iforgatherrest#2,#3% @@ -258,6 +294,7 @@ \def#4{#2}% \ifx#4\@nnil \else + \@xfor@storenext#3,\@nil\@@% #5% \if@endfor \@iforgatherrest#3% @@ -270,16 +307,27 @@ } % \end{macrocode} %\end{macro} -% Get remainder of list (stores in \cs{@forremainder}): -%\changes{1.01}{2007 July 11}{Made '@forgatherrest long}% +%\changes{1.02}{2007 August 16}{Added \cs{@xfor@storenext}}% +%\begin{macro}{\@xfor@storenext} +% Stores first argument in \cs{@xfor@nextelement}. +% \begin{macrocode} +\def\@xfor@storenext#1,#2\@@{% +\def\@xfor@nextelement{#1}% +} +% \end{macrocode} +%\end{macro} +% %\begin{macro}{\@forgatherrest} +% Get remainder of list (stores in \cs{@forremainder}): +%\changes{1.01}{2007 July 11}{made long}% % \begin{macrocode} \long\def\@forgatherrest#1,\@nil,\@nil{\def\@forremainder{#1}} % \end{macrocode} %\end{macro} -% As above, but there may not be anything before \cs{@nil}: -%\changes{1.01}{2007 July 11}{Made '@iforgatherrest long}% +% %\begin{macro}{\@iforgatherrest} +% As above, but there may not be anything before \cs{@nil}: +%\changes{1.01}{2007 July 11}{made long}% % \begin{macrocode} \long\def\@iforgatherrest#1\@nil,\@nil{% \def\@fortmp{#1}% @@ -299,6 +347,7 @@ \ifx#3\@nnil \let\@ifornext\@fornoop \else + \@xfor@storenext#2,\@nil\@@% #4\relax \if@endfor \@iforgatherrest#2\relax diff --git a/Master/texmf-dist/source/latex/xfor/xfor.ins b/Master/texmf-dist/source/latex/xfor/xfor.ins index 225a78fb744..45caba065e3 100644 --- a/Master/texmf-dist/source/latex/xfor/xfor.ins +++ b/Master/texmf-dist/source/latex/xfor/xfor.ins @@ -1,4 +1,4 @@ -% xfor.ins generated using makedtx version 0.91b 2007/7/11 12:25 +% xfor.ins generated using makedtx version 0.93b 2007/8/16 15:55 \input docstrip \preamble -- cgit v1.2.3