[Top][All Lists]

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

Re: string manipulation : removing a part of a string

From: Vincent Torri
Subject: Re: string manipulation : removing a part of a string
Date: Sat, 16 Jun 2012 07:49:29 +0200 (CEST)

On Fri, 15 Jun 2012, Eric Blake wrote:

On 06/15/2012 04:55 PM, Vincent Torri wrote:

thank you for all the tips ! Just for information, I use


Don't you mean:

EFL_CHECK_COMPILER_FLAGS([efl], [-Wno-foo -Wbar])

ha, right, I was too enthusiastic :)

m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))
m4_pushdef([UP], m4_translit([[$2]], [-a-z], [_A-Z]))

m4_if(m4_index([$2], [-Wno-]), [0], [m4_pushdef([flagm4],
[m4_bpatsubst([[$2]], [no-])])], [m4_pushdef([flagm4], [$2])])

This can be shortened:

m4_pushdef([flagm4], m4_bpatsubst([[$2]], [no-]))

since m4_bpatsubst is a no-op if the pattern 'no-' doesn't appear.


And since this is the only use of flagm4, and I have now shortened the
computation, you could inline the computation instead of using a temp m4

option=m4_bpatsubst([[$2]], [no-])

arg ! it's so simple !!


Personally, I'd write this as:


as "" are unnecessary in a single-word assignment, and {} is unnecessary
when there is nothing after the variable name.  I might not be terse in
my comments, but I try to be terse in my code :)  But what you have is
correct, and I won't fault you if that is your personal shell coding style.

yes, it's my personal coding style. I try to be consistent all over the code, even if some quotes and {} are not necessary

AC_ARG_VAR(UPEFL[_CFLAGS], [preprocessor flags for $2])

Hope that typo was unintentional (EFL vs. FEL).

ouch, thank you, it's a typo, indeed.

AM_CONDITIONAL([EFL_HAVE]UP, [test "x${have_flag}" = "xyes"])


missing m4_popdef([flagm4]) if you keep the temp m4 variable.

heh, as option=m4_bpatsubst([[$2]], [no-]) is working, there's no need. It's so simple when you know how it works...

I finally found the doc of that m4 macro, and it's not mentioned that it's a no op in some cases:

is it possible to add that ?

Also, if I'm not mistaken, there's a typo in the macro name :

m4_bpatsubsts (final s)


dnl Macro that iterates over a sequence of white separated flags
dnl and that call EFL_CHECK_COMPILER_FLAG() for each of these flags

m4_foreach_w([flag], [$2], [EFL_CHECK_COMPILER_FLAG($1, m4_defn([flag]))])


m4_foreach_w([flag], [$2],
[EFL_CHECK_COMPILER_FLAG([$1], m4_defn([flag]))])

for $1, i was sure, but why is it not needed for m4_defn([flag]) ?

thank you very much for that review. Now I have a nice detection macro for gcc/clang warning flags :)

Vincent Torri

reply via email to

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