Question about m4 include/sinclude
| Newsgroups | gmane.comp.gnu.m4.general |
|---|---|
| Message-ID | <20080930154926.5e4a7f4977ecf005087928ae8b390888.7b4a2dd484.wbe@email.secureserver.net> |
Without using ifdef or something similar, is there a way to prevent m4 from entering an infinite recursion with a file like: % cat foo include(`foo') I realize I can probably do something like define a macro in the file, and then not include the file if the macro is defined... HOWEVER, in my particular application, I cannot control all of the m4 files... so my fear is that someone will do something like the above or even: % setenv M4PATH "dir1:dir2" % cat dir1/foo include(`bar') % cat dir2/bar include(`foo') And my m4 go off into an infinite loop. I can control command line options, but when I tried --nesting-limit=1, that didn't seem to help. About all I could think of is to have my Perl script I'm calling m4 from pre-process the files looking for include or sinclude lines, taking into account the M4PATH environment files, and making sure I don't repeat files (using something like stat() and the inode and device to make sure I handle symlinks). But this feels REALLY ugly, and if I'm going to do that, the argument from the user base is going to be "why did you use m4... why not have your own include mechanism" (yeah, I know). Seems like it would be something that m4 itself should catch and (maybe optionally) puke when it finds the same file the second time around.... Anyway, is there ANYTHING I can do to prevent multiple includes? Thanks! -Roger _______________________________________________ m4-discuss mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-discuss