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: Fri, 15 Jun 2012 15:18:29 +0200 (CEST)



On Fri, 15 Jun 2012, Eric Blake wrote:

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,

it's in an m4 macro

Show more context of what you are trying to do.

dnl Macro that checks for a compiler flag availability
dnl
dnl EFL_CHECK_COMPILER_FLAG(EFL, FLAG[, ACTION-IF-FOUND[ ,ACTION-IF-NOT-FOUND]])
dnl AC_SUBST : EFL_CFLAGS (EFL being replaced by its value)
dnl AM_CONDITIONAL : EFL_HAVE_FLAG (FLAG being replaced by its value)

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

tmp=$2
m4_if(m4_index([$tmp], [-Wno-]), 0, [m4_define([flagm4], [m4_bpatsubst([[$tmp]], [no-])])], [m4_define([flagm4], [$tmp])])

flag=flagm4
AC_MSG_NOTICE([flagval :: $flag])

etc...
])



reply via email to

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