This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++ configure time
On Mon, Mar 19, 2001 at 02:54:39PM -0800, Zack Weinberg wrote:
> > Well then perhaps we can use ed or something. Or do like
> > perl and build our own echo. *Anything* but here documents.
>
> Department of disgusting hacks:
Yep, that's disgusting. But you ain't seen nothing yet.
I want to continue to use echo as much as possible because it is a
shell builtin most places. But of course we have to watch out for
the escape character cases and transform them into something else.
In most cases we'll be able to just change \ to @ in the echo text
and use tr to revert the change. If both \ and @ appear in the
original text, then a more complicated transformation is required
in order to recover the original.
The following handles all of the cases I could think of. I've come
to the un-stunning conclusion that I absolutely lothe m4, and can't
figure out why anyone would willingly use it.
r~
changequote([,])dnl
dnl
define(ACQS, [patsubst([$1], ['], [\&\\\&\&])])dnl
dnl
define(ACQD, [patsubst([$1],changequote(,)["\]changequote([,]), [\\\&])])dnl
dnl
dnl _AC_GEN_FILE(target-file, text, quote, quote-fn)
dnl
define(_AC_GEN_FILE,
[ifelse(index([$2],[\]), -1, [_AC_GEN_FILE_0i([$1],[$2],[$3],[$4])],
index([$2],[@]), -1, [_AC_GEN_FILE_1i([$1],[$2],[$3],[$4])],
[_AC_GEN_FILE_2i([$1],[$2],[$3],[$4])])])dnl
dnl
define(_AC_GEN_FILE_0i, [_AC_GEN_FILE_0o([$1],[$3][indir([$4],[$2])][$3])])dnl
define(_AC_GEN_FILE_0o, [echo $1 $2])dnl
define(_AC_GEN_FILE_1i, [_AC_GEN_FILE_1o([$1],[$3][translit([indir([$4],[$2])],[\],[@])][$3])])dnl
define(_AC_GEN_FILE_1o, [echo $2 | tr @ \\\\ $1])dnl
dnl Map: @ @0
dnl \ @1
define(_at,@)dnl
define(_AC_GEN_FILE_2i, [_AC_GEN_FILE_2o([$1],[$3][patsubst([patsubst([indir([$4],[$2])],[\\],_at[]1)],[@],[@0])][$3])])dnl
define(_AC_GEN_FILE_2o, [echo $2 | sed -e 's/@1/\\/g' -e 's/@0/@/g' $1])dnl
dnl
define(AC_CREATE_FILE, [_AC_GEN_FILE([>$1], [$2], ["], [ACQD])])dnl
define(AC_CREATE_FILE_Q, [_AC_GEN_FILE([>$1], [$2], ['], [ACQS])])dnl
define(AC_APPEND_FILE, [_AC_GEN_FILE([>>$1], [$2], ["], [ACQD])])dnl
define(AC_APPEND_FILE_Q, [_AC_GEN_FILE([>>$1], [$2], ['], [ACQS])])dnl
dnl
dnl
define(AC_DEFINE,
[AC_APPEND_FILE_Q(confdefs.h,[ifelse(eval([$# >= 2]), 1, [#define $1 $2], [#define $1 1])])])dnl
dnl
traceon[]dnl
AC_DEFINE(CASE_A, hi)
AC_DEFINE(CASE_B, "\n")
AC_DEFINE(CASE_C, "@home\n")
AC_DEFINE(CASE_D, '\'')