[Top][All Lists]

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

Re: [PATCH] Use expr where possible

From: Paul Eggert
Subject: Re: [PATCH] Use expr where possible
Date: Thu, 16 Jun 2005 01:10:57 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

"Peter O'Gorman" <address@hidden> writes:

> To reply to myself, Bill Fenner just mentioned on irc that this will
> give a bad result for "i686-pc-linux-gnu" he instead suggests using
> [.-.] as in:

That won't work on older hosts; it will match ".".

I've worked around this by avoiding expr entirely here (as well as
echo | sed).  Here's what I installed into Autoconf CVS:

2005-06-16  Paul Eggert  <address@hidden>

        * doc/autoconf.texi (Limitations of Usual Tools): Mention expr bug
        on Mac OS X 10.4 reported by Peter O'Gorman in:
        * lib/autoconf/general.m4 (_AC_CANONICAL_SPLIT):
        Use shell builtins rather than 'expr', to work around expr bug.

Index: doc/autoconf.texi
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.913
diff -p -u -r1.913 autoconf.texi
--- doc/autoconf.texi   11 Jun 2005 07:01:37 -0000      1.913
+++ doc/autoconf.texi   16 Jun 2005 07:22:45 -0000
@@ -11830,6 +11830,13 @@ Solaris 8 @command{/usr/ucb/expr}) have 
 bytes.  In this case, you might want to fall back on @samp{echo|sed} if
 @command{expr} fails.
+On Mac OS X 10.4, @command{expr} mishandles the pattern @samp{[^-]} in
+some cases.  For example, the command @samp{expr
+Xpowerpc-apple-darwin8.1.0 : 'X[^-]*-[^-]*-\(.*\)'} outputs
address@hidden rather than the correct @samp{darwin8.1.0}.
+This particular case can be worked around by substituting @samp{[^--]}
+for @samp{[^-]}.
 Don't leave, there is some more!
 The @acronym{QNX} 4.25 @command{expr}, in addition of preferring @samp{0} to
Index: lib/autoconf/general.m4
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.864
diff -p -u -r1.864 general.m4
--- lib/autoconf/general.m4     11 Jun 2005 06:05:12 -0000      1.864
+++ lib/autoconf/general.m4     16 Jun 2005 07:22:44 -0000
@@ -1671,9 +1671,26 @@ m4_define([AC_REQUIRE_AUX_FILE],
 [AC_SUBST([$1],       [$ac_cv_$1])dnl
 dnl FIXME: AC_SUBST([$1_alias],  [$ac_cv_$1_alias])dnl
-AC_SUBST([$1_cpu],     [`expr "X$ac_cv_$1" : ['X\([^-]*\)']`])dnl
-AC_SUBST([$1_vendor],  [`expr "X$ac_cv_$1" : ['X[^-]*-\([^-]*\)']`])dnl
-AC_SUBST([$1_os],      [`expr "X$ac_cv_$1" : ['X[^-]*-[^-]*-\(.*\)']`])dnl
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_$1
+case $[#] in
+0|1|2) ;;
+  shift; shift; shift
+  for ac_arg
+  do $1_os=$1_os-$ac_arg
+  done;;

reply via email to

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