[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 07:13:59 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

On 06/15/2012 07:09 AM, Vincent Torri wrote:
> On Thu, 14 Jun 2012, Eric Blake wrote:
>> On 06/14/2012 05:36 PM, Vincent Torri wrote:
>>> Hey
>>> I pass -Wno-foo as a parameter of an m4 macro. What I would like is to
>>> store into a variable -Wfoo, so removing 'no-'
>>> Is it possible with the m4 macro string manipulation ? If not, what's
>>> the best solution ?
>> m4_bpatsubst([[$1]], [no-])
>> will delete the first instance of the regular expression 'no-' (if any)
>> from parameter $1.  Yes, the first argument is double-quoted, so that
>> the output of m4_bpatsubst will still be single-quoted.
>>> Another related question: if I pass -Wbar, I would like to know if it
>>> begins by '-Wno-'. How can I do that with m4 ?
>> m4_if(m4_index([$1], [-Wno-]), 0, [yes...], [no...])
> I try that to set flagm4 to -Wfoo if tmp is -Wno-foo, but it seems that
> i don't use correctly the m4 macros
> m4_if(m4_index([$tmp], [-Wno-]), 0, [m4_define([flagm4],

$tmp is NOT an m4 parameter.

Are you trying to do this at m4 time (ie. while running autoconf) or at
shell time (ie. while running configure)?  Make up your mind, because
that determines what language you will write the comparison in.

> [m4_bpatsubst([[$tmp]], [no-])])], [m4_define([flagm4], [$tmp])])
> do you have an idea ?

Show more context of what you are trying to do.

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]