groff-commit
[Top][All Lists]
Advanced

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

[groff] 19/31: [nroff]: Slightly refactor.


From: G. Branden Robinson
Subject: [groff] 19/31: [nroff]: Slightly refactor.
Date: Sun, 25 Jul 2021 02:39:48 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 5ddc467c07f5128ccd4734492d7530df3a07b313
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Jul 24 08:18:51 2021 +1000

    [nroff]: Slightly refactor.
    
    * src/roff/nroff/nroff.sh: Slightly refactor.  Rename formerly unused
      loop index variable from `i` to `arg` to leverage it in a later
      diagnostic message without a separate definition.  Inside the loop,
      expand `arg` instead of positional parameter 1, the meaning of which
      is less obvious after the parameter list is shifted by the new
      `is_option_argument_pending` logic (commit 2b955c57, 20 July).
---
 ChangeLog               | 10 ++++++++++
 src/roff/nroff/nroff.sh | 20 +++++++++-----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 15cd8b5..1274c28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2021-07-23  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       * src/roff/nroff/nroff.sh: Slightly refactor.  Rename formerly
+       unused loop index variable from `i` to `arg` to leverage it in a
+       later diagnostic message without a separate definition.  Inside
+       the loop, expand `arg` instead of positional parameter 1, the
+       meaning of which is less obvious after the parameter list is
+       shifted by the new `is_option_argument_pending` logic (commit
+       2b955c57, 20 July).
+
+2021-07-23  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        * src/roff/groff/groff.1.man (Options) <-S>: Fix error: `-S`
        sets safer mode (redundantly) but is not passed to pic and troff
        as was claimed.
diff --git a/src/roff/nroff/nroff.sh b/src/roff/nroff/nroff.sh
index d4be5f5..951ad14 100644
--- a/src/roff/nroff/nroff.sh
+++ b/src/roff/nroff/nroff.sh
@@ -63,21 +63,19 @@ Topt=
 opts=
 dry_run=
 is_option_argument_pending=
-for i
-do
-  # Remember last argument seen for a usage diagnostic after loop exits.
-  arg=$1
 
+for arg
+do
   if [ -n "$is_option_argument_pending" ]
   then
     is_option_argument_pending=
-    opts="$opts $1"
+    opts="$opts $arg"
     shift
   fi
 
   case $1 in
     -c)
-      opts="$opts $1 -P-c" ;;
+      opts="$opts $arg -P-c" ;;
     -h)
       opts="$opts -P-h" ;;
     -[eq] | -s*)
@@ -85,11 +83,11 @@ do
       ;;
     -[dKmMnoPrTwW])
       is_option_argument_pending=yes
-      opts="$opts $1" ;;
+      opts="$opts $arg" ;;
     -[bCEikpStUz] | -[dKMmrnoPwW]*)
-      opts="$opts $1" ;;
+      opts="$opts $arg" ;;
     -T*)
-      Topt=$1 ;;
+      Topt=$arg ;;
     -u*)
       # -u is for Solaris compatibility and not otherwise documented.
       #
@@ -102,7 +100,7 @@ do
       dry_run=yes ;;
     -v | --version)
       echo "GNU nroff (groff) version @VERSION@"
-      opts="$opts $1" ;;
+      opts="$opts $arg" ;;
     --help)
       cat <<EOF
 usage: $prog [-bcCEhikpStUVz] [-dCS] [-dNAME=STRING] [-Karg] [-mNAME]\
@@ -117,7 +115,7 @@ EOF
     -)
       break ;;
     -*)
-      echo "$prog: usage error: invalid option '$1';" \
+      echo "$prog: usage error: invalid option '$arg';" \
            " see '$prog --help'" >&2
       exit 2 ;;
     *)



reply via email to

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