From: Akim Demaille Date: Mon, 10 Jul 2000 08:53:58 +0000 (+0000) Subject: * acgeneral.m4 (AC_DIRNAME): Use an `expr' solution instead of X-Git-Tag: autoconf-2.50~762 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=282265f13f0e1b39deded1beff24da880ef04007;p=thirdparty%2Fautoconf.git * 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). --- diff --git a/ChangeLog b/ChangeLog index 1318c2022..16a51bf01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-07-10 Akim Demaille + + * 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 * aclang.m4: Promote s,,, over s%%%, and `sed prog' over `sed -e diff --git a/acgeneral.m4 b/acgeneral.m4 index e6ca0d531..ee192b7a0 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -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\(/\)' \| \ + . : '\(.\)']) ## --------------------------------------------------- ## diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 61e5c555b..764f948d9 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -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 diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index e6ca0d531..ee192b7a0 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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\(/\)' \| \ + . : '\(.\)']) ## --------------------------------------------------- ## diff --git a/man/autoconf.1 b/man/autoconf.1 index 70b64c267..0a1fe2b2f 100644 --- a/man/autoconf.1 +++ b/man/autoconf.1 @@ -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 diff --git a/man/autoheader.1 b/man/autoheader.1 index 8a00779ba..1c89dcec5 100644 --- a/man/autoheader.1 +++ b/man/autoheader.1 @@ -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 diff --git a/man/autoupdate.1 b/man/autoupdate.1 index 73a78ea22..f03d72264 100644 --- a/man/autoupdate.1 +++ b/man/autoupdate.1 @@ -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