Re: string manipulation : removing a part of a string

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

 



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

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux