autoconf
[Top][All Lists]
Advanced

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

Re: Bug in AS_ESCAPE, AS_MKDIR_P, or my understanding of M4?


From: Akim Demaille
Subject: Re: Bug in AS_ESCAPE, AS_MKDIR_P, or my understanding of M4?
Date: 31 Jan 2001 16:48:43 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Crater Lake)

>>>>> "Derek" == Derek R Price <address@hidden> writes:

Derek> Yeah, sorry.  I'm trying to use AS_MKDIR_P in an unescaped
Derek> heredoc context.  The reason I don't seem to be able to avoid
Derek> _that_ is that I want it to happen as part of a step before a
Derek> header gets created so I'm passing it into AC_CONFIG_HEADER as
Derek> an INIT-CMD.

There are plenty of reasons for this to be impossible.  There is no
`eval_and_quote' macro in M4, and it's quite hard to implement (what
of the side effects?).  There are only approximations, and it's quite
complex trying to.

A first approximation would be:

AC_PLAIN_SCRIPT
cat <<EOF
AS_ESCAPE(m4_dquote(AS_MKDIR_P(["sdir"])), [\$`])
EOF

but it fails:

| cat <<EOF
| { case \"sdir\" in
|   [\\\\/]* | ?:[\\\\/]*  as_incr_dir=;;
|   *                      as_incr_dir=.;;
| esac
| as_dummy="sdir"
| for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
|   case $as_mkdir_dir in
|     # Skip DOS drivespec
|     ?:) as_incr_dir=$as_mkdir_dir ;;
|     *)
|       as_incr_dir=$as_incr_dir/$as_mkdir_dir
|       test -d "$as_incr_dir" || mkdir "$as_incr_dir"
|     ;;
|   esac
| done; }
| ), \$`)
| EOF

Pay special attention to the last line: it shows that m4 took the
closing parens of the case/esac into the teeth, and ``improperly''
split the arguments of AS_ESCAPE.

I would recomment to... No, wait a second, I would not recommend what
you are doing, M4 is not good at it, but, it you really want to, I'd
recommend something like:

AC_PLAIN_SCRIPT
AS_MKDIR_P(["sdir"])
cat <<EOF
m4_patsubst(AS_ESCAPE(m4_dquote(m4_defn([AS_MKDIR_P]))), [$1], ["sdir"])
EOF



reply via email to

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