Hi Lars,

| I've written a macro which makes it easier to write more flexible
| autoconf-macros, and I thought some of you might find it interesting.

It's interesting work which might be useful someday in Autoconf, but
for now, I don't think we want to introduce ``complications''.  In
fact, we're trying to simplify the use of Autoconf, even if it means
doing too much work.

| Any comments?

Yes, I have a few comments on your code which you might want to know.

| define([$IM_STRING_COMPACT],[dnl
| patsubst(patsubst([$1],[[
|          ]+],[ ]),[^ \| $],[])])

This is wrong, you have two evaluation here (two patsubst), hence we
need to quote twice.  Your macro will certainly die if there are
commas in $1, and will behaves incorrectly if $a happens to contains
something which is a macro name.

Also, it is (IMHO), a bad habit to use [dnl as you do.  Some day, you
will be trapped.

define([$IM_STRING_COMPACT],
[patsubst(patsubst([[$1]],[[
         ]+],[ ]),[^ \| $],[])])


| define([$IM_STRING_WORDCOUNT_COMPACT],[dnl
| builtin([eval],(1+len(patsubst([$1],[[^ ]+],[_])))/2)])

[[$1]]


| define([$IM_DEFINE_VARIABLE],[dnl
| dnl errprint([define( $1, $2 )

$ M4='m4 --trace $IM_DEFINE_VARIABLE -d' autoconf

is a better means to trace SIM_PARSE_MODIFIER_LIST

| dnl ])dnl
| define([$1],[$2])
| ])


|        [errprint([SIM_PARSE_MODIFIER_LIST: invalid variable (arg 3): "$2"

You should give more details, such as __file__ and __line__.  Or use
libm4's m4_warn.

| define([$IM_PUSHDEF_MODIFIERS],[dnl
| ifelse(indir([$IM_STRING_WORDCOUNT_COMPACT],[$1]),

Why do you `indir' all the time?  Oh!, yes, it's a dollar, not an `S'
:)  Well, for legibility, it might be better that you reserve your
name space and use it:

_SIM_STRING_WORDCOUNT_COMPACT

or something.


| define([$IM_PARSE_MODIFIER_LIST],[dnl
| pushdef([wordcount],builtin([eval],(indir([$IM_STRING_WORDCOUNT],[$2]))))dnl

m4_eval is defined in CVS Autoconf, it's much easier to read.


|        [ifelse($4, , , $4)],

Second $4 should be quoted.

Akim

Reply via email to