GraphicsMagick: Changes intended to help tests under MinGW

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.26327.1670102625.1350.graphicsmagick-commit@lists.sourceforge.net>
changeset d99accd58bb5 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=d99accd58bb5
summary: Changes intended to help tests under MinGW

diffstat:

 ChangeLog                   |  11 ++++++++++
 Makefile.in                 |   1 +
 common.shi.in               |   1 +
 configure                   |   4 +++
 configure.ac                |   3 ++
 utilities/tests/common.sh   |  12 +++++-----
 utilities/tests/convert.tap |   2 +-
 winpath.sh                  |  48 ++++++++++++++++++++++++++------------------
 www/Changelog.html          |   5 ++++
 9 files changed, 60 insertions(+), 27 deletions(-)

diffs (247 lines):

diff -r a71a41ce1967 -r d99accd58bb5 ChangeLog
--- a/ChangeLog	Sat Dec 03 16:29:52 2022 +0100
+++ b/ChangeLog	Sat Dec 03 15:23:30 2022 -0600
@@ -1,5 +1,16 @@
 2022-12-03  Bob Friesenhahn  <[email protected]>
 
+	* configure.ac (top_srcdir_native): Produce a substituted value
+	representing the top source directory expressed suitable for the
+	native operating system.  This is to support MinGW.
+
+	* utilities/tests/convert.tap: Use ';' rather than '/' as sed
+	delimiter character since '/' is a directory separator..
+
+	* winpath.sh: Use printf rather than echo.  If an escape level is
+	not provided, then output an unescaped Windows path using
+	forward-slashes.
+
 	* Magick++/lib/Color.cpp: Add Quantum casts to Color() arguments
 	to solve error with unidentified compiler.  SourceForge issue #160
 	"Add Quantum casts for 16-bit to Image.cpp and Color.cpp".
diff -r a71a41ce1967 -r d99accd58bb5 Makefile.in
--- a/Makefile.in	Sat Dec 03 16:29:52 2022 +0100
+++ b/Makefile.in	Sat Dec 03 15:23:30 2022 -0600
@@ -2724,6 +2724,7 @@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
+top_srcdir_native = @top_srcdir_native@
 type_include_files = @type_include_files@
 windows_font_dir = @windows_font_dir@
 xml2_config = @xml2_config@
diff -r a71a41ce1967 -r d99accd58bb5 common.shi.in
--- a/common.shi.in	Sat Dec 03 16:29:52 2022 +0100
+++ b/common.shi.in	Sat Dec 03 15:23:30 2022 -0600
@@ -7,6 +7,7 @@
 top_builddir='@abs_top_builddir@'
 
 set -a
+TOP_SRCDIR_NATIVE='@top_srcdir_native@'
 GM="${MEMCHECK} @abs_top_builddir@/utilities/gm"
 LD_LIBRARY_PATH="@abs_top_builddir@/magick/.libs:${LD_LIBRARY_PATH}"
 
diff -r a71a41ce1967 -r d99accd58bb5 configure
--- a/configure	Sat Dec 03 16:29:52 2022 +0100
+++ b/configure	Sat Dec 03 15:23:30 2022 -0600
@@ -898,6 +898,7 @@
 LD
 FGREP
 SED
+top_srcdir_native
 DIRSEP
 MAGICK_FILTER_MODULE_PATH
 MAGICK_CONFIGURE_BUILD_PATH
@@ -5519,6 +5520,7 @@
 MAGICK_CONFIGURE_SRC_PATH="${srcdirfull}/config"
 MAGICK_CONFIGURE_BUILD_PATH="${builddir}/config"
 MAGICK_FILTER_MODULE_PATH="${builddir}/filters"
+top_srcdir_native=${srcdir}
 DIRSEP=':'
 case "${build_os}" in
   mingw* )
@@ -5526,6 +5528,7 @@
     MAGICK_CONFIGURE_SRC_PATH=`$WinPathScript "${MAGICK_CONFIGURE_SRC_PATH}" 0`
     MAGICK_CONFIGURE_BUILD_PATH=`$WinPathScript "${MAGICK_CONFIGURE_BUILD_PATH}" 0`
     MAGICK_FILTER_MODULE_PATH=`$WinPathScript "${MAGICK_FILTER_MODULE_PATH}" 0`
+    top_srcdir_native=`$WinPathScript "${srcdir}"`
     ;;
 esac
 case "${host_os}" in
@@ -5539,6 +5542,7 @@
 
 
 
+
 # Check for programs
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
diff -r a71a41ce1967 -r d99accd58bb5 configure.ac
--- a/configure.ac	Sat Dec 03 16:29:52 2022 +0100
+++ b/configure.ac	Sat Dec 03 15:23:30 2022 -0600
@@ -205,6 +205,7 @@
 MAGICK_CONFIGURE_SRC_PATH="${srcdirfull}/config"
 MAGICK_CONFIGURE_BUILD_PATH="${builddir}/config"
 MAGICK_FILTER_MODULE_PATH="${builddir}/filters"
+top_srcdir_native=${srcdir}
 DIRSEP=':'
 case "${build_os}" in
   mingw* )
@@ -212,6 +213,7 @@
     MAGICK_CONFIGURE_SRC_PATH=`$WinPathScript "${MAGICK_CONFIGURE_SRC_PATH}" 0`
     MAGICK_CONFIGURE_BUILD_PATH=`$WinPathScript "${MAGICK_CONFIGURE_BUILD_PATH}" 0`
     MAGICK_FILTER_MODULE_PATH=`$WinPathScript "${MAGICK_FILTER_MODULE_PATH}" 0`
+    top_srcdir_native=`$WinPathScript "${srcdir}"`
     ;;
 esac
 case "${host_os}" in
@@ -224,6 +226,7 @@
 AC_SUBST([MAGICK_CONFIGURE_BUILD_PATH])
 AC_SUBST([MAGICK_FILTER_MODULE_PATH])
 AC_SUBST([DIRSEP])
+AC_SUBST([top_srcdir_native])
 
 # Check for programs
 AC_PROG_CC
diff -r a71a41ce1967 -r d99accd58bb5 utilities/tests/common.sh
--- a/utilities/tests/common.sh	Sat Dec 03 16:29:52 2022 +0100
+++ b/utilities/tests/common.sh	Sat Dec 03 15:23:30 2022 -0600
@@ -5,12 +5,12 @@
 . ${top_srcdir}/scripts/tap-functions.shi
 mkdir -p ${subdir}
 cd ${subdir} || exit 1
-BETARGB_PROFILE="${top_srcdir}/utilities/tests/BetaRGB.icc"
-GENERIC_TTF="${top_srcdir}/PerlMagick/demo/Generic.ttf"
-MODEL_MIFF="${top_srcdir}/Magick++/demo/model.miff"
-SMILE_MIFF="${top_srcdir}/Magick++/demo/smile.miff"
-SUNRISE_JPEG="${top_srcdir}/utilities/tests/sunrise.jpg"
-SUNRISE_MIFF="${top_srcdir}/utilities/tests/sunrise.miff"
+BETARGB_PROFILE="${TOP_SRCDIR_NATIVE}/utilities/tests/BetaRGB.icc"
+GENERIC_TTF="${TOP_SRCDIR_NATIVE}/PerlMagick/demo/Generic.ttf"
+MODEL_MIFF="${TOP_SRCDIR_NATIVE}/Magick++/demo/model.miff"
+SMILE_MIFF="${TOP_SRCDIR_NATIVE}/Magick++/demo/smile.miff"
+SUNRISE_JPEG="${TOP_SRCDIR_NATIVE}/utilities/tests/sunrise.jpg"
+SUNRISE_MIFF="${TOP_SRCDIR_NATIVE}/utilities/tests/sunrise.miff"
 #CONVERT_FLAGS='-monitor'
 #COMPOSITE_FLAGS='-monitor'
 #MONTAGE_FLAGS='-monitor'
diff -r a71a41ce1967 -r d99accd58bb5 utilities/tests/convert.tap
--- a/utilities/tests/convert.tap	Sat Dec 03 16:29:52 2022 +0100
+++ b/utilities/tests/convert.tap	Sat Dec 03 15:23:30 2022 -0600
@@ -13,7 +13,7 @@
 # Number of tests we plan to execute
 test_plan_fn ${count}
 
-cat ${commands} | sed -e "s:\${SUNRISE_MIFF}:${SUNRISE_MIFF}:g" | while read subcommand
+cat ${commands} | sed -e "s;\${SUNRISE_MIFF};${SUNRISE_MIFF};g" | while read subcommand
 do
     #set -x
     # identity:10 produces a 1000x1000 image
diff -r a71a41ce1967 -r d99accd58bb5 winpath.sh
--- a/winpath.sh	Sat Dec 03 16:29:52 2022 +0100
+++ b/winpath.sh	Sat Dec 03 15:23:30 2022 -0600
@@ -1,14 +1,19 @@
 #!/bin/sh
-# Copyright (C) 2003 GraphicsMagick Group
+# Copyright (C) 2003-2022 GraphicsMagick Group
 #
 # This program is covered by multiple licenses, which are described in
 # Copyright.txt. You should have received a copy of Copyright.txt with this
 # package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 #
-# Convert the specified POSIX path to a Windows path under MinGW and Cygwin
-# The optional second parameter specifies the level of backslash escaping
-# to apply for each Windows backslash position in order to support varying
-# levels of variable substitutions in scripts.
+# Convert the specified POSIX path to a Windows path under MinGW and
+# Cygwin The optional second parameter specifies a level of back-slash
+# escaping to apply for each forward-slash position in order to
+# produce a native Windows path (using back-slashes) to support
+# varying levels of POSIX shell variable substitutions in scripts when
+# it is necessary to preserve/store native Windows paths.  If the
+# second parameter is not provided then a Windows-compatible path is
+# produced using only forward slashes (which are still accepted by
+# Windows).
 #
 # Note that Cygwin includes the 'cygpath' utility, which already provides
 # path translation capability.
@@ -16,15 +21,15 @@
 # Written by Bob Friesenhahn <[email protected]> June 2002
 #
 arg="$1"
-escapes=0
+escapes='none'
 if test -n "$2"
 then
   escapes="$2"
-fi
-if test $escapes -gt 3
-then
-  echo "$0: escape level must in range 0 - 3"
-  exit 1
+  if test $escapes -gt 3
+  then
+    printf "$0: escape level must in range 0 - 3\n"
+    exit 1
+  fi
 fi
 result=''
 length=0
@@ -33,9 +38,9 @@
   IFS="\n"
   while read mount_entry
   do
-    win_mount_path=`echo "$mount_entry" | sed -e 's: .*::g'`
-    unix_mount_path=`echo "$mount_entry" | sed -e 's:.* on ::;s: type .*::'`
-    temp=`echo "$arg" | sed -e "s!^$unix_mount_path!$win_mount_path!"`
+    win_mount_path=`printf "$mount_entry\n" | sed -e 's: .*::g'`
+    unix_mount_path=`printf "$mount_entry\n" | sed -e 's:.* on ::;s: type .*::'`
+    temp=`printf "$arg" | sed -e "s!^$unix_mount_path!$win_mount_path!"`
     if test "$temp" != "$arg"
     then
       candidate="$temp"
@@ -49,21 +54,24 @@
   done
   if test -z "$result"
   then
-    echo "$0: path \"$arg\" is not mounted"
+    printf "$0: path \"$arg\" is not mounted\n"
     exit 1
   fi
-  case $escapes in
+  case "$escapes" in
     0)
-     echo "$result" | sed -e 's:/:\\:g'
+     printf "${result}" | sed -e 's:/:\\:g'
      ;;
     1)
-     echo "$result" | sed -e 's:/:\\\\:g'
+     printf "${result}" | sed -e 's:/:\\\\:g'
      ;;
     2)
-     echo "$result" | sed -e 's:/:\\\\\\\\:g'
+     printf "${result}" | sed -e 's:/:\\\\\\\\:g'
      ;;
     3)
-     echo "$result" | sed -e 's:/:\\\\\\\\\\\\\\\\:g'
+     printf "${result}" | sed -e 's:/:\\\\\\\\\\\\\\\\:g'
+     ;;
+    *)
+     printf "${result}"
      ;;
   esac
   exit 0;
diff -r a71a41ce1967 -r d99accd58bb5 www/Changelog.html
--- a/www/Changelog.html	Sat Dec 03 16:29:52 2022 +0100
+++ b/www/Changelog.html	Sat Dec 03 15:23:30 2022 -0600
@@ -40,6 +40,11 @@
 <p>2022-12-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
+<li><p>utilities/tests/convert.tap: Use ';' rather than '/' as sed
+delimiter character since '/' is a directory separator..</p></li>
+<li><p>winpath.sh: Use printf rather than echo.  If an escape level is
+not provided, then output an unescaped Windows path using
+forward-slashes.</p></li>
 <li><p>Magick++/lib/Color.cpp: Add Quantum casts to Color() arguments
 to solve error with unidentified compiler.  SourceForge issue #160
 &quot;Add Quantum casts for 16-bit to Image.cpp and Color.cpp&quot;.</p></li>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.