From 07d426b145a3c2e39a7a85b56dc211f9fbd0a0df Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 12 Feb 2016 00:26:01 +0000 Subject: ran_toks (10feb16) git-svn-id: svn://tug.org/texlive/trunk@39684 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/ran_toks/ran_toks.sty | 51 ++++++++++++++--------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/ran_toks/ran_toks.sty b/Master/texmf-dist/tex/latex/ran_toks/ran_toks.sty index 97328c55b3f..f656d89a241 100644 --- a/Master/texmf-dist/tex/latex/ran_toks/ran_toks.sty +++ b/Master/texmf-dist/tex/latex/ran_toks/ran_toks.sty @@ -7,7 +7,7 @@ %% ran_toks.dtx (with options: `copyright,package') %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% ran_toks.sty package, 2012/10/29 %% +%% ran_toks.sty package, 2013/08/03 %% %% Copyright (C) 2012 D. P. Story %% %% dpstory@uakron.edu %% %% %% @@ -19,9 +19,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{ran_toks} - [2012/11/18 v1.0a Randomizing tokens] + [2016/02/06 v1.0e Randomizing tokens] \RequirePackage{verbatim} -\input{random.tex} +\@ifundefined{nextrandom}{\input{random.tex}}{} \def\nextrandom{\begingroup \ifnum\randomi<\@ne % then initialize with time \global\randomi\time @@ -30,7 +30,7 @@ \global\multiply\randomi97 \global\advance\randomi\month \message{Randomizer initialized to \the\randomi.}% \nextrandom \nextrandom \nextrandom - \xdef\rtInitSeedValue{\the\randomi}% + \xdef\InitSeedValue{\the\randomi}% \fi \count@ii\randomi \divide\count@ii 127773 % modulus = multiplier * 127773 + 2836 @@ -58,22 +58,27 @@ \def\ranToksOff{\werandomizefalse} \def\useThisSeed#1{\saveseedfalse\randomi=#1} \@onlypreamble\useThisSeed -\def\useLastAsSeed{\IfFileExists{\jobname_rt.sav}% - {% +\def\useLastAsSeed{\rt@useLastAsSeed} +\@onlypreamble\useLastAsSeed +\def\rt@useLastAsSeed{% + \IfFileExists{\jobname_rt.sav}{% \PackageInfo{ran_toks}{Inputting \jobname_rt.sav}% - \newread\readsavfile + \@ifundefined{readsavfile}{\newread\readsavfile}{}% \openin\readsavfile=\jobname_rt.sav - \read\readsavfile to \rtInitSeedValue + \read\readsavfile to \InitSeedValue \read\readsavfile to \lastRandomNum \closein\readsavfile \randomi=\lastRandomNum + \xdef\InitSeedValue{\the\randomi} }{% \PackageInfo{ran_toks}{\jobname_rt.sav cannot be found, \MessageBreak using the random initializer}% }% } -\@onlypreamble\useLastAsSeed +\@ifundefined{aeb@randomizeChoices}{% + \let\inputRandomSeed\useLastAsSeed + \let\useRandomSeed\useThisSeed}{} \def\verbatimwrite{\@bsphack \let\do\@makeother\dospecials \catcode`\^^M\active \catcode`\^^I=12 @@ -83,18 +88,18 @@ \verbatim@start} \def\endverbatimwrite{\@esphack} \def\rt@IWVO{\immediate\write\verbatim@out} -\def\rtInitSeedValue{\the\randomi} +\def\InitSeedValue{\the\randomi} \def\rt@writeSeedData{% \ifsaveseed - \newwrite\rt@savedata - \immediate\openout \rt@savedata \jobname_rt.sav - \let\verbatim@out\rt@savedata + \@ifundefined{saveseedinfo}{\newwrite\saveseedinfo}{} + \immediate\openout \saveseedinfo \jobname_rt.sav + \let\verbatim@out\saveseedinfo \def\rt@msgi{initializing seed value}% \def\rt@msgii{last random number used}% \uccode`c=`\%\uppercase{% - \rt@IWVO{\rtInitSeedValue\space c \rt@msgi}% + \rt@IWVO{\InitSeedValue\space c \rt@msgi}% \rt@IWVO{\the\randomi\space c \rt@msgii}% - }% + }\immediate\closeout\saveseedinfo \fi } \AtEndDocument{\rt@writeSeedData}% @@ -192,9 +197,10 @@ \expandafter\r@nToks\expandafter{\the\rt@listIn}% } \def\rt@inputVerb#1{\input{\jobname_#1.cut}} -\long\def\r@ndToks#1{% - \ifx#1\par\def\rt@next{\r@ndToks}\else - \advance\rt@nMax1 +\def\rt@PAR{\par} +\long\def\r@ndToks#1{\def\rt@rgi{#1}% + \ifx\rt@rgi\rt@PAR\def\rt@next{\r@ndToks}\else + \advance\rt@nMax1\relax \global\@namedef{rtTok\the\rt@nMax\rt@BaseName}{#1}% \def\rt@next{\@ifnextchar\rt@NIL {\rt@endToks\@gobble}{\r@ndToks}}% @@ -210,11 +216,16 @@ } \def\assignRanToks#1{\advance\rt@nCnt1 \global\rt@nameedef{rtRanTok\the\rt@nCnt\rt@BaseName}% - {\noexpand\rtTokByNum[\rt@BaseName]{#1}}% + {\noexpand\@nameuse{rtTok#1\rt@BaseName}}% } \newcommand{\nToksFor}[1]{\@nameuse{nMax4#1}} -\newcommand{\rtTokByNum}[2][\rt@BaseName]{\@nameuse{rtTok#2#1}\ignorespaces} +\newcommand{\rtTokByNum}[2][\rt@BaseName]{\@nameuse{rtTok#2#1}% + \ignorespaces} \newcommand{\useRanTok}[2][\rt@BaseName]{\@nameuse{rtRanTok#2#1}} +\newcommand{\displayListRandomly}[2][]{\rt@nCnt=0\relax + \@whilenum\rt@nCnt<\nToksFor{#2}\advance\rt@nCnt1\relax + \do{#1\useRanTok{\the\rt@nCnt}}% +} \endinput %% %% End of file `ran_toks.sty'. -- cgit v1.2.3