groff-commit
[Top][All Lists]
Advanced

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

[groff] 03/03: [configure]: Warn of buggy Ghostscript versions.


From: G. Branden Robinson
Subject: [groff] 03/03: [configure]: Warn of buggy Ghostscript versions.
Date: Sun, 16 May 2021 05:31:05 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit ebc2637532ff35b1261f6d7cc207f122dc4f2e26
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun May 16 19:18:42 2021 +1000

    [configure]: Warn of buggy Ghostscript versions.
    
    * m4/groff.m4 (GROFF_GHOSTSCRIPT_VERSION_CHECK): Add new autoconf macro
      to check if Ghostscript version.  Versions 9.00 <= x < 9.54 suffer
      from a rendering glitch that affects the AT&T troff (and groff)
      special character \(lh; see
      <https://bugs.ghostscript.com/show_bug.cgi?id=703187>.  Store the
      result of the check.
    
      (GROFF_GHOSTSCRIPT_VERSION_NOTICE): Add new macro to report the
      problem detected by GROFF_GHOSTSCRIPT_VERSION_CHECK to the user.
    
    * configure.ac: Call the macros in appropriate places.
    
    Fixes <https://savannah.gnu.org/bugs/index.php?59531>.
    
    I did not name GROFF_GHOSTSCRIPT_VERSION_NOTICE consistently with other
    groff autoconf macros of similar purpose; I find the existing names,
    ending in "_CHECK", confusing because these don't perform checks except
    in a trivial sense (effectively of a single Boolean variable).  Instead
    they are wrappers around a lengthy parameter to AC_MSG_NOTICE.
    
    By contrast, GROFF_GHOSTSCRIPT_VERSION_CHECK does the actual ugly
    business of calling `gs -v`, munging the resulting string, and
    comparison.  (I tried AX_COMPARE_VERSION but couldn't get it to work,
    and in any case the Ghostscript versioning scheme is simple and sane.)
    
    I'm open to feedback on writing more idiomatic autoconf macros.
---
 ChangeLog    | 15 +++++++++++++
 configure.ac |  2 ++
 m4/groff.m4  | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f64ae5d..1b0e979 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2021-05-16  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       * m4/groff.m4 (GROFF_GHOSTSCRIPT_VERSION_CHECK): Add new
+       autoconf macro to check if Ghostscript version.  Versions 9.00
+       <= x < 9.54 suffer from a rendering glitch that affects the AT&T
+       troff (and groff) special character \(lh; see
+       <https://bugs.ghostscript.com/show_bug.cgi?id=703187>.  Store
+       the result of the check.
+       (GROFF_GHOSTSCRIPT_VERSION_NOTICE): Add new macro to report the
+       problem detected by GROFF_GHOSTSCRIPT_VERSION_CHECK to the user.
+
+       * configure.ac: Call the macros in appropriate places.
+
+       Fixes <https://savannah.gnu.org/bugs/index.php?59531>.
+
+2021-05-16  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        * tmac/andoc.tmac (reload-man): Remove removal of RI macro, made
        unnecessary by commit 551f138 (15 May).
 
diff --git a/configure.ac b/configure.ac
index f3e393b..08b7af0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,6 +166,7 @@ GROFF_MAKE_RM
 GROFF_DIFF_D
 GROFF_HAVE_TEST_EF_OPTION
 GROFF_BASH
+GROFF_GHOSTSCRIPT_VERSION_CHECK
 gl_GLIBC21
 gl_LOCALCHARSET
 
@@ -236,3 +237,4 @@ echo "\
 GROFF_APPRESDIR_CHECK
 GROFF_URW_FONTS_CHECK
 GROFF_UCHARDET_CHECK
+GROFF_GHOSTSCRIPT_VERSION_NOTICE
diff --git a/m4/groff.m4 b/m4/groff.m4
index 2ecf1af..7c6e6d0 100644
--- a/m4/groff.m4
+++ b/m4/groff.m4
@@ -457,6 +457,78 @@ AC_DEFUN([GROFF_GHOSTSCRIPT_PREFS],
     [ALT_GHOSTSCRIPT_PROGS="gs gswin32c gsos2"])
    AC_SUBST([ALT_GHOSTSCRIPT_PROGS])])
 
+# Ghostscript version check.  Versions 9.00 <= x < 9.54 suffer from a
+# rendering glitch that affects the AT&T troff (and groff) special
+# character \(lh; see
+#   <https://bugs.ghostscript.com/show_bug.cgi?id=703187>.
+
+AC_DEFUN([GROFF_GHOSTSCRIPT_VERSION_CHECK], [
+  if test "$GHOSTSCRIPT" != "missing"
+  then
+    AC_MSG_CHECKING([for gs version with good left sidebearing handling])
+    ghostscript_notice=
+    GHOSTSCRIPT_VERSION_GOOD=
+    GHOSTSCRIPT_V_STRING=`"$GHOSTSCRIPT" -v | sed 1q`
+    # Get first word.
+    GHOSTSCRIPT_WORDS=`echo "$GHOSTSCRIPT_V_STRING" | cut -d\  -f1-`
+
+    # If the first word is "GPL", discard it.
+    if expr "$GHOSTSCRIPT_WORDS" : "GPL" > /dev/null
+    then
+      GHOSTSCRIPT_WORDS=`echo "$GHOSTSCRIPT_WORDS" | cut -d\  -f2-`
+    fi
+
+    # Only do a version check if the program calls itself Ghostscript.
+    if expr "$GHOSTSCRIPT_WORDS" : "Ghostscript" > /dev/null
+    then
+      GHOSTSCRIPT_VERSION_GOOD=no
+      GHOSTSCRIPT_VERSION=`echo "$GHOSTSCRIPT_WORDS" | cut -d\  -f2`
+      GHOSTSCRIPT_MAJOR=`echo "$GHOSTSCRIPT_VERSION" | cut -d. -f1`
+      GHOSTSCRIPT_MINOR=`echo "$GHOSTSCRIPT_VERSION" | cut -d. -f2`
+
+      if test "$GHOSTSCRIPT_MAJOR" -lt 9
+      then
+        GHOSTSCRIPT_VERSION_GOOD=yes
+      elif test "$GHOSTSCRIPT_MAJOR" -ge 10
+      then
+        GHOSTSCRIPT_VERSION_GOOD=yes
+      elif test "$GHOSTSCRIPT_MINOR" -ge 54
+      then
+        GHOSTSCRIPT_VERSION_GOOD=yes
+      fi
+    fi
+
+    if test "$GHOSTSCRIPT_VERSION_GOOD" = "yes"
+    then
+      GHOSTSCRIPT_VERSION="$GHOSTSCRIPT_VERSION (good)"
+    elif test "$GHOSTSCRIPT_VERSION_GOOD" = "no"
+    then
+      GHOSTSCRIPT_VERSION="$GHOSTSCRIPT_VERSION (buggy)"
+      ghostscript_notice="Buggy version of Ghostscript detected."
+    else
+      ghostscript_notice="Unable to determine version of Ghostscript."
+    fi
+
+    if test -n "$GHOSTSCRIPT_VERSION"
+    then
+      AC_MSG_RESULT([got $GHOSTSCRIPT_VERSION])
+    else
+      AC_MSG_RESULT([unable to determine])
+    fi
+  fi])
+
+AC_DEFUN([GROFF_GHOSTSCRIPT_VERSION_NOTICE], [
+  if test -n "$ghostscript_notice"
+    then
+     AC_MSG_NOTICE([$ghostscript_notice
+
+  Ghostscript versions 9.00 <= x < 9.54 suffer from a rendering glitch
+  that affects the AT&T troff (and groff) special character \(lh; see
+  <https://bugs.ghostscript.com/show_bug.cgi?id=703187>.  If your
+  version of Ghostscript has not been patched to fix this problem, you
+  may need to work around it in groff documents you render for the
+  PostScript (and, for tbl(1) tables, HTML) output devices.])
+  fi])
 
 # Check location of 'awk'; allow '--with-awk=PROG' option to override.
 



reply via email to

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