autoconf
[Top][All Lists]
Advanced

[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

EFL_CHECK_COMPILER_FLAGS([-Wno-foo -Wbar])

Don't you mean:

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

ha, right, I was too enthusiastic :)

AC_DEFUN([EFL_CHECK_COMPILER_FLAG],
[
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.


option=flagm4

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
variable:

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

arg ! it's so simple !!

CFLAGS_save="${CFLAGS}"

Personally, I'd write this as:

CFLAGS_save=$CFLAGS

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

UPEFL[_CFLAGS]="${UPEFL[_CFLAGS]} [$2]"
AC_ARG_VAR(UPEFL[_CFLAGS], [preprocessor flags for $2])
AC_SUBST(UPFEL[_CFLAGS])

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"])

m4_popdef([UP])
m4_popdef([UPEFL])

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:

http://www.gnu.org/software/autoconf/manual/autoconf.html#Conditional-constructs

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
dnl
dnl EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS)

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

Almost.

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]