From facafbb26a0554617788e362d73e71d7b070ffa3 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 17 Oct 2012 22:45:04 +0000
Subject: loops (17oct12)

git-svn-id: svn://tug.org/texlive/trunk@28002 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/loops/loops.sty | 48 +++++++++++++++++++++--------
 1 file changed, 36 insertions(+), 12 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/loops/loops.sty')

diff --git a/Master/texmf-dist/tex/latex/loops/loops.sty b/Master/texmf-dist/tex/latex/loops/loops.sty
index 4183be5ba27..f05a61d6c10 100644
--- a/Master/texmf-dist/tex/latex/loops/loops.sty
+++ b/Master/texmf-dist/tex/latex/loops/loops.sty
@@ -1,5 +1,5 @@
 %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
-% This is file 'loops.sty', version 1.0, September 2012.                   %
+% This is file 'loops.sty', version 1.1, October 2012.                     %
 %                                                                          %
 % This package and accompanying files may be distributed and/or            %
 % modified under the conditions of the LaTeX Project Public License,       %
@@ -53,11 +53,16 @@
 \do 032=10,033=12,036=03,038=04,040=12,041=12,042=12,043=12,%
   059=12,045=12,047=12,058=12,063=12,091=12,093=12,126=13,\do=,%
 
-\ProvidesPackage{loops}[2012/09/29 v1.0 Loops and list processors (AM)]
+\ProvidesPackage{loops}[2012/10/14 v1.1 Loops and list processors (AM)]
 \NeedsTeXFormat{LaTeX2e}[2011/06/27]
 
+% This is the way to load 'skeyval-for-core' here, otherwise we
+% can't access some of the needed commands from 'skeyval-core':
+
 \@ifpackageloaded{skeyval}{}{\RequirePackage{skeyval}}
+
 \skvnewlet\ltxkernelfor\@for
+\skvnewlet\ltxkerneltfor\@tfor
 
 % \skvusetwoprev{<parser>}{<list>}{<target.item>}{<do.on.target>}
 %
@@ -223,13 +228,12 @@
 % \edef\x{\skvfor{\cmda,\cmdb}\do}
 % \show\x -> \let\cmda\cmda@ii \let\cmdb\cmdb@ii
 %
-\skvnewdef\skvfor#1#2{\skv@for@a#1,\skv@for@nil,\skv@for@nnil{#2}}
-\skvnewdef\skv@for@a#1,#2\skv@for@nnil#3{%
-  \skvifblank{#1}{%
-    \skv@for@a#2\skv@for@nnil{#3}%
+\skvnewdef\skvfor#1#2{\skv@for@a{#2}#1,\skv@for@nil,}
+\skvnewdef\skv@for@a#1#2,{%
+  \skvifblank{#2}{%
+    \skv@for@a{#1}%
   }{%
-    \skvifstrcmp{#1}{\skv@for@nil}%
-      {}{#3{#1}\skv@for@a#2\skv@for@nnil{#3}}%
+    \skvifstrcmp{#2}\skv@for@nil{}{#1{#2}\skv@for@a{#1}}%
   }%
 }
 
@@ -385,7 +389,7 @@
 % Define \foxloop keys. Name all the macros with 'foreach' prefix so
 % that we can avoid new command names and use the list auto-completion
 % scheme of \newforeach.
-\quickkeys.define{foxloop}{%
+\quickkeys.define{skvfoxloop}{%
   parser/{,}/
     \def\skv@foreach@parser{#1}
     \skvstripouterbraces{2}\skv@foreach@parser
@@ -505,10 +509,14 @@
       \skv@fox@parseremember{#1}%
     }%
   ;
+  reverse list,reverse/true/
+    \edef\skv@foreach@reverselist{0\skvifstrcmp{true}{#1}01}%
+    /true,false
+  ;
 }
 
 % Set up \foxloop defaults:
-\quickkeys.set{foxloop}{%
+\quickkeys.set{skvfoxloop}{%
   parser={,},
   list is a macro=false,
   list type=csv,
@@ -520,6 +528,7 @@
   keep decimals=true,
   keep high decimals=false,
   expand before fill=false,
+  reverse list=false,
 }
 
 % Parser for 'evaluate' key:
@@ -827,7 +836,17 @@
   }%
 }
 
-\skvnewlet\setupfoxloop\setupforeach
+\skvnewdef*\skv@foxloop@kvlist{}
+% \setupfoxloop{<kvlist>}
+\skvrobustdef*\setupfoxloop#1{%
+  \skvifblank{#1}{}{%
+    \skvaddtolist\skv@foxloop@kvlist{#1}%
+  }%
+}
+\skvrobustdef*\skv@foxloop@setkeys#1{%
+  \def\reserved@a{\quickkeys.set{skvfoxloop}}%
+  \expandafter\reserved@a\expandafter{\skv@foxloop@kvlist,#1}%
+}
 
 % \atbeginfoxloop[<depth>]{<code>}
 \skvnewlet\atbeginfoxloop\atbeginforeach
@@ -835,6 +854,7 @@
 \skvnewlet\atendfoxloop\atendforeach
 
 \skvrobustdef*\foxloop{\skv@teststopt\skv@foxloop{}}
+\skvnewlet\foreachfox\foxloop
 \skvrobustdef*\skv@foxloop[#1]#2#3{%
   \ifskv@tempst
     \def\skv@foreach@st{00}%
@@ -848,7 +868,7 @@
   \def\skv@foreach@precallback{}%
   \def\skv@foreach@postcallback{}%
   \def\skv@foreach@onlyinitially{}%
-  \quickkeys.set{foxloop}{#1}%
+  \skv@foxloop@setkeys{#1}%
   \if\skv@foreach@st\else
     \if\skv@foreach@listismacro
       \def\skv@foreach@st{00}%
@@ -921,6 +941,10 @@
       \skvifempty\skv@foreach@userlist{}{%
         \expandafter\skv@foreach@filllist\expandafter
           {\skv@foreach@parser}\skv@foreach@userlist
+        \if\skv@foreach@reverselist\skvafterfi
+          \expandafter\skv@foreach@doreverselist\expandafter
+            {\skv@foreach@parser}\skv@foreach@userlist
+        \fi
       }%
       % If \skv@foreach@userlist is empty, \currentfox in
       % \skv@foxloop@b will terminate the loop.
-- 
cgit v1.2.3

