]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Solaris' /usr/ucb/expr, and SunOS' /usr/bin/expr fail with the `:'
authorAkim Demaille <akim@epita.fr>
Fri, 4 Aug 2000 09:13:16 +0000 (09:13 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 4 Aug 2000 09:13:16 +0000 (09:13 +0000)
operator when \(\) is used, and matches a string longer than 120
characters.
Reported by Geoff Keating.

* doc/autoconf.texi (Limitations of Usual Tools): Some words about
this.
* acgeneral.m4 (_AC_SHELL_DIRNAME): Fall back to echo|sed if expr
fails.
From Paul Eggert.

ChangeLog
acgeneral.m4
doc/autoconf.texi
lib/autoconf/general.m4

index 34037a9ea797691cea6ba99303443e0cb4bc398b..e0910f9606c2eb6672c4c2f6015925a3ce776133 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2000-08-04  Akim Demaille  <akim@epita.fr>
+
+       Solaris' /usr/ucb/expr, and SunOS' /usr/bin/expr fail with the `:'
+       operator when \(\) is used, and matches a string longer than 120
+       characters.
+       Reported by Geoff Keating.
+
+       * doc/autoconf.texi (Limitations of Usual Tools): Some words about
+       this.
+       * acgeneral.m4 (_AC_SHELL_DIRNAME): Fall back to echo|sed if expr
+       fails.
+       From Paul Eggert.
+
 2000-08-04  Akim Demaille  <akim@epita.fr>
 
        * acgeneral.m4: (AC_RUN_IFELSE, AC_LINK_IFELSE, AC_COMPILE_IFELSE):
index 80d1c466f11b6832e52d374fa8f6befc43316e52..8f77e1bd0fa28f0f2a787e5c0313ce604bffb9a5 100644 (file)
@@ -796,26 +796,39 @@ done; }
 # Paul Eggert answers:
 # Question: Under UN*X, should `//1' give `/'?
 #
-# No, under some older flavors of Unix, leading // is a special path
-# name: it refers to a "super-root" and is used to access other
-# machines' files.  Leading ///, ////, etc. are equivalent to /; but
-# leading // is special.  I think this tradition started with Apollo
-# Domain/OS, an OS that is still in use on some older hosts.
-#
-# POSIX.2 allows but does not require the special treatment for //.
-# It says that the behavior of dirname on path names of the form
-# //([^/]+/*)? is implementation defined.  In these cases, GNU dirname
-# returns /, but it's more portable to return // as this works even on
-# those older flavors of Unix.
-#
-# I have heard rumors that this special treatment of // may be dropped
-# in future versions of POSIX, but for now it's still the standard.
+#   No, under some older flavors of Unix, leading // is a special path
+#   name: it refers to a "super-root" and is used to access other
+#   machines' files.  Leading ///, ////, etc. are equivalent to /; but
+#   leading // is special.  I think this tradition started with Apollo
+#   Domain/OS, an OS that is still in use on some older hosts.
+#
+#   POSIX.2 allows but does not require the special treatment for //.
+#   It says that the behavior of dirname on path names of the form
+#   //([^/]+/*)? is implementation defined.  In these cases, GNU dirname
+#   returns /, but it's more portable to return // as this works even on
+#   those older flavors of Unix.
+#
+#   I have heard rumors that this special treatment of // may be dropped
+#   in future versions of POSIX, but for now it's still the standard.
+#
+# Prefer expr to echo|sed, since expr is usually faster and it handles
+# backslashes and newlines correctly.  However, older expr
+# implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
+# a silly length limit that causes expr to fail if the matched
+# substring is longer than 120 bytes.  So fall back on echo|sed if
+# expr fails.
 define([_AC_SHELL_DIRNAME],
 [expr X$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
       X$1 : 'X\(//\)[[^/]]' \| \
       X$1 : 'X\(//\)$' \| \
       X$1 : 'X\(/\)' \| \
-      .   : '\(.\)'])
+      .   : '\(.\)' 2>/dev/null ||
+echo "X$1" | sed '
+           /^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/p; q; }
+           /^X\(\/\/\)[^/].*/{ s//\1/p; q; }
+           /^X\(\/\/\)$/{ s//\1/p; q; }
+           /^X\(\/\).*/{ s//\1/p; q; }
+           s/.*/./p; q'])
 
 
 ## --------------------------------------------------- ##
index b80e1a1c242c2453b710f55171aaf099990991b7..93f264ca7527c834833942e4c7a5a8ce203d615a 100644 (file)
@@ -5396,8 +5396,6 @@ the specification has been changed to match traditional Unix's behavior
 
 Avoid this portability problem by avoiding the empty string.
 
-
-
 Don't use @code{length}, @code{substr}, @code{match} and @code{index}.
 
 @item @command{expr} (@samp{:})
@@ -5405,6 +5403,11 @@ Don't use @code{length}, @code{substr}, @code{match} and @code{index}.
 Don't use @samp{\?}, @samp{\+} and @samp{\|} in patterns, they are
 not supported on Solaris.
 
+Older @commant{expr} implementations (e.g. SunOS 4 @comamnd{expr} and
+Solaris 8 @command{/usr/ucb/expr}) have a silly length limit that causes
+@commant{expr} to fail if the matched substring is longer than 120
+bytes.  In this case, you might want to fall back on @samp{echo|sed} if
+@command{expr} fails.
 
 
 @item @command{grep}
index 80d1c466f11b6832e52d374fa8f6befc43316e52..8f77e1bd0fa28f0f2a787e5c0313ce604bffb9a5 100644 (file)
@@ -796,26 +796,39 @@ done; }
 # Paul Eggert answers:
 # Question: Under UN*X, should `//1' give `/'?
 #
-# No, under some older flavors of Unix, leading // is a special path
-# name: it refers to a "super-root" and is used to access other
-# machines' files.  Leading ///, ////, etc. are equivalent to /; but
-# leading // is special.  I think this tradition started with Apollo
-# Domain/OS, an OS that is still in use on some older hosts.
-#
-# POSIX.2 allows but does not require the special treatment for //.
-# It says that the behavior of dirname on path names of the form
-# //([^/]+/*)? is implementation defined.  In these cases, GNU dirname
-# returns /, but it's more portable to return // as this works even on
-# those older flavors of Unix.
-#
-# I have heard rumors that this special treatment of // may be dropped
-# in future versions of POSIX, but for now it's still the standard.
+#   No, under some older flavors of Unix, leading // is a special path
+#   name: it refers to a "super-root" and is used to access other
+#   machines' files.  Leading ///, ////, etc. are equivalent to /; but
+#   leading // is special.  I think this tradition started with Apollo
+#   Domain/OS, an OS that is still in use on some older hosts.
+#
+#   POSIX.2 allows but does not require the special treatment for //.
+#   It says that the behavior of dirname on path names of the form
+#   //([^/]+/*)? is implementation defined.  In these cases, GNU dirname
+#   returns /, but it's more portable to return // as this works even on
+#   those older flavors of Unix.
+#
+#   I have heard rumors that this special treatment of // may be dropped
+#   in future versions of POSIX, but for now it's still the standard.
+#
+# Prefer expr to echo|sed, since expr is usually faster and it handles
+# backslashes and newlines correctly.  However, older expr
+# implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
+# a silly length limit that causes expr to fail if the matched
+# substring is longer than 120 bytes.  So fall back on echo|sed if
+# expr fails.
 define([_AC_SHELL_DIRNAME],
 [expr X$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
       X$1 : 'X\(//\)[[^/]]' \| \
       X$1 : 'X\(//\)$' \| \
       X$1 : 'X\(/\)' \| \
-      .   : '\(.\)'])
+      .   : '\(.\)' 2>/dev/null ||
+echo "X$1" | sed '
+           /^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/p; q; }
+           /^X\(\/\/\)[^/].*/{ s//\1/p; q; }
+           /^X\(\/\/\)$/{ s//\1/p; q; }
+           /^X\(\/\).*/{ s//\1/p; q; }
+           s/.*/./p; q'])
 
 
 ## --------------------------------------------------- ##