groff-commit
[Top][All Lists]
Advanced

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

[groff] 25/28: src/utils/afmtodit/make-afmtodit-tables: Refactor.


From: G. Branden Robinson
Subject: [groff] 25/28: src/utils/afmtodit/make-afmtodit-tables: Refactor.
Date: Wed, 25 May 2022 22:43:24 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 3f4ae24ef67540758564112cb0609fea1566e60a
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed May 25 21:10:00 2022 -0500

    src/utils/afmtodit/make-afmtodit-tables: Refactor.
    
    * src/utils/afmtodit/make-afmtodit-tables: Refactor.  Drop unused
      variable `prog`.  Use value of `CPP` from environment (if defined) and
      use parameter expansion to apply a default if null or not set.  Use
      for loop to eliminate duplicative if statement.  Test input files for
      readability, not just existence.  Use more portable test(1) and shell
      syntax.  Swap usage error and fatal error exit statuses; using "1" for
      failure and "2" for usage errors is more common in shell scripts I've
      seen.  Update usage message to put non-literal parameter in full caps,
      and clarify its name.  Update comment blocks written to generated
      files to further clarify data provenance.
---
 ChangeLog                               | 14 ++++++++++
 src/utils/afmtodit/make-afmtodit-tables | 45 ++++++++++++++++-----------------
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7c2dff9c..6290b3db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2022-05-25  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/utils/afmtodit/make-afmtodit-tables: Refactor.  Drop
+       unused variable `prog`.  Use value of `CPP` from environment (if
+       defined) and use parameter expansion to apply a default if null
+       or not set.  Use for loop to eliminate duplicative if statement.
+       Test input files for readability, not just existence.  Use more
+       portable test(1) and shell syntax.  Swap usage error and fatal
+       error exit statuses; using "1" for failure and "2" for usage
+       errors is more common in shell scripts I've seen.  Update usage
+       message to put non-literal parameter in full caps, and clarify
+       its name.  Update comment blocks written to generated files to
+       further clarify data provenance.
+
 2022-05-25  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * m4/groff.m4 (GROFF_PRINT): Refactor.  Stop performing checks
diff --git a/src/utils/afmtodit/make-afmtodit-tables 
b/src/utils/afmtodit/make-afmtodit-tables
index 2f188b7b..937bb728 100755
--- a/src/utils/afmtodit/make-afmtodit-tables
+++ b/src/utils/afmtodit/make-afmtodit-tables
@@ -36,28 +36,25 @@
 # This program needs a C preprocessor.
 #
 
-CPP=cpp
-
-prog="$0"
-
-if test $# -ne 3; then
-  echo "usage: $0 UnicodeData.txt <version-string> glyphlist.txt >" \
-    "afmtodit.in"
-  exit 1
+if [ $# -ne 3 ]
+then
+  echo "usage: $0 UnicodeData.txt UNICODE-VERSION-STRING" \
+    "glyphlist.txt > afmtodit.tables"
+  exit 2
 fi
 
 unicode_data="$1"
-version_string="$2"
+unicode_version="$2"
 glyph_list="$3"
 
-if test ! -f "$1"; then
-  echo "File '$1' doesn't exist" >&2
-  exit 2
-fi
-if test ! -f "$3"; then
-  echo "File '$3' doesn't exist" >&2
-  exit 2
-fi
+for f in "$1" "$3"
+do
+  if ! [ -r "$f" ]
+  then
+    echo "$0: '$f' does not exist or is not readable" >&2
+    exit 1
+  fi
+done
 
 # Handle UnicodeData.txt.
 #
@@ -79,7 +76,7 @@ cat $$1 \
 | sed -e 's/^\([^;]*\);.*$/\1 u\1/' >> $$2
 
 # Run C preprocessor to recursively decompose.
-$CPP $$2 $$3
+"${CPP:-cpp}" $$2 $$3
 
 # Convert it back to original format.
 cat $$3 \
@@ -92,8 +89,8 @@ cat $$3 \
 
 # Write comment.
 cat <<END
-# This table has been algorithmically derived from the file
-# UnicodeData.txt, version $version_string, available from unicode.org,
+# This table was algorithmically derived from the file 'UnicodeData.txt'
+# for Unicode $unicode_version, available from unicode.org,
 # on `date '+%Y-%m-%d'`.
 END
 
@@ -107,9 +104,11 @@ echo ''
 
 # Write comment.
 cat <<END
-# This table has been algorithmically derived from the file
-# glyphlist.txt, version 2.0, available from partners.adobe.com,
-# on `date '+%Y-%m-%d'`.  See "groff:" comments for altered mappings.
+# This table was algorithmically derived from the Adobe Glyph List (AGL)
+# file 'glyphlist.txt' from the GitHub Adobe Type Tools agl-aglfn
+# project, on `date '+%Y-%m-%d'`.
+#
+# See "groff:" comments for altered mappings.
 END
 
 # Convert AGL syntax to a chunk of Perl.



reply via email to

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