autoconf-patches
[Top][All Lists]
Advanced

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

Re: document AS_BASENAME


From: Ralf Wildenhues
Subject: Re: document AS_BASENAME
Date: Fri, 31 Mar 2006 08:54:31 +0200
User-agent: Mutt/1.5.11

* Paul Eggert wrote on Fri, Mar 31, 2006 at 08:12:35AM CEST:
> 
> Thanks, I installed the following, which I hope addresses all the
> issues that you and others raised.

> (For extra trivia credit, explain
> why the '?' is needed in the patch below.  :-)

I'm cheap, I always go for trivia.  Spoiler after the form feed below.
(Even looked at http://www.cs.ucla.edu/classes/winter03/cs131/hw/hw1.html
once, after finding it in a lucky search; decided we should not "fix"
Autoconf, it would make it unduly easy for your students, it's unobvious
and would require more string copying inside m4.  ;-)

> +# This is not portable.
> +c=`basename "$cname" .c`
> +
> +# This is more portable.
> +c=`AS_BASENAME(["$cname"])`
> +case $c in
> +?*.c) c=`expr "X$c" : 'X\(.*\)\.c'`;;
> +esac

FWIW, I wonder whether using expr at all for general names is a good
idea, as the documented bug on Tru64 that turns everything into a number
that looks like one (after other operations):
 $ expr 'X000123.c' : 'X\(.*\)\.c'
 123

will leave all-numeric leading-zero outputs a bit out in the cold.
(This holds for all kinds of expr expressions we recommend in the
manual.)


Because you want
  basename .c .c
to output
  .c

Cheers,
Ralf




reply via email to

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