groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 04/35: tmac/pdfpic.tmac: Refactor PDFPIC_NOSPACE handling.


From: G. Branden Robinson
Subject: [groff] 04/35: tmac/pdfpic.tmac: Refactor PDFPIC_NOSPACE handling.
Date: Mon, 21 Feb 2022 06:15:48 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit d026a4c4949156fc1a0bb0e61987c19ee3b2cac4
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Feb 15 02:18:06 2022 +1100

    tmac/pdfpic.tmac: Refactor PDFPIC_NOSPACE handling.
    
    * tmac/pdfpic.tmac (PDFPIC): Refactor PDFPIC_NOSPACE handling.  Stop
      shelling out to create, and then sourcing, a temporary file just to
      obtain the value of an environment variable.  groff already has the
      `\V` escape sequence for that purpose (it's even safe!).  Check that
      the value of $GROFF_PDFPIC_NOSPACE is a valid numeric expression
      before assigning it to a register.  Trivially, use '=' instead of '=='
      as an equality operator.  *roff languages do not use '=' as an
      assignment operator, and I believe the '==' synonym to be a sop to C
      programmers.
---
 ChangeLog        | 12 ++++++++++++
 tmac/pdfpic.tmac |  8 ++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b66127e8..4f5ab82f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2022-02-15  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tmac/pdfpic.tmac (PDFPIC): Refactor PDFPIC_NOSPACE handling.
+       Stop shelling out to create, and then sourcing, a temporary file
+       just to obtain the value of an environment variable.  groff
+       already has the `\V` escape sequence for that purpose (it's even
+       safe!).  Check that the value of $GROFF_PDFPIC_NOSPACE is a
+       valid numeric expression before assigning it to a register.
+       Trivially, use '=' instead of '==' as an equality operator.
+       *roff languages do not use '=' as an assignment operator, and I
+       believe the '==' synonym to be a sop to C programmers.
+
 2022-02-14  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [man]: Stop attempting to adjust pargraph tag lines.
diff --git a/tmac/pdfpic.tmac b/tmac/pdfpic.tmac
index 342d49d6..96fa7f6b 100644
--- a/tmac/pdfpic.tmac
+++ b/tmac/pdfpic.tmac
@@ -221,11 +221,11 @@ skipping
 \X'pdf: pdfpic \\$1 -L \\n[pdfpic*desired-width]z \
 \\n[pdfpic*desired-height]z'
 .  if !r PDFPIC_NOSPACE \{\
-.    sy echo ".nr PDFPIC_NOSPACE 0$GROFF_PDFPIC_NOSPACE" > /tmp/x\n[$$]
-.    so /tmp/x\n[$$]
-.    sy rm /tmp/x\n[$$]
+.    nr PDFPIC_NOSPACE 0
+.    if \B'\\V[GROFF_PDFPIC_NOSPACE]' \
+.      nr PDFPIC_NOSPACE \\V[GROFF_PDFPIC_NOSPACE]
 .  \}
-.  if \\n[PDFPIC_NOSPACE]==0 \{\
+.  if \\n[PDFPIC_NOSPACE]=0 \{\
 .    br
 .    sp \\n[pdfpic*desired-height]u
 .  \}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]