Re: Make m4 only call macros surrounded by brackets.

Zack Piper <[email protected]> Sat, 28 Feb 2015 23:21:07 +0000
Newsgroups gmane.comp.gnu.m4.general
Message-ID <[email protected]>
On Sat, Feb 28, 2015 at 09:37:30PM +0000, Zack Piper wrote:
> Hello,
> 
> I'm currently trying to figure out how to make m4 only call macros within certain brackets, for example:
> 
> ```
> define(`test', '2')
> test
> ->test
> 
> <test>
> ->2
> ```
> 
> It would be even better if this was possible.
> 
> ```
> define(`test', '2')
> <test>
> -><test>
> 
> <#test>
> ->2
> ```
> 
> Above is exactly what the `-H` flag does on GPP (Generic Preprocessor) (http://files.nothingisreal.com/software/gpp/gpp.html).
> 
> Any help would be great, thanks!
> -- 
> I have nothing fancy or intelligent to put here.

Hm, I found out how to do it. Unfortuently it seems to segfault when using "changeword(`#<\([_a-zA-Z0-9]*\)>)')", and then trying to invoke a macro:

(gdb) run gpp.m4
Starting program: /usr/local/bin/m4 gpp.m4
Got object file from memory but can't read symbols: File truncated.





Program received signal SIGSEGV, Segmentation fault.
next_token (td=td@entry=0x7fffffffd0b0, line=line@entry=0x7fffffffd0ac) at input.c:918
918           if (regs.start[1] != -1)


-- 
I have nothing fancy or intelligent to put here.
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJU8k1iAAoJEPu4cabIrwGue8kP/R3bPfVeUZw2WUlVS1h2qOaS
qDV0anQWhwKJLlnjik1oaS+MhVeByv+WpAH7ZJk480f547+vHqLJUeTaqa30dgNx
QtKpZsnDKRXYQfnKYEXNkGaJkQM5jMCHPhg2r6sjqPOSSldPj1fS2AX0zQiLPen4
kwPKDK7eH0w5YcvyVh14IJNQVgXH5f7eBO4L5CbqDP6bL6fQUZXr3IZO5XW5bteo
6kKMIHByifvsJFPItIti7lLX/Yw7LkXGtNGjF2mWv1b4161T8Ll4C9QVcQz4rCqH
jKQy4aYMzeA7DCSEzKukLvyxwU7IUB3VwvP+xC1uTpIVBcvmMtvAorBnSt+927n9
efZdEV2pCCf9oE7A3JeSBCSQTgih/xG41+aVdqKaQ84b9ShJF3VWUWJJGllK+CU+
R1TY/cQRBlEa8FU5QSiUZZWzJN0D++01tHTsT3dzxVKReyWBJw8Tmcb1S3IRMnUu
1RvCOrJEdACFgBQFxFUOy1/5b5ENmJYYMpL3Uw43johwhpDuaGxOlVrozAD85/6b
4cw9H+I7K9pdzqAZjqu/D67oEaHA3izrzgc1l790OfvyDH5Gw6U6K41hRbipmNB8
cw3IRpWtIInmozW9v2uM6NZev1f4WYHhb6aOBSmgO1Lw9n8e7az8Mto/JGpbM5QG
wl53KGc8UrlwdNdk+to3
=L9AC
-----END PGP SIGNATURE-----