From 2531e37608bb6ac7f16564e0675b375ce5890346 Mon Sep 17 00:00:00 2001 From: Hanson Char Date: Wed, 10 Jul 2024 22:39:24 -0700 Subject: [PATCH 1/5] Fix infinite loop in the example on Loops over list of items provided under Section 2.6.2 of TeX-programming-notes.tex --- doc/latex/pgfplots/ChangeLog | 5 +++++ doc/latex/pgfplots/TeX-programming-notes.tex | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/latex/pgfplots/ChangeLog b/doc/latex/pgfplots/ChangeLog index a6fb226d..bc9edcda 100644 --- a/doc/latex/pgfplots/ChangeLog +++ b/doc/latex/pgfplots/ChangeLog @@ -1,3 +1,8 @@ +2024-07-10 Hanson Char + + Fix infinite loop in the example on Loops over list of items provided + under Section 2.6.2 of TeX-programming-notes.tex + 2021-12-27 Christian Feuersaenger fix linux file read permissions of some new lua files in TDS zip diff --git a/doc/latex/pgfplots/TeX-programming-notes.tex b/doc/latex/pgfplots/TeX-programming-notes.tex index a946e2db..00dfe28c 100644 --- a/doc/latex/pgfplots/TeX-programming-notes.tex +++ b/doc/latex/pgfplots/TeX-programming-notes.tex @@ -926,7 +926,7 @@ \subsubsection{Loops over list of items} }% \long\def\looppicker#1#2#3,{% \def\tempitem{#3}% - \ifx\tempitem\listingloopENDMARKER + \expandafter\ifx\tempitem\listingloopENDMARKER \let\next=\relax% \else \def#1{#3}% From 35c7359451311f8f129d380b8ddf52c947648aea Mon Sep 17 00:00:00 2001 From: Hanson Char Date: Thu, 11 Jul 2024 08:21:04 -0700 Subject: [PATCH 2/5] Changes per https://github.com/plante3 --- doc/latex/pgfplots/TeX-programming-notes.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/latex/pgfplots/TeX-programming-notes.tex b/doc/latex/pgfplots/TeX-programming-notes.tex index 00dfe28c..823baca2 100644 --- a/doc/latex/pgfplots/TeX-programming-notes.tex +++ b/doc/latex/pgfplots/TeX-programming-notes.tex @@ -920,13 +920,13 @@ \subsubsection{Loops over list of items} Looping over a list of items is very similar, only we will need |\ifx| in place of |\ifnum| and we need some end marker instead of the threshold value. However, how do we specify the list itself? Let's make some comma-separated list, e.\,g. |{a,b,c,d}| and call the end marker |\listingloopENDMARKER|. \begin{codeexample}[] -\def\listingloopENDMARKER{\par \listingloopENDMARKER} +\def\listingloopENDMARKER{\listingloopENDMARKER} \long\def\listingloop#1in#2#3{% \looppicker{#1}{#3}#2,\listingloopENDMARKER,% }% \long\def\looppicker#1#2#3,{% \def\tempitem{#3}% - \expandafter\ifx\tempitem\listingloopENDMARKER + \ifx\tempitem\listingloopENDMARKER \let\next=\relax% \else \def#1{#3}% @@ -936,7 +936,7 @@ \subsubsection{Loops over list of items} \next }% \listingloop\x in{a,b,c,,d,e}{% - The current item is `\x' + The current item is `\x'\par } \end{codeexample} From c70bfd9082a8348fbd4473f735c5db71c981f31c Mon Sep 17 00:00:00 2001 From: Hanson Char Date: Thu, 11 Jul 2024 11:42:36 -0700 Subject: [PATCH 3/5] Fix dead loop of build system when `make notes` --- doc/latex/pgfplots/TeX-programming-notes.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/latex/pgfplots/TeX-programming-notes.tex b/doc/latex/pgfplots/TeX-programming-notes.tex index 823baca2..195531bb 100644 --- a/doc/latex/pgfplots/TeX-programming-notes.tex +++ b/doc/latex/pgfplots/TeX-programming-notes.tex @@ -933,9 +933,9 @@ \subsubsection{Loops over list of items} #2% \def\next{\looppicker{#1}{#2}}% \fi - \next + \next% }% -\listingloop\x in{a,b,c,,d,e}{% +\listingloop\x in{aa, b,c ,,d,e}{% The current item is `\x'\par } \end{codeexample} From 92241b782c5ab5ac0603174c5ca442bf2529336d Mon Sep 17 00:00:00 2001 From: Hanson Char Date: Thu, 11 Jul 2024 20:07:28 -0700 Subject: [PATCH 4/5] Fix typo --- doc/latex/pgfplots/TeX-programming-notes.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/latex/pgfplots/TeX-programming-notes.tex b/doc/latex/pgfplots/TeX-programming-notes.tex index 195531bb..10804ce0 100644 --- a/doc/latex/pgfplots/TeX-programming-notes.tex +++ b/doc/latex/pgfplots/TeX-programming-notes.tex @@ -944,7 +944,7 @@ \subsubsection{Loops over list of items} \begin{itemize} \item We have defined |\listingloopENDMARKER| to replace itself. This is possible because |\ifx| will only compare first-level expansion, see Section~\ref{sec:branching}. \item We seem to miss a white space in \ldots|#1in#2|\ldots. However, tokens are always ending with an additional white space as |\xin| is not equal to |\x in|. Hence, none is needed here and more than one white space would probably get gobbled. - \item The definition |\looppicker#1#2#3,|\ldots has three arguments but the recursive call |\looppicker{#1}{#2}| only gives two arguments!? This is the actual magic making this type of list possible! \TeX{} is actually scanning beyond the scope of the given token to obtain the third argument. In effect, we are biting off piece by piece, list item by list item off the given list. All because we have stated an additional |,| -- comma being the item separator -- in the definition of the |\looppicker| macro. The expansion of the loop macro will always pick up one more item from the list concatenated to its end until it has reached the |\ENDMARKER|. This is added to the list's very end on the loop's start, and there it stops. + \item The definition |\looppicker#1#2#3,|\ldots has three arguments but the recursive call |\looppicker{#1}{#2}| only gives two arguments!? This is the actual magic making this type of list possible! \TeX{} is actually scanning beyond the scope of the given token to obtain the third argument. In effect, we are biting off piece by piece, list item by list item off the given list. All because we have stated an additional |,| -- comma being the item separator -- in the definition of the |\looppicker| macro. The expansion of the loop macro will always pick up one more item from the list concatenated to its end until it has reached the |\listingloopENDMARKER|. This is added to the list's very end on the loop's start, and there it stops. \end{itemize} \subsection{More On \TeX} From 0f6217d38025dda2650a95d644700363cb462e4a Mon Sep 17 00:00:00 2001 From: Hanson Char Date: Fri, 12 Jul 2024 00:55:49 -0700 Subject: [PATCH 5/5] Add co-contributor plante to ChangeLog --- doc/latex/pgfplots/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/latex/pgfplots/ChangeLog b/doc/latex/pgfplots/ChangeLog index bc9edcda..c1999c52 100644 --- a/doc/latex/pgfplots/ChangeLog +++ b/doc/latex/pgfplots/ChangeLog @@ -1,4 +1,4 @@ -2024-07-10 Hanson Char +2024-07-10 Hanson Char and plante Fix infinite loop in the example on Loops over list of items provided under Section 2.6.2 of TeX-programming-notes.tex