On 9/30/20 5:03 AM, hhmm wrote: > please see this reference > > https://stackoverflow.com/questions/64066166/how-to-rescan-m4-data-for-recursive-macro-inplace-substitution/64066869?noredirect=1#comment113299085_64066869
Better yet, ask your question directly here, instead of making every reader chase a URL that may have a different lifetime than the mailing list archive. So doing that on your behalf: > I have this very simple code. > > define(`S',`some') > define(`T',`thing') > define(`something',`st_todo') > S`'T In the interim, this expands to: some`'thing and thus the scanner never gets to see "something" as a single macro name. > OR > S()T() Partway through evaluation, this has expanded to: someT() but someT is not a macro name, and thus the scanner never gets to see "something" as a single macro name. > > the actual end result is > > something > OR > something You probably meant "someT()" here, based on your examples above. > > but expected recursive substitution result as > > st_todo > > how I can rescan the code to the input again ? The existing answers on that topic appear to gracefully cover it: any time you want a second macro to be expanded and that expansion concatenated with the output of the first, for evaluating the entire concatenation for further macros, you have to use a glue macro. define(`concat',`$1$2') concat(S,T) evaluates to: concat(`some',`thing') which in turn evaluates to: something which is now a valid macro name, and finally expands to: st_todo If you need a macro that concatenates more than just $1 and $2, you can write it. https://www.gnu.org/software/m4/manual/m4-1.4.15/html_node/Shift.html#index-joining-arguments-130 documents a "join" macro shipped with the m4 documentation that can be used with an empty separator to concatenate an arbitrary number of arguments into a single-quoted string with no intervening `' or (); pass that through one more macro call to perform macro expansion on the entire string. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
