Skip to contentSkip to conversation

toolsoftrade: Fix up conventions around VerbatimT

PATCH In review Akira Yokosawa 2 participants 3 messages Jun 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 toolsoftrade: Fix up conventions around VerbatimT

After the convention introduced in commit b29ee7777f33 ("Redefine line count format at the beginning of VerbatimT env"), redefine \myfvline in front of \begin{VerbatimT}.

This restores custom form of line counts in Listing 4.14 such as "A1", "B2", "C3", etc.

Remove \fvset{} which is now redundant as well.

---
 toolsoftrade/toolsoftrade.tex | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
toolsoftrade/toolsoftrade.tex +3 -10
index d83e55f2..08efff11 100644
@@ -1487,24 +1487,19 @@ A short answer to this question is ``they lived dangerously''.
 \begin{listing}[tb]
 \begin{adjustwidth}{10pt}{5pt}
 \footnotesize
-\fvset{numbers=left,numbersep=5pt,fontsize=\scriptsize,frame=single,xrightmargin=5pt}
-{\renewcommand{\theFancyVerbLine}{%
-  {\rmfamily\tiny A\arabic{FancyVerbLine}}}
+\renewcommand{\myfvline}{A\arabic{FancyVerbLine}}
 \begin{VerbatimT}
 ptr = global_ptr;
 if (ptr != NULL && ptr < high_address)
 	do_low(ptr);
 \end{VerbatimT}
-}
 Might be transformed to:
-{\renewcommand{\theFancyVerbLine}{%
-  {\rmfamily\tiny B\arabic{FancyVerbLine}}}
+\renewcommand{\myfvline}{B\arabic{FancyVerbLine}}
 \begin{VerbatimT}
 if (global_ptr != NULL &&
     global_ptr < high_address)
 	do_low(global_ptr);
 \end{VerbatimT}
-}
 The compiler assumes normal variables do not spontaneously change,
 the surrounding code  might use many machine registers, and this
 transformation reduces register pressure.
@@ -1513,14 +1508,12 @@ to \co{NULL} between lines~B1 and~B2 of the transformed code, the
 two comparisons will be against different variables, possibly passing
 \co{do_low} a \co{NULL} pointer.
 Prevent this by using \co{READ_ONCE()} as follows:
-{\renewcommand{\theFancyVerbLine}{%
-  {\rmfamily\tiny C\arabic{FancyVerbLine}}}
+\renewcommand{\myfvline}{C\arabic{FancyVerbLine}}
 \begin{VerbatimT}
 ptr = READ_ONCE(global_ptr);
 if (ptr != NULL && ptr < high_address)
 	do_low(ptr);
 \end{VerbatimT}
-}
 \end{adjustwidth}
 \caption{Living Dangerously Early 1990s Style}
 \label{lst:toolsoftrade:Living Dangerously Early 1990s Style}

base-commit: f7fdd691fd80b87b08719f1faad5059105712f37

Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 toolsoftrade: Fix off-by-one error WRT Listing 4.14's line count

There is no such line "B4" there.

---
 toolsoftrade/toolsoftrade.tex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
toolsoftrade/toolsoftrade.tex +1 -1
index 08efff11..9b3f2e4e 100644
@@ -1527,7 +1527,7 @@ relatively small memories of that era.
 Nevertheless, problems did arise, as shown in lines~A1--A3 of
 \cref{lst:toolsoftrade:Living Dangerously Early 1990s Style},
 which the compiler is within its rights to transform into
-lines~B1--B4.
+lines~B1--B3.
 As you can see, the temporary on line~A1 has been optimized away, so
 that \co{global_ptr} will be loaded up to three times.
 This can be prevented using \co{READ_ONCE()} as shown on line~C1,
Signature · 1 line
2.43.0
#2 lore raw
In reply to Akira Yokosawa
Quoted 10 lines · Akira Yokosawa

After the convention introduced in commit b29ee7777f33 ("Redefine line count format at the beginning of VerbatimT env"), redefine \myfvline in front of \begin{VerbatimT}.

This restores custom form of line counts in Listing 4.14 such as "A1", "B2", "C3", etc.

Remove \fvset{} which is now redundant as well.

Much better, queued and pushed, and thank you for bearing with me on this one!

Thanx, Paul

Quoted 56 lines
---
 toolsoftrade/toolsoftrade.tex | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
toolsoftrade/toolsoftrade.tex +3 -10
index d83e55f2..08efff11 100644
@@ -1487,24 +1487,19 @@ A short answer to this question is ``they lived dangerously''.
 \begin{listing}[tb]
 \begin{adjustwidth}{10pt}{5pt}
 \footnotesize
-\fvset{numbers=left,numbersep=5pt,fontsize=\scriptsize,frame=single,xrightmargin=5pt}
-{\renewcommand{\theFancyVerbLine}{%
-  {\rmfamily\tiny A\arabic{FancyVerbLine}}}
+\renewcommand{\myfvline}{A\arabic{FancyVerbLine}}
 \begin{VerbatimT}
 ptr = global_ptr;
 if (ptr != NULL && ptr < high_address)
 	do_low(ptr);
 \end{VerbatimT}
-}
 Might be transformed to:
-{\renewcommand{\theFancyVerbLine}{%
-  {\rmfamily\tiny B\arabic{FancyVerbLine}}}
+\renewcommand{\myfvline}{B\arabic{FancyVerbLine}}
 \begin{VerbatimT}
 if (global_ptr != NULL &&
     global_ptr < high_address)
 	do_low(global_ptr);
 \end{VerbatimT}
-}
 The compiler assumes normal variables do not spontaneously change,
 the surrounding code  might use many machine registers, and this
 transformation reduces register pressure.
@@ -1513,14 +1508,12 @@ to \co{NULL} between lines~B1 and~B2 of the transformed code, the
 two comparisons will be against different variables, possibly passing
 \co{do_low} a \co{NULL} pointer.
 Prevent this by using \co{READ_ONCE()} as follows:
-{\renewcommand{\theFancyVerbLine}{%
-  {\rmfamily\tiny C\arabic{FancyVerbLine}}}
+\renewcommand{\myfvline}{C\arabic{FancyVerbLine}}
 \begin{VerbatimT}
 ptr = READ_ONCE(global_ptr);
 if (ptr != NULL && ptr < high_address)
 	do_low(ptr);
 \end{VerbatimT}
-}
 \end{adjustwidth}
 \caption{Living Dangerously Early 1990s Style}
 \label{lst:toolsoftrade:Living Dangerously Early 1990s Style}

base-commit: f7fdd691fd80b87b08719f1faad5059105712f37

Signature · 1 line
2.43.0