groff-commit
[Top][All Lists]
Advanced

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

[groff] 03/04: pic2graph: Adapt to old convert(1) programs.


From: G. Branden Robinson
Subject: [groff] 03/04: pic2graph: Adapt to old convert(1) programs.
Date: Mon, 23 Apr 2018 05:34:34 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit b60f6b6d0c0a9655d10d32ee6688ac0f45fc3006
Author: G. Branden Robinson <address@hidden>
Date:   Mon Apr 23 04:14:55 2018 -0400

    pic2graph: Adapt to old convert(1) programs.
    
        * contrib/pic2graph/pic2graph.sh: Grep convert's -help output
          for the string "-trim".  If it is not found, the old method
          for image trimming documented in pic2graph's man page, "-crop
          0x0", is used.  I am motivated by the fact that the warning
          about this in our man page is very old (10 years or more), and
          I wanted to get rid of it.
    
          pic2graph emits a warning when performing this fallback, in
          the event the ImageMagick and/or GraphicsMagick teams surprise
          the world again.
    
        * contrib/pic2graph/pic2graph.1.man: Remove BUGS section, the
          entire contents of which was dedicated to convert's change in
          behavior.
    
    NEWS:
    * Add Emacs fill-column.
    * Add Vim modeline.
    * Wrap the few lines in this file that were longer that 76 columns
      (about 6 out of almost 2,900) and reflow their paragraphs.
    
    Signed-off-by: G. Branden Robinson <address@hidden>
---
 ChangeLog                         | 19 ++++++++++++++++++
 NEWS                              | 42 +++++++++++++++++++++++----------------
 contrib/pic2graph/pic2graph.1.man | 26 ------------------------
 contrib/pic2graph/pic2graph.sh    | 13 +++++++++++-
 4 files changed, 56 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3b7cbed..deb71f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2018-04-23  G. Branden Robinson <address@hidden>
+
+       pic2graph: Adapt to old convert(1) programs.
+
+       * contrib/pic2graph/pic2graph.sh: Grep convert's -help output
+         for the string "-trim".  If it is not found, the old method
+         for image trimming documented in pic2graph's man page, "-crop
+         0x0", is used.  I am motivated by the fact that the warning
+         about this in our man page is very old (10 years or more), and
+         I wanted to get rid of it.
+
+         pic2graph emits a warning when performing this fallback, in
+         the event the ImageMagick and/or GraphicsMagick teams surprise
+         the world again.
+
+       * contrib/pic2graph/pic2graph.1.man: Remove BUGS section, the
+         entire contents of which was dedicated to convert's change in
+         behavior.
+
 2018-04-22  G. Branden Robinson <address@hidden>
 
        groff_man(7): Expand command synopsis section.
diff --git a/NEWS b/NEWS
index fea449c..06d868a 100644
--- a/NEWS
+++ b/NEWS
@@ -27,10 +27,10 @@ o PDFPIC has now been corrected, so the behaviour is the 
same whether you
   which were written using the old behaviour will not be rendered correctly
   if using the pdf driver with the new version.
 
-  The change would mean that documents which relied on the previous behaviour
-  are likely to have a gap underneath the image which was not there before.
-  If you see this effect there are three ways you can restore the previous
-  0behaviour:-
+  The change would mean that documents which relied on the previous
+  behaviour are likely to have a gap underneath the image which was not
+  there before.  If you see this effect there are three ways you can restore
+  the previous 0behaviour:-
 
   Add the line ".nr PDFPIC_NOSPACE 1" to the document before the first call
   to .PDFPIC.
@@ -50,9 +50,15 @@ Miscellaneous
 -------------
 
 o New 'configure' option --with-compatibility-wrappers to control how groff
-  compatibility wrappers for vendor-provided non-GNU macro sets are installed
-  (See: ./configure --help).
+  compatibility wrappers for vendor-provided non-GNU macro sets are
+  installed (See: ./configure --help).
 
+o pic2graph now attempts to adapt to very old installed versions of the
+  ImageMagick and GraphicsMagick programs "convert".  pic2graph searches the
+  output of convert's "-help" option, and uses "-trim" if that string is
+  found; otherwise, the old "-crop 0x0" method (which produces incompatible
+  results on versions that _do_ support "-trim") is used.  pic2graph emits a
+  warning to standard error if the search fails and the old method is used.
 
 VERSION 1.22.3
 ==============
@@ -1427,8 +1433,8 @@ Eqn2graph
 ---------
 
 o A new script contributed by Eric S. Raymond <address@hidden>.  It
-  converts an EQN diagram into a cropped image.  Since it uses gs and the PNM
-  library, virtually all graphics formats are available for output.
+  converts an EQN diagram into a cropped image.  Since it uses gs and the
+  PNM library, virtually all graphics formats are available for output.
 
 Groffer
 -------
@@ -2006,9 +2012,9 @@ configure script).
 Documentation
 -------------
 
-Three new man pages are available: groff_tmac.5 (documenting how troff macros
-are accessed and where they are found), groff.7 (a short reference of the GNU
-roff language), and roff.7 (a general survey on GNU troff).
+Three new man pages are available: groff_tmac.5 (documenting how troff
+macros are accessed and where they are found), groff.7 (a short reference of
+the GNU roff language), and roff.7 (a general survey on GNU troff).
 
 Miscellaneous
 -------------
@@ -2030,10 +2036,10 @@ Bug fixes only; no user-visible changes.
 VERSION 1.12
 ============
 
-Finally, there are new maintainers for groff.  Mailing lists and a development
-repository are available also. See the file README for details.  Not all
-reported bugs could be fixed, so please send mails again if something is
-still not working.
+Finally, there are new maintainers for groff.  Mailing lists and a
+development repository are available also. See the file README for details.
+Not all reported bugs could be fixed, so please send mails again if
+something is still not working.
 
 Most of the installation problems should have vanished now (most
 notably the $(tmac_wrap) bug).
@@ -2765,8 +2771,8 @@ containing the hyphenation patterns.
 
 There is a `\C'xxx'' escape sequence equivalent to `\[xxx]'.
 
-Characters ", ', ), ], *, \(dg are now initially transparent for the purposes
-of end of sentence recognition.
+Characters ", ', ), ], *, \(dg are now initially transparent for the
+purposes of end of sentence recognition.
 
 There is an anti-recursion feature in the `char' request, so you can
 say `.char \(bu \s+2\(bu\s-2'.
@@ -2846,5 +2852,7 @@ definitions.
 Local Variables:
 version-control: never
 coding: latin-1
+fill-column: 76
 mode: text
 End:
+# vim: set autoindent textwidth=76:
diff --git a/contrib/pic2graph/pic2graph.1.man 
b/contrib/pic2graph/pic2graph.1.man
index 42f5ecc..b9ea5c3 100644
--- a/contrib/pic2graph/pic2graph.1.man
+++ b/contrib/pic2graph/pic2graph.1.man
@@ -177,32 +177,6 @@ Otherwise, temporary files will be created in
 .
 .
 .\" ====================================================================
-.SH BUGS
-.\" ====================================================================
-.
-Due to changes in the behavior of ImageMagick
-.BR \%convert (1)
-that are both forward and backward-incompatible,
-mismatches between your
-.B pic2graph
-and
-.BR \%convert (1)
-versions may produce zero-sized or untrimmed output images.
-.
-For this version of
-.B pic2graph
-you will need a version of
-.BR \%convert (1)
-that supports the
-.B \-trim
-option; older versions of
-.B pic2graph
-used
-.BR \-crop\~0x0 ,
-which no longer has trimming behavior.
-.
-.
-.\" ====================================================================
 .SH AUTHORS
 .\" ====================================================================
 .B pic2graph
diff --git a/contrib/pic2graph/pic2graph.sh b/contrib/pic2graph/pic2graph.sh
index fd3c4c9..7773b26 100644
--- a/contrib/pic2graph/pic2graph.sh
+++ b/contrib/pic2graph/pic2graph.sh
@@ -34,6 +34,7 @@
 #
 groffpic_opts=""
 convert_opts=""
+convert_trim_arg="-trim"
 format="png"
 eqndelim='$$'
 
@@ -83,6 +84,15 @@ if test -z "$tmp"; then
     { (exit 1); exit 1; }
 fi
 
+# See if the installed version of convert(1) is new enough to support the -trim
+# option.  Versions that didn't were described as "old" as early as 2008.
+is_convert_recent=`convert -help | grep -e -trim`
+if test -z "$is_convert_recent"
+then
+    echo "$0: warning: falling back to old '-crop 0x0' trim method" >&2
+    convert_trim_arg="-crop 0x0"
+fi
+
 trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' EXIT INT TERM
 
 # Here goes:
@@ -92,7 +102,8 @@ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' EXIT 
INT TERM
 # 4. Use convert(1) to crop the PostScript and turn it into a bitmap.
 (echo ".EQ"; echo $eqndelim; echo ".EN"; echo ".PS"; cat; echo ".PE") | \
     groff -e -p $groffpic_opts -Tps -P-pletter > $tmp/pic2graph.ps \
-    && convert -trim $convert_opts $tmp/pic2graph.ps $tmp/pic2graph.$format \
+    && convert $convert_trim_arg $convert_opts $tmp/pic2graph.ps \
+       $tmp/pic2graph.$format \
     && cat $tmp/pic2graph.$format
 
 # End



reply via email to

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