manpagez: man pages & more
info m4
Home | html | info | man

File: m4.info,  Node: Improved fatal_error,  Prev: Improved capitalize,  Up: Answers

17.8 Solution for ‘fatal_error’
===============================

The ‘fatal_error’ macro (*note M4exit::) is not robust to versions of
GNU M4 earlier than 1.4.8, where invoking ‘__file__’ (*note Location::)
inside ‘m4wrap’ would result in an empty string, and ‘__line__’ resulted
in ‘0’ even though all files start at line 1.  Furthermore, versions
earlier than 1.4.6 did not support the ‘__program__’ macro.  If you want
‘fatal_error’ to work across the entire 1.4.x release series, a better
implementation would be:

     define(`fatal_error',
       `errprint(ifdef(`__program__', `__program__', ``m4'')'dnl
     `:ifelse(__line__, `0', `',
         `__file__:__line__:')` fatal error: $*
     ')m4exit(`1')')
     ⇒
     m4wrap(`divnum(`demo of internal message')
     fatal_error(`inside wrapped text')')
     ⇒
     ^D
     error→m4:stdin:6: Warning: excess arguments to builtin `divnum' ignored
     ⇒0
     error→m4:stdin:6: fatal error: inside wrapped text

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.