]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* acgeneral.m4 (AC_DIRNAME): Use an `expr' solution instead of
authorAkim Demaille <akim@epita.fr>
Mon, 10 Jul 2000 08:53:58 +0000 (08:53 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 10 Jul 2000 08:53:58 +0000 (08:53 +0000)
echo|sed.
From Paul Eggert.
* doc/autoconf.texi (Limitations of Usual Tools): Include the
words from Paul about `|' with expr(1).

ChangeLog
acgeneral.m4
doc/autoconf.texi
lib/autoconf/general.m4
man/autoconf.1
man/autoheader.1
man/autoupdate.1

index 1318c20227b0b52be26b77ca9b7b7f7075e72820..16a51bf018fcbebf4092f3048048e88634be6380 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2000-07-10  Akim Demaille  <akim@epita.fr>
+
+       * acgeneral.m4 (AC_DIRNAME): Use an `expr' solution instead of
+       echo|sed.
+       From Paul Eggert.
+       * doc/autoconf.texi (Limitations of Usual Tools): Include the
+       words from Paul about `|' with expr(1).
+
 2000-07-10  Akim Demaille  <akim@epita.fr>
 
        * aclang.m4: Promote s,,, over s%%%, and `sed prog' over `sed -e
index e6ca0d5318a9a8fb6266b6939c60e71d2057c16c..ee192b7a05a4753864978f9e22f4e6c0bf1e96b2 100644 (file)
@@ -779,9 +779,30 @@ done; }
 # ---------------------------
 # Simulate running `dirname(1)' on PATHNAME, not all systems have it.
 # This macro must be usable from inside ` `.
+#
+# 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.
 define([_AC_SHELL_DIRNAME],
-[echo $1 | sed '/^\/*$/!s,//*$,,;s,[[^/]]*$,,;s,//*$,/,;/^\/$/!s,/$,,;s,^$,.,'])
-
+[expr "X$dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+      "X$dir" : 'X\(//\)[^/]' \| \
+      "X$dir" : 'X\(//\)$' \| \
+      "X$dir" : 'X\(/\)' \| \
+      .       : '\(.\)'])
 
 
 ## --------------------------------------------------- ##
index 61e5c555b8c88441700dd1dff54ea2b083dd2365..764f948d9aea43f6a3fa6539342444a3ce5bfe7e 100644 (file)
@@ -5065,17 +5065,39 @@ foo
 
 @command{egrep} also suffers the limitations of @command{grep}.
 
+
 @item @command{expr}
 @cindex @command{expr}
-Don't use @samp{\?}, @samp{\+} and @samp{\|} in patterns, they are
-not supported on Solaris.
-
 No @command{expr} keyword starts with @samp{x}, so use @samp{expr
 x"@var{word}" : '@var{regex}'} to keep @command{expr} from
 misinterpreting @var{word}.
 
+You can use @samp{|}.  There is one portability problem occuring when
+you @samp{|} together the empty string (or zero) with the empty string.
+For example:
+
+@example
+expr '' \| ''
+@end example
+
+@sc{gnu}/Linux and @sc{posix.2} return the empty string for this case,
+but traditional Unix returns @samp{0}.  In the latest @sc{posix} draft,
+the specification has been changed to match traditional Unix's behavior
+(which is bizarre, but it's too late to fix this).
+
+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{:})
+@cindex @command{expr}
+Don't use @samp{\?}, @samp{\+} and @samp{\|} in patterns, they are
+not supported on Solaris.
+
+
+
 @item @command{grep}
 @cindex @command{grep}
 Don't use @samp{grep -s} to suppress output, because @samp{grep -s} on
index e6ca0d5318a9a8fb6266b6939c60e71d2057c16c..ee192b7a05a4753864978f9e22f4e6c0bf1e96b2 100644 (file)
@@ -779,9 +779,30 @@ done; }
 # ---------------------------
 # Simulate running `dirname(1)' on PATHNAME, not all systems have it.
 # This macro must be usable from inside ` `.
+#
+# 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.
 define([_AC_SHELL_DIRNAME],
-[echo $1 | sed '/^\/*$/!s,//*$,,;s,[[^/]]*$,,;s,//*$,/,;/^\/$/!s,/$,,;s,^$,.,'])
-
+[expr "X$dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+      "X$dir" : 'X\(//\)[^/]' \| \
+      "X$dir" : 'X\(//\)$' \| \
+      "X$dir" : 'X\(/\)' \| \
+      .       : '\(.\)'])
 
 
 ## --------------------------------------------------- ##
index 70b64c267458785db65ba1e3ab9cd4d94bfa0fd9..0a1fe2b2f6aa790875c9045632e39f3025af6452 100644 (file)
@@ -1,5 +1,5 @@
-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.020.
-.TH AUTOCONF "1" "June 2000" "GNU autoconf 2.14a" FSF
+.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.022.
+.TH AUTOCONF "1" "July 2000" "GNU autoconf 2.14a" FSF
 .SH NAME
 autoconf \- Generate configuration scripts
 .SH SYNOPSIS
index 8a00779bae7cc3d1cd684f26cdf48dfa13365233..1c89dcec57d4b113cd9337fbc1ed055bdf6f8c9e 100644 (file)
@@ -1,5 +1,5 @@
-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.020.
-.TH AUTOHEADER "1" "June 2000" "GNU autoconf 2.14a" FSF
+.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.022.
+.TH AUTOHEADER "1" "July 2000" "GNU autoconf 2.14a" FSF
 .SH NAME
 autoheader \- Create a template header for configure
 .SH SYNOPSIS
index 73a78ea22e2d8375ac1470477dac7fc0d002c604..f03d7226425139fecf831a0f5483cc16b570d56c 100644 (file)
@@ -1,5 +1,5 @@
-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.020.
-.TH AUTOUPDATE "1" "June 2000" "GNU autoconf 2.14a" FSF
+.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.022.
+.TH AUTOUPDATE "1" "July 2000" "GNU autoconf 2.14a" FSF
 .SH NAME
 autoupdate \- Update a configure.in to a newer Autoconf
 .SH SYNOPSIS