case change in m4_foreach()

2013-02-20 Thread Robert Boehne
I'm writing a macro that takes a list of comma-separated arguments and 
then uses m4_foreach

to loop over each argument in the list:

m4_foreach([var_name], [$1]
[
 dnl Body
])

In the body I want to do some string manipulation on
the variables value, making it uppercase and replacing - and . with 
underscores.


The problem is that for any macro that translates text, the argument
is interpreted literally - i.e.

  m4_toupper(var_name)
gives
 VAR_NAME

instead of transforming the value, it transforms the name.

i.e.:
#m4_normalize(tl_cxx_DEP)
ds-11.0
#translit(''tl_cxx_DEP'', a-z, A-Z)
''TL_CXX_DEP''
#m4_toupper(tl_cxx_DEP)
TL_CXX_DEP

How can I get the contents of the variable transformed?

Thanks,

Robert Boehne

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


Re: case change in m4_foreach()

2013-02-20 Thread Eric Blake
On 02/20/2013 10:55 AM, Robert Boehne wrote:
 I'm writing a macro that takes a list of comma-separated arguments and
 then uses m4_foreach
 to loop over each argument in the list:
 
 m4_foreach([var_name], [$1]
 [
  dnl Body
 ])
 
 In the body I want to do some string manipulation on
 the variables value, making it uppercase and replacing - and . with
 underscores.
 
 The problem is that for any macro that translates text, the argument
 is interpreted literally - i.e.
 
  m4_toupper(var_name)
 gives
 VAR_NAME
 
 instead of transforming the value, it transforms the name.

 
 How can I get the contents of the variable transformed?

Use m4_defn.

m4_foreach([var_name], [$1],
[
  m4_toupper(m4_defn([var_name]))
])

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



signature.asc
Description: OpenPGP digital signature
___
Autoconf mailing list
Autoconf@gnu.org
https://lists.gnu.org/mailman/listinfo/autoconf