bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] more ports to Solaris tr, which needs [] around ranges


From: Bruno Haible
Subject: Re: [PATCH] more ports to Solaris tr, which needs [] around ranges
Date: Wed, 6 Oct 2010 00:59:22 +0200
User-agent: KMail/1.9.9

Hi Paul,

> * gnulib-tool: Solaris tr needs [] around ranges.
> * m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Likewise.
> * tests/test-pipe-filter-gi1.c (main): Likewise.
> * tests/test-pipe-filter-ii1.c (main): Likewise.

Good catch: The first two would likely be visible as bugs.

But I don't understand two things about this patch:

1) Years ago, you defined the "gnulib philosophy":
     - Programmers should write programs that look like POSIX.
     - The necessary platform-dependent workarounds should be
       centralized.

Here the problem is that Solaris 'tr' does not support ranges in POSIX
syntax. The autoconf manual
<http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Usual-Tools.html>
gives a workaround according to the gnulib philosophy: Use /usr/xpg4/bin/tr
instead of tr from $PATH.

Why not use this workaround in gnulib-tool?

2) There was already a fix in tests/test-pipe-filter-gi1.c and
tests/test-pipe-filter-ii1.c, which (IIRC) I tested when I committed it:
<http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=a3ae6e8ac4e122d3492ea9739e7cd0242fca9a31>

Here is a proposed patch.


2010-10-05  Bruno Haible  <address@hidden>

        Less intrusive workarounds for Solaris 'tr'.
        * gnulib-tool: Undo last change.
        (TR): New variable.
        (tr): New function.
        * tests/test-pipe-filter-gi1.c (main): Undo last change. Workaround
        already in place since 2009-08-16.
        * tests/test-pipe-filter-ii1.c (main): Likewise.

--- gnulib-tool.orig    Wed Oct  6 00:52:02 2010
+++ gnulib-tool Wed Oct  6 00:51:27 2010
@@ -119,6 +119,25 @@
   sed_comments=false
 fi
 
+# Find a 'tr' program that supports character ranges in the POSIX syntax.
+# Solaris /usr/bin/tr does not.
+if test -f /usr/xpg6/bin/tr; then
+  TR=/usr/xpg6/bin/tr
+else
+  if test -f /usr/xpg4/bin/tr; then
+    TR=/usr/xpg4/bin/tr
+  else
+    TR=tr
+  fi
+fi
+if test $TR != tr; then
+  # Define tr as a shell function.
+  tr ()
+  {
+    $TR "$@"
+  }
+fi
+
 # func_usage
 # outputs to stdout the --help usage message.
 func_usage ()
@@ -4584,7 +4603,7 @@
     # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
     # created using libtool, because libtool already handles the dependencies.
     if test "$libtool" != true; then
-      libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
+      libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
       echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
       echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
       echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
@@ -5163,7 +5182,7 @@
      # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
      # created using libtool, because libtool already handles the dependencies.
      if test "$libtool" != true; then
-       libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
+       libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
        echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
        echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
        echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
@@ -5281,7 +5300,7 @@
    # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
    # created using libtool, because libtool already handles the dependencies.
    if test "$libtool" != true; then
-     libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
+     libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
      echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
      echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
      echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
--- tests/test-pipe-filter-gi1.c.orig   Wed Oct  6 00:52:02 2010
+++ tests/test-pipe-filter-gi1.c        Wed Oct  6 00:47:23 2010
@@ -26,8 +26,8 @@
 #include "macros.h"
 
 
-/* Pipe a text file through 'tr "[a-z]" "[A-Z]"', which converts ASCII
-   characters from lower case to upper case.  */
+/* Pipe a text file through 'tr a-z A-Z', which converts ASCII characters from
+   lower case to upper case.  */
 
 struct locals
 {
@@ -96,8 +96,8 @@
     l.nread = 0;
 
     argv[0] = tr_program;
-    argv[1] = "[a-z]";
-    argv[2] = "[A-Z]";
+    argv[1] = "a-z";
+    argv[2] = "A-Z";
     argv[3] = NULL;
 
     f = pipe_filter_gi_create ("tr", tr_program, argv, false, true,
--- tests/test-pipe-filter-ii1.c.orig   Wed Oct  6 00:52:02 2010
+++ tests/test-pipe-filter-ii1.c        Wed Oct  6 00:47:23 2010
@@ -26,8 +26,8 @@
 #include "macros.h"
 
 
-/* Pipe a text file through 'tr "[a-z]" "[A-Z]"', which converts ASCII
-   characters from lower case to upper case.  */
+/* Pipe a text file through 'tr a-z A-Z', which converts ASCII characters from
+   lower case to upper case.  */
 
 struct locals
 {
@@ -119,8 +119,8 @@
     l.nread = 0;
 
     argv[0] = tr_program;
-    argv[1] = "[a-z]";
-    argv[2] = "[A-Z]";
+    argv[1] = "a-z";
+    argv[2] = "A-Z";
     argv[3] = NULL;
 
     result = pipe_filter_ii_execute ("tr", tr_program, argv, false, true,



reply via email to

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