Thu Jun 25 02:54:50 2020 UTC ()
Fix --error-output to be more like GNU m4.  It's a long version of -o.


(uwe)
diff -r1.27 -r1.28 src/usr.bin/m4/m4.1

cvs diff -r1.27 -r1.28 src/usr.bin/m4/m4.1 (switch to unified diff)

--- src/usr.bin/m4/m4.1 2016/01/17 11:24:28 1.27
+++ src/usr.bin/m4/m4.1 2020/06/25 02:54:50 1.28
@@ -1,522 +1,519 @@ @@ -1,522 +1,519 @@
1.\" $NetBSD: m4.1,v 1.27 2016/01/17 11:24:28 wiz Exp $ 1.\" $NetBSD: m4.1,v 1.28 2020/06/25 02:54:50 uwe Exp $
2.\" @(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $ 2.\" @(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
3.\" 3.\"
4.\" Copyright (c) 1989, 1993 4.\" Copyright (c) 1989, 1993
5.\" The Regents of the University of California. All rights reserved. 5.\" The Regents of the University of California. All rights reserved.
6.\" 6.\"
7.\" This code is derived from software contributed to Berkeley by 7.\" This code is derived from software contributed to Berkeley by
8.\" Ozan Yigit at York University. 8.\" Ozan Yigit at York University.
9.\" 9.\"
10.\" Redistribution and use in source and binary forms, with or without 10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions 11.\" modification, are permitted provided that the following conditions
12.\" are met: 12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright 13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer. 14.\" notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in the 16.\" notice, this list of conditions and the following disclaimer in the
17.\" documentation and/or other materials provided with the distribution. 17.\" documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of the University nor the names of its contributors 18.\" 3. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software 19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission. 20.\" without specific prior written permission.
21.\" 21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE. 32.\" SUCH DAMAGE.
33.\" 33.\"
34.Dd January 16, 2015 34.Dd January 16, 2015
35.Dt M4 1 35.Dt M4 1
36.Os 36.Os
37.Sh NAME 37.Sh NAME
38.Nm m4 38.Nm m4
39.Nd macro language processor 39.Nd macro language processor
40.Sh SYNOPSIS 40.Sh SYNOPSIS
41.Nm m4 41.Nm m4
42.Op Fl EGgiPQsv 42.Op Fl EGgiPQsv
43.Oo 43.Oo
44.Sm off 44.Sm off
45.Fl D Ar name Op No = Ar value 45.Fl D Ar name Op No = Ar value
46.Sm on 46.Sm on
47.Oc 47.Oc
48.Op Fl d Ar flags 48.Op Fl d Ar flags
49.Op Fl e Ar filename 
50.Op Fl F Ar filename 49.Op Fl F Ar filename
51.Op Fl I Ar dirname 50.Op Fl I Ar dirname
52.Op Fl L Ar number 51.Op Fl L Ar number
53.Op Fl o Ar filename 52.Op Fl o Ar filename
54.Op Fl R Ar filename 53.Op Fl R Ar filename
55.Op Fl t Ar macro 54.Op Fl t Ar macro
56.Op Fl U Ns Ar name 55.Op Fl U Ns Ar name
57.Op Ar 56.Op Ar
58.Sh DESCRIPTION 57.Sh DESCRIPTION
59The 58The
60.Nm m4 59.Nm m4
61utility is a macro processor that can be used as a front end to any 60utility is a macro processor that can be used as a front end to any
62language (e.g., C, ratfor, fortran, lex, and yacc). 61language (e.g., C, ratfor, fortran, lex, and yacc).
63If no input files are given, 62If no input files are given,
64.Nm m4 63.Nm m4
65reads from the standard input, 64reads from the standard input,
66otherwise files specified on the command line are 65otherwise files specified on the command line are
67processed in the given order. 66processed in the given order.
68Input files can be regular files, files in the m4 include paths, or a 67Input files can be regular files, files in the m4 include paths, or a
69single dash 68single dash
70.Pq Sq - , 69.Pq Sq - ,
71denoting standard input. 70denoting standard input.
72.Nm m4 71.Nm m4
73writes 72writes
74the processed text to the standard output, unless told otherwise. 73the processed text to the standard output, unless told otherwise.
75.Pp 74.Pp
76Macro calls have the form name(argument1[, argument2, ..., argumentN]). 75Macro calls have the form name(argument1[, argument2, ..., argumentN]).
77.Pp 76.Pp
78There cannot be any space following the macro name and the open 77There cannot be any space following the macro name and the open
79parenthesis 78parenthesis
80.Sq \&( . 79.Sq \&( .
81If the macro name is not followed by an open 80If the macro name is not followed by an open
82parenthesis it is processed with no arguments. 81parenthesis it is processed with no arguments.
83.Pp 82.Pp
84Macro names consist of a leading alphabetic or underscore 83Macro names consist of a leading alphabetic or underscore
85possibly followed by alphanumeric or underscore characters, e.g., 84possibly followed by alphanumeric or underscore characters, e.g.,
86valid macro names match the pattern 85valid macro names match the pattern
87.Dq [a-zA-Z_][a-zA-Z0-9_]* . 86.Dq [a-zA-Z_][a-zA-Z0-9_]* .
88.Pp 87.Pp
89In arguments to macros, leading unquoted space, tab, and newline 88In arguments to macros, leading unquoted space, tab, and newline
90.Pq Sq \en 89.Pq Sq \en
91characters are ignored. 90characters are ignored.
92To quote strings, use left and right single quotes 91To quote strings, use left and right single quotes
93.Po e.g.,\ \& 92.Po e.g.,\ \&
94.Sq "\ this is a string with a leading space" 93.Sq "\ this is a string with a leading space"
95.Pc . 94.Pc .
96You can change the quote characters with the 95You can change the quote characters with the
97.Ic changequote 96.Ic changequote
98built-in macro. 97built-in macro.
99.Pp 98.Pp
100Most built-ins don't make any sense without arguments, and hence are not 99Most built-ins don't make any sense without arguments, and hence are not
101recognized as special when not followed by an open parenthesis. 100recognized as special when not followed by an open parenthesis.
102.Pp 101.Pp
103The options are as follows: 102The options are as follows:
104.Bl -tag -width Ds 103.Bl -tag -width Ds
105.It Fl D , Fl Fl define Ar name Ns Op Pf = Ns Ar value 104.It Fl D , Fl Fl define Ar name Ns Op Pf = Ns Ar value
106Define the symbol 105Define the symbol
107.Ar name 106.Ar name
108to have some value (or 107to have some value (or
109.Dv NULL ) . 108.Dv NULL ) .
110.It Fl d , Fl Fl debug Ar "flags" 109.It Fl d , Fl Fl debug Ar "flags"
111Set trace flags. 110Set trace flags.
112.Ar flags 111.Ar flags
113may hold the following: 112may hold the following:
114.Bl -tag -width Ds 113.Bl -tag -width Ds
115.It Ar a 114.It Ar a
116print macro arguments. 115print macro arguments.
117.It Ar c 116.It Ar c
118print macro expansion over several lines. 117print macro expansion over several lines.
119.It Ar e 118.It Ar e
120print result of macro expansion. 119print result of macro expansion.
121.It Ar f 120.It Ar f
122print filename location. 121print filename location.
123.It Ar l 122.It Ar l
124print line number. 123print line number.
125.It Ar q 124.It Ar q
126quote arguments and expansion with the current quotes. 125quote arguments and expansion with the current quotes.
127.It Ar t 126.It Ar t
128start with all macros traced. 127start with all macros traced.
129.It Ar x 128.It Ar x
130number macro expansions. 129number macro expansions.
131.It Ar V 130.It Ar V
132turn on all options. 131turn on all options.
133.El 132.El
134.Pp 133.Pp
135By default, trace is set to 134By default, trace is set to
136.Qq eq . 135.Qq eq .
137.It Fl E , Fl Fl fatal-warnings 136.It Fl E , Fl Fl fatal-warnings
138Warnings make 137Warnings make
139.Nm 138.Nm
140exit. 139exit.
141.It Fl e , Fl Fl error-output Ar filename 
142Redirect error output to filename. 
143.It Fl F , Fl Fl freeze-state Ar filename 140.It Fl F , Fl Fl freeze-state Ar filename
144Save the input state to 141Save the input state to
145.Ar filename . 142.Ar filename .
146.It Fl G , Fl Fl traditional 143.It Fl G , Fl Fl traditional
147Disable GNU-m4 extensions. 144Disable GNU-m4 extensions.
148.It Fl g , Fl Fl gnu 145.It Fl g , Fl Fl gnu
149Activate GNU-m4 compatibility mode. 146Activate GNU-m4 compatibility mode.
150In this mode, translit handles simple character 147In this mode, translit handles simple character
151ranges (e.g., a-z), regular expressions mimic emacs behavior, 148ranges (e.g., a-z), regular expressions mimic emacs behavior,
152multiple m4wrap calls are handled as a stack, 149multiple m4wrap calls are handled as a stack,
153the number of diversions is unlimited, 150the number of diversions is unlimited,
154empty names for macro definitions are allowed, 151empty names for macro definitions are allowed,
155and eval understands 152and eval understands
156.Sq 0rbase:value 153.Sq 0rbase:value
157numbers. 154numbers.
158.It Fl Fl help 155.It Fl Fl help
159Print help message and exit. 156Print help message and exit.
160.It Fl I , Fl Fl include Ar "dirname" 157.It Fl I , Fl Fl include Ar "dirname"
161Add directory 158Add directory
162.Ar dirname 159.Ar dirname
163to the include path. 160to the include path.
164.It Fl i , Fl Fl interactive 161.It Fl i , Fl Fl interactive
165Set unbuffered output, disable tty signals. 162Set unbuffered output, disable tty signals.
166.It Fl L , Fl Fl nesting-limit 163.It Fl L , Fl Fl nesting-limit
167Set the nesting limit in macro expansions. 164Set the nesting limit in macro expansions.
168This is unimplemented and unlimited. 165This is unimplemented and unlimited.
169.It Fl o Ar filename 166.It Fl o , Fl Fl error-output Ar filename
170Send trace output to 167Send trace output to
171.Ar filename . 168.Ar filename .
172.It Fl P , Fl Fl prefix-builtins 169.It Fl P , Fl Fl prefix-builtins
173Prefix all built-in macros with 170Prefix all built-in macros with
174.Sq m4_ . 171.Sq m4_ .
175For example, instead of writing 172For example, instead of writing
176.Ic define , 173.Ic define ,
177use 174use
178.Ic m4_define . 175.Ic m4_define .
179.It Fl Q , Fl Fl quiet , Fl Fl silent 176.It Fl Q , Fl Fl quiet , Fl Fl silent
180Don't print warnings. 177Don't print warnings.
181.It Fl R , Fl Fl reload-state Ar filename 178.It Fl R , Fl Fl reload-state Ar filename
182Reload a previously saved state from 179Reload a previously saved state from
183.Ar filename . 180.Ar filename .
184.It Fl s , Fl Fl synclines 181.It Fl s , Fl Fl synclines
185Output line synchronization directives, suitable for 182Output line synchronization directives, suitable for
186.Xr cpp 1 . 183.Xr cpp 1 .
187.It Fl t , Fl Fl trace Ar macro 184.It Fl t , Fl Fl trace Ar macro
188Turn tracing on for 185Turn tracing on for
189.Ar macro . 186.Ar macro .
190.It Fl U , Fl Fl undefine Ar "name" 187.It Fl U , Fl Fl undefine Ar "name"
191Undefine the symbol 188Undefine the symbol
192.Ar name . 189.Ar name .
193.It Fl v , Fl Fl version 190.It Fl v , Fl Fl version
194Print the version and exit. 191Print the version and exit.
195.El 192.El
196.Sh SYNTAX 193.Sh SYNTAX
197.Nm m4 194.Nm m4
198provides the following built-in macros. 195provides the following built-in macros.
199They may be redefined, losing their original meaning. 196They may be redefined, losing their original meaning.
200Return values are null unless otherwise stated. 197Return values are null unless otherwise stated.
201.Bl -tag -width changequote 198.Bl -tag -width changequote
202.It Fn builtin name 199.It Fn builtin name
203Calls a built-in by its 200Calls a built-in by its
204.Fa name , 201.Fa name ,
205overriding possible redefinitions. 202overriding possible redefinitions.
206.It Fn changecom startcomment endcomment 203.It Fn changecom startcomment endcomment
207Changes the start comment and end comment sequences. 204Changes the start comment and end comment sequences.
208Comment sequences may be up to five characters long. 205Comment sequences may be up to five characters long.
209The default values are the hash sign 206The default values are the hash sign
210and the newline character. 207and the newline character.
211.Bd -literal -offset indent 208.Bd -literal -offset indent
212# This is a comment 209# This is a comment
213.Ed 210.Ed
214.Pp 211.Pp
215With no arguments, comments are turned off. 212With no arguments, comments are turned off.
216With one single argument, the end comment sequence is set 213With one single argument, the end comment sequence is set
217to the newline character. 214to the newline character.
218.It Fn changequote beginquote endquote 215.It Fn changequote beginquote endquote
219Defines the open quote and close quote sequences. 216Defines the open quote and close quote sequences.
220Quote sequences may be up to five characters long. 217Quote sequences may be up to five characters long.
221The default values are the backquote character and the quote 218The default values are the backquote character and the quote
222character. 219character.
223.Bd -literal -offset indent 220.Bd -literal -offset indent
224`Here is a quoted string' 221`Here is a quoted string'
225.Ed 222.Ed
226.Pp 223.Pp
227With no arguments, the default quotes are restored. 224With no arguments, the default quotes are restored.
228With one single argument, the close quote sequence is set 225With one single argument, the close quote sequence is set
229to the newline character. 226to the newline character.
230.It Fn decr arg 227.It Fn decr arg
231Decrements the argument 228Decrements the argument
232.Fa arg 229.Fa arg
233by 1. 230by 1.
234The argument 231The argument
235.Fa arg 232.Fa arg
236must be a valid numeric string. 233must be a valid numeric string.
237.It Fn define name value 234.It Fn define name value
238Define a new macro named by the first argument 235Define a new macro named by the first argument
239.Fa name 236.Fa name
240to have the 237to have the
241value of the second argument 238value of the second argument
242.Fa value . 239.Fa value .
243Each occurrence of 240Each occurrence of
244.Sq $n 241.Sq $n
245(where 242(where
246.Ar n 243.Ar n
247is 0 through 9) is replaced by the 244is 0 through 9) is replaced by the
248.Ar n Ns 'th 245.Ar n Ns 'th
249argument. 246argument.
250.Sq $0 247.Sq $0
251is the name of the calling macro. 248is the name of the calling macro.
252Undefined arguments are replaced by a null string. 249Undefined arguments are replaced by a null string.
253.Sq $# 250.Sq $#
254is replaced by the number of arguments; 251is replaced by the number of arguments;
255.Sq $* 252.Sq $*
256is replaced by all arguments comma separated; 253is replaced by all arguments comma separated;
257.Sq $@ 254.Sq $@
258is the same as 255is the same as
259.Sq $* 256.Sq $*
260but all arguments are quoted against further expansion. 257but all arguments are quoted against further expansion.
261.It Fn defn name ... 258.It Fn defn name ...
262Returns the quoted definition for each argument. 259Returns the quoted definition for each argument.
263This can be used to rename 260This can be used to rename
264macro definitions (even for built-in macros). 261macro definitions (even for built-in macros).
265.It Fn divert num 262.It Fn divert num
266There are 10 output queues (numbered 0-9). 263There are 10 output queues (numbered 0-9).
267At the end of processing 264At the end of processing
268.Nm m4 265.Nm m4
269concatenates all the queues in numerical order to produce the 266concatenates all the queues in numerical order to produce the
270final output. 267final output.
271Initially the output queue is 0. 268Initially the output queue is 0.
272The divert 269The divert
273macro allows you to select a new output queue (an invalid argument 270macro allows you to select a new output queue (an invalid argument
274passed to divert causes output to be discarded). 271passed to divert causes output to be discarded).
275.It Ic divnum 272.It Ic divnum
276Returns the current output queue number. 273Returns the current output queue number.
277.It Ic dnl 274.It Ic dnl
278Discard input characters up to and including the next newline. 275Discard input characters up to and including the next newline.
279.It Fn dumpdef name ... 276.It Fn dumpdef name ...
280Prints the names and definitions for the named items, or for everything 277Prints the names and definitions for the named items, or for everything
281if no arguments are passed. 278if no arguments are passed.
282.It Fn errprint msg 279.It Fn errprint msg
283Prints the first argument on the standard error output stream. 280Prints the first argument on the standard error output stream.
284.It Fn esyscmd cmd 281.It Fn esyscmd cmd
285Passes its first argument to a shell and returns the shell's standard output. 282Passes its first argument to a shell and returns the shell's standard output.
286Note that the shell shares its standard input and standard error with 283Note that the shell shares its standard input and standard error with
287.Nm m4 . 284.Nm m4 .
288.It Fn eval expr[,radix[,minimum]] 285.It Fn eval expr[,radix[,minimum]]
289Computes the first argument as an arithmetic expression using 32-bit 286Computes the first argument as an arithmetic expression using 32-bit
290arithmetic. 287arithmetic.
291Operators are the standard C ternary, arithmetic, logical, 288Operators are the standard C ternary, arithmetic, logical,
292shift, relational, bitwise, and parentheses operators. 289shift, relational, bitwise, and parentheses operators.
293You can specify 290You can specify
294octal, decimal, and hexadecimal numbers as in C. 291octal, decimal, and hexadecimal numbers as in C.
295The optional second argument 292The optional second argument
296.Fa radix 293.Fa radix
297specifies the radix for the result and the optional third argument 294specifies the radix for the result and the optional third argument
298.Fa minimum 295.Fa minimum
299specifies the minimum number of digits in the result. 296specifies the minimum number of digits in the result.
300.It Fn expr expr 297.It Fn expr expr
301This is an alias for 298This is an alias for
302.Ic eval . 299.Ic eval .
303.It Fn format formatstring arg1 ... 300.It Fn format formatstring arg1 ...
304Returns 301Returns
305.Fa formatstring 302.Fa formatstring
306with escape sequences substituted with 303with escape sequences substituted with
307.Fa arg1 304.Fa arg1
308and following arguments, in a way similar to 305and following arguments, in a way similar to
309.Xr printf 3 . 306.Xr printf 3 .
310This built-in is only available in GNU-m4 compatibility mode, and the only 307This built-in is only available in GNU-m4 compatibility mode, and the only
311parameters implemented are there for autoconf compatibility: 308parameters implemented are there for autoconf compatibility:
312left-padding flag, an optional field width, a maximum field width, 309left-padding flag, an optional field width, a maximum field width,
313*-specified field widths, and the %s and %c data type. 310*-specified field widths, and the %s and %c data type.
314.It Fn ifdef name yes no 311.It Fn ifdef name yes no
315If the macro named by the first argument is defined then return the second 312If the macro named by the first argument is defined then return the second
316argument, otherwise the third. 313argument, otherwise the third.
317If there is no third argument, the value is 314If there is no third argument, the value is
318.Dv NULL . 315.Dv NULL .
319The word 316The word
320.Qq unix 317.Qq unix
321is predefined. 318is predefined.
322.It Fn ifelse a b yes ... 319.It Fn ifelse a b yes ...
323If the first argument 320If the first argument
324.Fa a 321.Fa a
325matches the second argument 322matches the second argument
326.Fa b 323.Fa b
327then 324then
328.Fn ifelse 325.Fn ifelse
329returns 326returns
330the third argument 327the third argument
331.Fa yes . 328.Fa yes .
332If the match fails the three arguments are 329If the match fails the three arguments are
333discarded and the next three arguments are used until there is 330discarded and the next three arguments are used until there is
334zero or one arguments left, either this last argument or 331zero or one arguments left, either this last argument or
335.Dv NULL 332.Dv NULL
336is returned if no other matches were found. 333is returned if no other matches were found.
337.It Fn include name 334.It Fn include name
338Returns the contents of the file specified in the first argument. 335Returns the contents of the file specified in the first argument.
339If the file is not found as is, look through the include path: 336If the file is not found as is, look through the include path:
340first the directories specified with 337first the directories specified with
341.Fl I 338.Fl I
342on the command line, then the environment variable 339on the command line, then the environment variable
343.Ev M4PATH , 340.Ev M4PATH ,
344as a colon-separated list of directories. 341as a colon-separated list of directories.
345Include aborts with an error message if the file cannot be included. 342Include aborts with an error message if the file cannot be included.
346.It Fn incr arg 343.It Fn incr arg
347Increments the argument by 1. 344Increments the argument by 1.
348The argument must be a valid numeric string. 345The argument must be a valid numeric string.
349.It Fn index string substring 346.It Fn index string substring
350Returns the index of the second argument in the first argument (e.g., 347Returns the index of the second argument in the first argument (e.g.,
351.Ic index(the quick brown fox jumped, fox) 348.Ic index(the quick brown fox jumped, fox)
352returns 16). 349returns 16).
353If the second 350If the second
354argument is not found index returns \-1. 351argument is not found index returns \-1.
355.It Fn indir macro arg1 ... 352.It Fn indir macro arg1 ...
356Indirectly calls the macro whose name is passed as the first argument, 353Indirectly calls the macro whose name is passed as the first argument,
357with the remaining arguments passed as first, ... arguments. 354with the remaining arguments passed as first, ... arguments.
358.It Fn len arg 355.It Fn len arg
359Returns the number of characters in the first argument. 356Returns the number of characters in the first argument.
360Extra arguments 357Extra arguments
361are ignored. 358are ignored.
362.It Fn m4exit code 359.It Fn m4exit code
363Immediately exits with the return value specified by the first argument, 360Immediately exits with the return value specified by the first argument,
3640 if none. 3610 if none.
365.It Fn m4wrap todo 362.It Fn m4wrap todo
366Allows you to define what happens at the final 363Allows you to define what happens at the final
367.Dv EOF , 364.Dv EOF ,
368usually for cleanup purposes (e.g., 365usually for cleanup purposes (e.g.,
369.Ic m4wrap("cleanup(tempfile)") 366.Ic m4wrap("cleanup(tempfile)")
370causes the macro cleanup to be 367causes the macro cleanup to be
371invoked after all other processing is done). 368invoked after all other processing is done).
372.Pp 369.Pp
373Multiple calls to 370Multiple calls to
374.Fn m4wrap 371.Fn m4wrap
375get inserted in sequence at the final 372get inserted in sequence at the final
376.Dv EOF . 373.Dv EOF .
377.It Fn maketemp template 374.It Fn maketemp template
378Invokes 375Invokes
379.Xr mkstemp 3 376.Xr mkstemp 3
380on the first argument, and returns the modified string. 377on the first argument, and returns the modified string.
381This can be used to create unique 378This can be used to create unique
382temporary file names. 379temporary file names.
383.It Fn paste file 380.It Fn paste file
384Includes the contents of the file specified by the first argument without 381Includes the contents of the file specified by the first argument without
385any macro processing. 382any macro processing.
386Aborts with an error message if the file cannot be 383Aborts with an error message if the file cannot be
387included. 384included.
388.It Fn patsubst string regexp replacement 385.It Fn patsubst string regexp replacement
389Substitutes a regular expression in a string with a replacement string. 386Substitutes a regular expression in a string with a replacement string.
390Usual substitution patterns apply: an ampersand 387Usual substitution patterns apply: an ampersand
391.Pq Sq \&& 388.Pq Sq \&&
392is replaced by the string matching the regular expression. 389is replaced by the string matching the regular expression.
393The string 390The string
394.Sq \e# , 391.Sq \e# ,
395where 392where
396.Sq # 393.Sq #
397is a digit, is replaced by the corresponding back-reference. 394is a digit, is replaced by the corresponding back-reference.
398.It Fn popdef arg ... 395.It Fn popdef arg ...
399Restores the 396Restores the
400.Ic pushdef Ns ed 397.Ic pushdef Ns ed
401definition for each argument. 398definition for each argument.
402.It Fn pushdef macro def 399.It Fn pushdef macro def
403Takes the same arguments as 400Takes the same arguments as
404.Ic define , 401.Ic define ,
405but it saves the definition on a 402but it saves the definition on a
406stack for later retrieval by 403stack for later retrieval by
407.Fn popdef . 404.Fn popdef .
408.It Fn regexp string regexp replacement 405.It Fn regexp string regexp replacement
409Finds a regular expression in a string. 406Finds a regular expression in a string.
410If no further arguments are given, 407If no further arguments are given,
411it returns the first match position or \-1 if no match. 408it returns the first match position or \-1 if no match.
412If a third argument 409If a third argument
413is provided, it returns the replacement string, with sub-patterns replaced. 410is provided, it returns the replacement string, with sub-patterns replaced.
414.It Fn shift arg1 ... 411.It Fn shift arg1 ...
415Returns all but the first argument, the remaining arguments are 412Returns all but the first argument, the remaining arguments are
416quoted and pushed back with commas in between. 413quoted and pushed back with commas in between.
417The quoting 414The quoting
418nullifies the effect of the extra scan that will subsequently be 415nullifies the effect of the extra scan that will subsequently be
419performed. 416performed.
420.It Fn sinclude file 417.It Fn sinclude file
421Similar to 418Similar to
422.Ic include , 419.Ic include ,
423except it ignores any errors. 420except it ignores any errors.
424.It Fn spaste file 421.It Fn spaste file
425Similar to 422Similar to
426.Fn paste , 423.Fn paste ,
427except it ignores any errors. 424except it ignores any errors.
428.It Fn substr string offset length 425.It Fn substr string offset length
429Returns a substring of the first argument starting at the offset specified 426Returns a substring of the first argument starting at the offset specified
430by the second argument and the length specified by the third argument. 427by the second argument and the length specified by the third argument.
431If no third argument is present it returns the rest of the string. 428If no third argument is present it returns the rest of the string.
432.It Fn syscmd cmd 429.It Fn syscmd cmd
433Passes the first argument to the shell. 430Passes the first argument to the shell.
434Nothing is returned. 431Nothing is returned.
435.It Ic sysval 432.It Ic sysval
436Returns the return value from the last 433Returns the return value from the last
437.Ic syscmd . 434.Ic syscmd .
438.It Fn traceon arg ... 435.It Fn traceon arg ...
439Enables tracing of macro expansions for the given arguments, or for all 436Enables tracing of macro expansions for the given arguments, or for all
440macros if no argument is given. 437macros if no argument is given.
441.It Fn traceoff arg ... 438.It Fn traceoff arg ...
442Disables tracing of macro expansions for the given arguments, or for all 439Disables tracing of macro expansions for the given arguments, or for all
443macros if no argument is given. 440macros if no argument is given.
444.It Fn translit string mapfrom mapto 441.It Fn translit string mapfrom mapto
445Transliterate the characters in the first argument from the set 442Transliterate the characters in the first argument from the set
446given by the second argument to the set given by the third. 443given by the second argument to the set given by the third.
447You cannot use 444You cannot use
448.Xr tr 1 445.Xr tr 1
449style abbreviations. 446style abbreviations.
450.It Fn undefine name1 ... 447.It Fn undefine name1 ...
451Removes the definition for the macros specified by its arguments. 448Removes the definition for the macros specified by its arguments.
452.It Fn undivert arg ... 449.It Fn undivert arg ...
453Flushes the named output queues (or all queues if no arguments). 450Flushes the named output queues (or all queues if no arguments).
454.It Ic unix 451.It Ic unix
455A pre-defined macro for testing the OS platform. 452A pre-defined macro for testing the OS platform.
456.It Ic __line__ 453.It Ic __line__
457Returns the current file's line number. 454Returns the current file's line number.
458.It Ic __file__ 455.It Ic __file__
459Returns the current file's name. 456Returns the current file's name.
460.El 457.El
461.Sh STANDARDS 458.Sh STANDARDS
462The 459The
463.Nm 460.Nm
464utility is compliant with the 461utility is compliant with the
465.St -p1003.1-2008 462.St -p1003.1-2008
466specification. 463specification.
467.Pp 464.Pp
468The flags 465The flags
469.Op Fl dgIot 466.Op Fl dgIot
470and the macros 467and the macros
471.Ic builtin , 468.Ic builtin ,
472.Ic esyscmd , 469.Ic esyscmd ,
473.Ic expr , 470.Ic expr ,
474.Ic format , 471.Ic format ,
475.Ic indir , 472.Ic indir ,
476.Ic paste , 473.Ic paste ,
477.Ic patsubst , 474.Ic patsubst ,
478.Ic regexp , 475.Ic regexp ,
479.Ic spaste , 476.Ic spaste ,
480.Ic unix , 477.Ic unix ,
481.Ic __line__ , 478.Ic __line__ ,
482and 479and
483.Ic __file__ 480.Ic __file__
484are extensions to that specification. 481are extensions to that specification.
485.Pp 482.Pp
486The output format of tracing and of 483The output format of tracing and of
487.Ic dumpdef 484.Ic dumpdef
488are not specified in any standard, 485are not specified in any standard,
489are likely to change and should not be relied upon. 486are likely to change and should not be relied upon.
490The current format of tracing is closely modelled on 487The current format of tracing is closely modelled on
491.Nm gnu-m4 , 488.Nm gnu-m4 ,
492to allow 489to allow
493.Nm autoconf 490.Nm autoconf
494to work. 491to work.
495.Pp 492.Pp
496The built-ins 493The built-ins
497.Ic pushdef 494.Ic pushdef
498and 495and
499.Ic popdef 496.Ic popdef
500handle macro definitions as a stack. 497handle macro definitions as a stack.
501However, 498However,
502.Ic define 499.Ic define
503interacts with the stack in an undefined way. 500interacts with the stack in an undefined way.
504In this implementation, 501In this implementation,
505.Ic define 502.Ic define
506replaces the top-most definition only. 503replaces the top-most definition only.
507Other implementations may erase all definitions on the stack instead. 504Other implementations may erase all definitions on the stack instead.
508.Pp 505.Pp
509All built-ins do expand without arguments in many other 506All built-ins do expand without arguments in many other
510.Nm m4 . 507.Nm m4 .
511.Pp 508.Pp
512Many other 509Many other
513.Nm 510.Nm
514have dire size limitations with respect to buffer sizes. 511have dire size limitations with respect to buffer sizes.
515.Sh AUTHORS 512.Sh AUTHORS
516.An -nosplit 513.An -nosplit
517.An Ozan Yigit Aq Mt oz@sis.yorku.ca 514.An Ozan Yigit Aq Mt oz@sis.yorku.ca
518and 515and
519.An Richard A. O'Keefe Aq Mt ok@goanna.cs.rmit.OZ.AU . 516.An Richard A. O'Keefe Aq Mt ok@goanna.cs.rmit.OZ.AU .
520.Pp 517.Pp
521GNU-m4 compatibility extensions by 518GNU-m4 compatibility extensions by
522.An Marc Espie Aq Mt espie@cvs.openbsd.org . 519.An Marc Espie Aq Mt espie@cvs.openbsd.org .