📄 m4.html
字号:
equal strings and there are six or more arguments, the first three arguments shall be discarded and processing shall restart withthe remaining arguments.</dd><dt><b>include</b></dt><dd>The defining text for the <b>include</b> macro shall be the contents of the file named by the first argument. It shall be anerror if the file cannot be read.</dd><dt><b>incr</b></dt><dd>The defining text of the <b>incr</b> macro shall be its first argument incremented by 1. It shall be an error to specify anargument containing any non-numeric characters.</dd><dt><b>index</b></dt><dd>The defining text of the <b>index</b> macro shall be the first character position (as a string) in the first argument where astring matching the second argument begins (zero origin), or -1 if the second argument does not occur.</dd><dt><b>len</b></dt><dd>The defining text of the <b>len</b> macro shall be the length (as a string) of the first argument.</dd><dt><b>m4exit</b></dt><dd>Exit from the <i>m4</i> utility. If the first argument is specified, it is the exit code. The default is zero. It shall be anerror to specify an argument containing any non-numeric characters.</dd><dt><b>m4wrap</b></dt><dd>The first argument shall be processed when EOF is reached. If the <b>m4wrap</b> macro is used multiple times, the argumentsspecified shall be processed in the order in which the <b>m4wrap</b> macros were processed.</dd><dt><b>maketemp</b></dt><dd>The defining text shall be the first argument, with any trailing <tt>'X'</tt> characters replaced with the current process IDas a string.</dd><dt><b>popdef</b></dt><dd>The <b>popdef</b> macro shall delete the current definition of its arguments, replacing that definition with the previous one.If there is no previous definition, the macro is undefined.</dd><dt><b>pushdef</b></dt><dd>The <b>pushdef</b> macro shall be equivalent to the <b>define</b> macro with the exception that it shall preserve any currentdefinition for future retrieval using the <b>popdef</b> macro.</dd><dt><b>shift</b></dt><dd>The defining text for the <b>shift</b> macro shall be all of its arguments except for the first one.</dd><dt><b>sinclude</b></dt><dd>The <b>sinclude</b> macro shall be equivalent to the <b>include</b> macro, except that it shall not be an error if the file isinaccessible.</dd><dt><b>substr</b></dt><dd>The defining text for the <b>substr</b> macro shall be the substring of the first argument beginning at the zero-offsetcharacter position specified by the second argument. The third argument, if specified, shall be the number of characters to select;if not specified, the characters from the starting point to the end of the first argument shall become the defining text. It shallnot be an error to specify a starting point beyond the end of the first argument and the defining text shall be null. It shall bean error to specify an argument containing any non-numeric characters.</dd><dt><b>syscmd</b></dt><dd>The <b>syscmd</b> macro shall interpret its first argument as a shell command line. The defining text shall be the stringresult of that command. No output redirection shall be performed by the <i>m4</i> utility. The exit status value from the commandcan be retrieved using the <b>sysval</b> macro.</dd><dt><b>sysval</b></dt><dd>The defining text of the <b>sysval</b> macro shall be the exit value of the utility last invoked by the <b>syscmd</b> macro (asa string).</dd><dt><b>traceon</b></dt><dd>The <b>traceon</b> macro shall enable tracing for the macros specified as arguments, or, if no arguments are specified, for allmacros. The trace output shall be written to standard error in an unspecified format.</dd><dt><b>traceoff</b></dt><dd>The <b>traceoff</b> macro shall disable tracing for the macros specified as arguments, or, if no arguments are specified, forall macros.</dd><dt><b>translit</b></dt><dd>The defining text of the <b>translit</b> macro shall be the first argument with every character that occurs in the secondargument replaced with the corresponding character from the third argument.</dd><dt><b>undefine</b></dt><dd>The <b>undefine</b> macro shall delete all definitions (including those preserved using the <b>pushdef</b> macro) of the macrosnamed by its arguments.</dd><dt><b>undivert</b></dt><dd>The <b>undivert</b> macro shall cause immediate output of any text in temporary buffers named as arguments, or all temporarybuffers if no arguments are specified. Buffers can be undiverted into other temporary buffers. Undiverting shall discard thecontents of the temporary buffer. It shall be an error to specify an argument containing any non-numeric characters.</dd></dl></blockquote><h4><a name="tag_04_82_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt> 0</dt><dd>Successful completion.</dd><dt>>0</dt><dd>An error occurred</dd></dl><p>If the <b>m4exit</b> macro is used, the exit value can be specified by the input file.</p></blockquote><h4><a name="tag_04_82_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>Default.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_82_16"></a>APPLICATION USAGE</h4><blockquote><p>The <b>defn</b> macro is useful for renaming macros, especially built-ins.</p></blockquote><h4><a name="tag_04_82_17"></a>EXAMPLES</h4><blockquote><p>If the file <b>m4src</b> contains the lines:</p><pre><tt>The value of `VER' is "VER".ifdef(`VER', "VER" is defined to be VER., VER is not defined.)ifelse(VER, 1, "VER" is `VER'.)ifelse(VER, 2, "VER" is `VER'., "VER" is not 2.)end</tt></pre><p>then the command</p><pre><tt>m4 m4src</tt></pre><p>or the command:</p><pre><tt>m4 -U VER m4src</tt></pre><p>produces the output:</p><pre><tt>The value of VER is "VER".VER is not defined.<br>VER is not 2.end</tt></pre><p>The command:</p><pre><tt>m4 -D VER m4src</tt></pre><p>produces the output:</p><pre><tt>The value of VER is "".VER is defined to be .<br>VER is not 2.end</tt></pre><p>The command:</p><pre><tt>m4 -D VER=1 m4src</tt></pre><p>produces the output:</p><pre><tt>The value of VER is "1".VER is defined to be 1.VER is 1.VER is not 2.end</tt></pre><p>The command:</p><pre><tt>m4 -D VER=2 m4src<br>produces the output:The value of VER is "2".VER is defined to be 2.<br>VER is 2.end</tt></pre></blockquote><h4><a name="tag_04_82_18"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_82_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_82_20"></a>SEE ALSO</h4><blockquote><p><a href="c99.html"><i>c99</i></a></p></blockquote><h4><a name="tag_04_82_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 2.</p></blockquote><h4><a name="tag_04_82_22"></a>Issue 5</h4><blockquote><p>The phrase "the defined text for macros written by the <b>dumpdef</b> macro" is added to the description of STDERR, and thedescription of <b>dumpdef</b> is updated to indicate that output is written to standard error. The description of <b>eval</b> isupdated to indicate that the list of excluded C operators excludes unary <tt>'&'</tt> and <tt>'.'</tt>. In the description of<b>ifdef</b>, the phrase "and it is not defined to be zero" is deleted.</p></blockquote><h4><a name="tag_04_82_23"></a>Issue 6</h4><blockquote><p>In the EXTENDED DESCRIPTION, the <b>eval</b> text is updated to include a <tt>'&'</tt> character in the excepted list.</p><p>The EXTENDED DESCRIPTION of <b>divert</b> is updated to clarify that there are only nine diversion buffers.</p><p>The normative text is reworded to avoid use of the term "must" for application requirements.</p><p>The Open Group Base Resolution bwg2000-006 is applied.</p><p>IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/31 is applied, replacing the EXAMPLES section.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -