Hi again,
On Tue, Apr 19, 2005 at 09:49:25AM -0700, Paul Eggert wrote:
> > And why is it necessary to try to handle AC_CONFIG_LIBOBJ_DIR(/)?
>
> Paranoia, that's all.
The documentation says that AC_CONFIG_LIBOBJ_DIR specifies
"a name relative to the top level of the source tree"
Thus I believe the paranoia should be directed elsewhere.
Please see the patch attached to this mail. Can I commit it?
> Come to think of it, perhaps I wasn't paranoid enough. Is it possible
> for ac_config_libobj_dir to be empty?
I think your previous code handles this case correctly--expr fails and
empty string is returned.
My previous proposal was wrong, but I think we can use this variation of
your code:
ac_libobj_dir=
test "X$ac_config_libobj_dir" = X. ||
ac_libobj_dir=`expr "X$ac_config_libobj_dir/" : 'X\(.*[^/]\)'`
The most common case is that ac_config_libobj_dir is set to ".", as it
is the default set by Autoconf; it's good that this case is optimized
and doesn't call expr.
_If_ our checks fail, and ac_config_libobj_dir happens to be / (or more
slashes), then expr returns empty string. I see no problem here.
Have a nice day,
Stepan
2005-04-20 Stepan Kasal <[EMAIL PROTECTED]>
* lib/autoconf/general.m4 (AC_CONFIG_LIBOBJ_DIR): Really check whether
the given path looks sane.
* lib/m4sugar/m4sugar.m4 (m4_bmatch): Halt with error if we don't get
enough arguments, similarly as m4_bpatsubsts.
(m4_re_relative_path): New macro; matches well named subdirectory of
the package.
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.851
diff -u -r1.851 general.m4
--- lib/autoconf/general.m4 20 Apr 2005 05:34:25 -0000 1.851
+++ lib/autoconf/general.m4 20 Apr 2005 08:27:18 -0000
@@ -2501,9 +2501,9 @@
# -----------------------------
# Announce LIBOBJ replacement files are in $top_srcdir/DIRNAME.
AC_DEFUN_ONCE([AC_CONFIG_LIBOBJ_DIR],
-[m4_bmatch([$1], [^]m4_defn([m4_cr_symbols2]),
- [AC_WARNING([invalid replacement directory: $1])])dnl
-m4_divert_text([DEFAULTS], [ac_config_libobj_dir=$1])[]dnl
+[m4_bmatch([$1], m4_defn([m4_re_relative_path]),
+ [m4_divert_text([DEFAULTS], [ac_config_libobj_dir=$1])],
+ [AC_WARNING([invalid replacement directory: $1])])[]dnl
])
Index: lib/m4sugar/m4sugar.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sugar.m4,v
retrieving revision 2.84
diff -u -r2.84 m4sugar.m4
--- lib/m4sugar/m4sugar.m4 19 Apr 2005 06:20:38 -0000 2.84
+++ lib/m4sugar/m4sugar.m4 20 Apr 2005 08:27:19 -0000
@@ -374,8 +374,8 @@
# All the values are optional, and the macro is robust to active symbols
# properly quoted.
m4_define([m4_bmatch],
-[m4_if([$#], 0, [],
- [$#], 1, [],
+[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
+ [$#], 1, [m4_fatal([$0: too few arguments: $#: $1])],
[$#], 2, [$2],
[m4_if(m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shiftn(3, $@))],
[$3])])])
@@ -1343,6 +1343,17 @@
)
+# m4_re_relative_path
+# -------------------
+# Regexp for `^[-.a-zA-Z_0-9][-.a-zA-Z_0-9/]*$'
+m4_define([m4_re_relative_path],
+[^]dnl
+m4_dquote([-.]m4_defn([m4_cr_symbols2]))dnl
+m4_dquote([-.]m4_defn([m4_cr_symbols2])/)dnl
+[*$]dnl
+)
+
+
# m4_tolower(STRING)
# m4_toupper(STRING)
# ------------------