📄 m4.html
字号:
to and including the nextnewlinecharacter.<dt><b>dumpdef</b><dd>The<b>dumpdef</b>macro writes the defined text to standard error for each of the macrosspecified as arguments, or, if no arguments are specified, for allmacros.<dt><b>errprint</b><dd>The<b>errprint</b>macro writes its arguments to standard error.<dt><b>eval</b><dd>The<b>eval</b>macro evaluates its first argument as anarithmetic expression, using 32-bit signed integerarithmetic.All of the C-language operators are supported, except for[],->,++,--,(type)unary *,<b>sizeof</b>,",", ".", "?:" and all assignment operators.It is an error to specify any of these operators.Precedence and associativity are as in C.Systems support octal andhexadecimal numbers as in C.The second argument, if specified, sets the radix for the result;the default is 10.The third argument, ifspecified, sets the minimum number of digits in the result.It is an error to specify an argumentcontaining any non-numeric characters.<dt><b>ifdef</b><dd>If the first argument to the<b>ifdef</b>macro is defined,the defining text is the second argument.Otherwise, the defining text is the third argument,if specified, or the null string, if not.<dt><b>ifelse</b><dd>If the first argument (or the defining text of the firstargument if it is a macro name) to the<b>ifelse</b>macro is thesame as the second argument (or the defining text of thesecond argument if it is a macro name), then the definingtext is the third argument.If there are more than fourarguments, the initial comparison of the first and secondarguments are repeated for each group of three arguments.If no match is found, the defining text will be the argumentfollowing the last set of three compared, otherwise it will be null.<dt><b>include</b><dd>The defining text for the<b>include</b>macro is the contentsof the file named by the first argument.It is an error if the file cannot be read.<dt><b>incr</b><dd>The defining text of the<b>incr</b>macro is its firstargument incremented by 1.It is an error to specifyan argument containing any non-numeric characters.<dt><b>index</b><dd>The defining text of the<b>index</b>macro is the first characterposition (as a string) in the first argument where a stringmatching the second argument begins (zero origin), or -1 ifthe second argument does not occur.<dt><b>len</b><dd>The defining text of the<b>len</b>macro is the length (as a string)of the first argument.<dt><b>m4exit</b><dd>Exit from the<i>m4</i>utility.If the first argument isspecified, it will be the exit code.The default is zero.It is an error to specify an argumentcontaining any non-numeric characters.<dt><b>m4wrap</b><dd>The first argument will be processed when EOF is reached.If the<b>m4wrap</b>macro is used multiple times, the argumentsspecified will be processed in the order in which the<b>m4wrap</b>macros were processed.<dt><b>maketemp</b><dd>The defining text is the first argument, with any trailingcapital X characters replaced with the current process ID as a string.<dt><b>popdef</b><dd>The<b>popdef</b>macro deletes the current definition of itsarguments, replacing it with the previous one.If there is no previous definition, the macro is undefined.<dt><b>pushdef</b><dd>The<b>pushdef</b>macro is identical to the<b>define</b>macro withthe exception that it preserves any current definitionfor future retrieval using the<b>popdef</b>macro.<dt><b>shift</b><dd>The defining text for the<b>shift</b>macro is all of its argumentsexcept for the first one.<dt><b>sinclude</b><dd>The<b>sinclude</b>macro is identical to the<b>include</b>macro, exceptthat it is not an error if the file is inaccessible.<dt><b>substr</b><dd>The defining text for the<b>substr</b>macro is the substringof the first argument beginning at the zero-offsetcharacter position specified by the second argument.The third argument, if specified, is the number of charactersto select;if not specified, the characters from thestarting point to the end of the first argument becomethe defining text.It is not an error to specifya starting point beyond the end of the first argument andthe defining text will be null.It is an error tospecify an argument containing any non-numeric characters.<dt><b>syscmd</b><dd>The<b>syscmd</b>macro interprets its first argument as a shell command line.The defining text is the string result of that command.No output redirection is performed by the<i>m4</i>utility.The exit status value from the commandcan be retrieved using the<b>sysval</b>macro.<dt><b>sysval</b><dd>The defining text of the<b>sysval</b>macro is the exit valueof the utility last invoked by the<b>syscmd</b>macro (as a string).<dt><b>traceon</b><dd>The<b>traceon</b>macro enables tracing for the macros specified asarguments, or, if no arguments are specified, for all macros.The trace output is written to standard errorin an unspecified format.<dt><b>traceoff</b><dd>The<b>traceoff</b>macro disables tracing for the macros specified asarguments, or, if no arguments are specified, for all macros.<dt><b>translit</b><dd>The defining text of the<b>translit</b>macro is the firstargument with every character that occurs in the secondargument replaced with the corresponding character fromthe third argument.<dt><b>undefine</b><dd>The<b>undefine</b>macro deletes all definitions (including thosepreserved using the<b>pushdef</b>macro) of the macros namedby its arguments.<dt><b>undivert</b><dd>The<b>undivert</b>macro causes immediate output of any textin temporary buffers named as arguments, or all temporarybuffers if no arguments are specified.Buffers can beundiverted into other temporary buffers.Undivertingdiscards the contents of the temporary buffer.It is an error to specify an argument containing any non-numeric characters.</dl></blockquote><h4><a name = "tag_001_014_1321"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>Successful completion.<dt>>0<dd>An error occurred</dl><p>If them4exitmacro is used, the exit value can be specified by theinput file.</blockquote><h4><a name = "tag_001_014_1322"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1323"> </a>APPLICATION USAGE</h4><blockquote>The<b>defn</b>macro is useful for renaming macros, especially built-ins.</blockquote><h4><a name = "tag_001_014_1324"> </a>EXAMPLES</h4><blockquote>An example of a single<i>m4</i>input file capable of generating two output files follows.The file<b>file1.m4</b>could contain lines such as:<pre><code>if(VER, 1, <i>do_something</i>)if(VER, 2, <i>do_something</i>)</code></pre><p>The makefile for the program might include:<pre><code>file1.1.c : file1.m4 m4 -D VER=1 file1.m4 > file1.1.c ...file1.2.c : file1.m4 m4 -D VER=2 file1.m4 > file1.2.c ...</code></pre><br><p>The<b>-U</b>option can be used to undefine<b>VER</b>.If<b>file1.m4</b>contains:<pre><code>if(VER, 1, <i>do_something</i>)if(VER, 2, <i>do_something</i>)ifndef(VER, <i>do_something</i>)</code></pre><br>then the makefile would contain:<pre><code>file1.0.c : file1.m4 m4 -U VER file1.m4 > file1.0.c ...file1.1.c : file1.m4 m4 -D VER=1 file1.m4 > file1.1.c ...file1.2.c : file1.m4 m4 -D VER=2 file1.m4 > file1.2.c ...</code></pre></blockquote><h4><a name = "tag_001_014_1325"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1326"> </a>SEE ALSO</h4><blockquote><i><a href="c89.html">c89</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -