-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix infinite loop in the example on Loops over list of items provided under Section 2.6.2 of TeX-programming-notes.tex #485
Open
hansonchar
wants to merge
5
commits into
pgf-tikz:master
Choose a base branch
from
hansonchar:Section2.6.2-infiniteloop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2531e37
Fix infinite loop in the example on Loops over list of items
hansonchar 35c7359
Changes per https://github.com/plante3
hansonchar c70bfd9
Fix dead loop of build system when `make notes`
hansonchar 92241b7
Fix typo
hansonchar 0f6217d
Add co-contributor plante to ChangeLog
hansonchar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
2024-07-10 Hanson Char <[email protected]> and plante <[email protected]> | ||
|
||
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 <[email protected]> | ||
|
||
fix linux file read permissions of some new lua files in TDS zip | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -920,7 +920,7 @@ \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,% | ||
}% | ||
|
@@ -933,18 +933,18 @@ \subsubsection{Loops over list of items} | |
#2% | ||
\def\next{\looppicker{#1}{#2}}% | ||
\fi | ||
\next | ||
\next% | ||
}% | ||
\listingloop\x in{a,b,c,,d,e}{% | ||
The current item is `\x' | ||
\listingloop\x in{aa, b,c ,,d,e}{% | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I modified the test cases to have a wider range of coverage of what otherwise could have gone wrong without being noticed. |
||
The current item is `\x'\par | ||
} | ||
\end{codeexample} | ||
|
||
Again, we make clear the subtleties contained therein: | ||
\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} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note I needed to append
%
here somake notes
won't get into an infinite loop. Basically a hack to get around what seems to be a flaw of the existing build system.