[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: m4sugar and m4 1.6, bison
From: |
Ralf Wildenhues |
Subject: |
Re: m4sugar and m4 1.6, bison |
Date: |
Sat, 12 Jul 2008 08:39:45 +0200 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
* Ralf Wildenhues wrote on Sat, Jul 12, 2008 at 08:11:55AM CEST:
> So then here's a first prototype for fast m4_append_uniq, completely
> untested, and would probably need some more-unique separator after $1 in
> the definition of m4_key.
I'll blame it on lack of coffee...
> # m4_make_macro_name(STRING)
> # Turn all characters not fitting to be a macro name into '_'.
> m4_define([m4_make_macro_name],
> [m4_bpatsubst([$1], [...])dnl
> ])
>
> # m4_append_uniq(MACRO-NAME, STRING, [SEPARATOR], [IF-UNIQ], [IF-DUP])
> m4_define([m4_append_uniq],
> [m4_pushdef([m4_key], [_$1_[]make_macro_name([$2])])dnl
> m4_ifdef(m4_key,
> [m4_if([m4_defn(m4_key)], [$2],
This is completely ignoring hash key collision. So, assuming that
collisions are rare, i.e., usually strings differ not only in characters
not allowed in a macro name, then the duplicate test here can just reuse
the one from the version of m4_append_uniq currently in Autoconf. That
will probably still give amortized fast check here. Actually, I guess
the uniq part is even O(n), only the reallocs necessary now and then
will be loglinear.
> [$5],
> [_$1($@)])],
> [_$1($@)])dnl
> m4_popdef([m4_key])dnl
> ])
>
> m4_define([_m4_append_uniq],
> [m4_define(m4_key, m4_defn(m4_key))dnl
Then this line can simply be:
[m4_define(m4_key)dnl
> do the appending work, expand $4...
> ])
Still completely untested, of course...
Cheers,
Ralf
- m4sugar and m4 1.6, bison, Eric Blake, 2008/07/11
- Re: m4sugar and m4 1.6, bison, Ralf Wildenhues, 2008/07/11
- Re: m4sugar and m4 1.6, bison, Eric Blake, 2008/07/11
- Re: m4sugar and m4 1.6, bison, Ralf Wildenhues, 2008/07/12
- Re: m4sugar and m4 1.6, bison,
Ralf Wildenhues <=
- Re: m4sugar and m4 1.6, bison, Eric Blake, 2008/07/13
- Re: m4sugar and m4 1.6, bison, Ralf Wildenhues, 2008/07/14
- Re: m4sugar and m4 1.6, bison, Eric Blake, 2008/07/14
- Re: m4sugar and m4 1.6, bison, Paolo Bonzini, 2008/07/31
Re: m4sugar and m4 1.6, bison, Eric Blake, 2008/07/15
Re: m4sugar and m4 1.6, bison, Eric Blake, 2008/07/21