source: trunk/minix/man/man9/m4.9@ 12

Last change on this file since 12 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 8.1 KB
Line 
1.so mnx.mac
2.TH M4 9
3.CD "m4 \(en macro processor"
4.SX "m4\fR [\fB\(enD \fIname\fR = \fIvalue\fR]\fR [\fB\(enU \fIname\fR]
5.FL "\(enD" "Define a symbol"
6.FL "\(enU" "Undefine a symbol"
7.EY "m4 <m4test" "Run M4"
8.PP
9\fIM4\fR is a macro processor intended as a front end
10for Ratfor, Pascal, and other languages that do not have a built-in macro
11processing capability. M4 reads standard input, the processed text is
12written on the standard output.
13.PP
14The options and their effects are as follows:
15
16.in +0.5i
17.ta 1.25i
18\(enD name[=val] Defines name to val, or to null in val's absence.
19.br
20\(enU name Undefines name.
21.in -0.5i
22
23.PP
24Macro calls have the form: name(arg1,arg2, ..., argn)
25
26The \*(OQ(\*(CQ must immediately follow the name of the macro.
27If the name of a
28defined macro is not followed by a ( it is taken to be a call of that macro
29with no arguments, i.e. name(). Potential macro names consist of alphabetic
30letters and digits.
31.PP
32Leading unquoted blanks, tabs and newlines are ignored while collecting
33arguments. Left and right single quotes are used to quote strings. The value
34of a quoted string is the string stripped of the quotes.
35.PP
36When a macro name is recognized, its arguments are collected by searching
37for a matching ). If fewer arguments are supplied than are in the macro
38definition, the trailing arguments are taken to be null. Macro evaluation
39proceeds normally during the collection of the arguments, and any commas or
40right parentheses which happen to turn up within the value of a nested call
41are as effective as those in the original input text. (This is typically
42referred as inside-out macro expansion.) After argument collection, the
43value of the macro is pushed back onto the input stream and rescanned.
44.PP
45M4 makes available the following built-in macros. They may be
46redefined, but once this is done the original meaning is lost. Their values
47are null unless otherwise stated.
48.PP
49\fBdefine "(name [, val])"\fR the second argument is installed as the value of
50the macro whose name is the first argument. If there is no second argument,
51the value is null. Each occurrence of $ n in the replacement text, where n is
52a digit, is replaced by the n -th argument. Argument 0 is the name of the
53macro; missing arguments are replaced by the null string.
54.PP
55\fBdefn "(name [, name ...])"\fR returns the quoted definition of its
56argument(s). Useful in renaming macros.
57.PP
58\fBundefine "(name [, name ...])"\fR removes the definition of the macro(s)
59named. If there is more than one definition for the named macro, (due to
60previous use of pushdef) all definitions are removed.
61.PP
62\fBpushdef "(name [, val])"\fR like define, but saves any previous definition
63by stacking the current definition.
64.PP
65\fBpopdef "(name [, name ...])"\fR removes current definition of its
66argument(s), exposing the previous one if any.
67.PP
68\fBifdef "(name, if-def [, ifnot-def])"\fR if the first argument is defined,
69the value is the second argument, otherwise the third. If there is no third
70argument, the value is null. A word indicating the current operating system
71is predefined. (e.g. unix or vms).
72.PP
73\fBshift "(arg, arg, arg, ...)"\fR returns all but its first argument. The
74other arguments are quoted and pushed back with commas in between. The
75quoting nullifies the effect of the extra scan that will subsequently be
76performed.
77.PP
78\fBchangequote "(lqchar, rqchar)"\fR change quote symbols to the first and
79second arguments. With no arguments, the quotes are reset back to the default
80characters. (i.e., `').
81.PP
82\fBchangecom "(lcchar, rcchar)"\fR change left and right comment markers from
83the default # and newline. With no arguments, the comment mechanism is reset
84back to the default characters. With one argument, the left marker becomes
85the argument and the right marker becomes newline. With two arguments, both
86markers are affected.
87.PP
88\fBdivert "(divnum)"\fR maintains 10 output streams, numbered 0-9. Initially
89stream 0 is the current stream. The divert macro changes the current output
90stream to its (digit-string) argument. Output diverted to a stream other than
910 through 9 is lost.
92.PP
93\fBundivert "([divnum [, divnum ...]])"\fR causes immediate output of text from
94diversions named as argument(s), or all diversions if no argument. Text may
95be undiverted into another diversion. Undiverting discards the diverted text.
96At the end of input processing, M4 forces an automatic undivert unless is
97defined.
98.PP
99\fBdivnum "()"\fR returns the value of the current output stream.
100.PP
101\fBdnl "()"\fR reads and discards characters up to and including the next
102newline.
103.PP
104\fBifelse "(arg, arg, if-same [, ifnot-same | arg, arg ...])"\fR has three or
105more arguments. If the first argument is the same string as the second, then
106the value is the third argument. If not, and if there are more than four
107arguments, the process is repeated with arguments 4, 5, 6 and 7. Otherwise,
108the value is either the fourth string, or, if it is not present, null.
109.PP
110\fBincr "(num)"\fR returns the value of its argument incremented by 1. The
111value of the argument is calculated by interpreting an initial digit-string as
112a decimal number.
113.PP
114\fBdecr "(num)"\fR returns the value of its argument decremented by 1.
115.PP
116\fBeval "(expression)"\fR evaluates its argument as a constant expression,
117using integer arithmetic. The evaluation mechanism is very similar to that of
118cpp (#if expression). The expression can involve only integer constants and
119character constants, possibly connected by the binary operators
120.HS
121.in +0.5i
122* / % + - >> << < > <= >= == != & ^ | && ||
123.in -0.5i
124.HS
125or the unary operators - ! or tilde or by the ternary operator ? : .
126Parentheses may be used for grouping. Octal numbers may be specified as in C.
127.PP
128\fBlen "(string)"\fR returns the number of characters in its argument.
129.PP
130\fBindex "(search-string, string)"\fR returns the position in its first
131argument where the second argument begins (zero origin), or 1 if the second
132argument does not occur.
133.PP
134\fBsubstr "(string, index [, length])"\fR returns a substring of its first
135argument. The second argument is a zero origin number selecting the first
136character (internally treated as an expression); the third argument indicates
137the length of the substring. A missing third argument is taken to be large
138enough to extend to the end of the first string.
139.PP
140\fBtranslit "(source, from [, to])"\fR transliterates the characters in its
141first argument from the set given by the second argument to the set given by
142the third. If the third argument is shorter than the second, all extra
143characters in the second argument are deleted from the first argument. If the
144third argument is missing altogether, all characters in the second argument
145are deleted from the first argument.
146.PP
147\fBinclude "(filename)"\fR returns the contents of the file that is
148named in the argument.
149.PP
150\fBsinclude "(filename)"\fRis identical to include, except that it says nothing
151if the file is inaccessable.
152.PP
153\fBpaste "(filename)"\fR returns the contents of the file named in the argument
154without any processing, unlike include.
155.PP
156\fBspaste "(filename)"\fR is identical to paste, except that it says nothing if
157the file is inaccessibl[De.
158.PP
159\fBsyscmd "(command)"\fR executes the
160.Ux
161command given in the first argument.
162No value is returned.
163.PP
164\fBsysval "()"\fR is the return code from the last call to syscmd.
165 .PP
166\fBmaketemp \*(OQ(string)"\fR fills in a string of XXXXXX in its argument with the
167current process ID.
168.PP
169\fBm4exit "([exitcode])"\fR causes immediate exit from M4. Argument 1, if
170given, is the exit code; the default is 0.
171.PP
172\fBm4wrap "(m4-macro-or-built-n)"\fR argument 1 will be pushed back at final
173EOF; example: m4wrap(`dumptable()').
174.PP
175\fBerrprint "(str [, str, str, ...])"\fR prints its argument(s) on stderr. If
176there is more than one argument, each argument is separated by a space during
177the output. An arbitrary number of arguments may be supplied.
178.PP
179\fBdumpdef "([name, name, ...])"\fR prints current names and definitions, for
180the named items, or for all if no arguments are given.
181.SP 1
182.SS "Author"
183.SP 1
184.PP
185\fIM4\fR was written by Ozan S. Yigif.
Note: See TracBrowser for help on using the repository browser.