[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: Eric Blake
Subject: Re: string manipulation : removing a part of a string
Date: Fri, 15 Jun 2012 17:13:23 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

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

> with the code below (i've taken into account your remarks)
> i'm not sure that the m4_foreach below is properly quoted

> [
> 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

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

> CFLAGS_save="${CFLAGS}"

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.

> CFLAGS="${CFLAGS} ${option}"

Here, the "" are necessary, but again the ${} is extra typing.

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

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

> 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.

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

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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