|
|
1.1 root 1:
2:
3: m4 Command m4
4:
5:
6:
7:
8: Macro processor
9:
10: mm44 [ffiillee ...]
11:
12: The command m4 processes macros. It allows you to define strings
13: for which m4 is to search, and strings to replace them; m4 then
14: opens file, reads its contents, replaces each macro with its
15: specified replacement string, and writes the results into the
16: standard output stream.
17:
18: m4 can also perform file manipulation, conditional decision
19: making, substring selection, and arithmetic. The Introduction to
20: the m4 Macro Processor describes m4 in detail.
21:
22: The files are read in the order given; if no file is named, then
23: m4 reads the standard input stream. The file name `-' indicates
24: the standard input.
25:
26: m4 copies input to output until it finds a potential _m_a_c_r_o. A
27: macro is a string of alphanumerics (letters, digits, or under-
28: scores) that begins with a non-digit character and is surrounded
29: by non-alphanumerics. If m4 does not recognize the macro, it
30: simply copies it to the output and continues processing. If m4
31: recognizes the macro and the next character is a left parenthesis
32: `(', an argument set follows:
33:
34:
35: macro(arg1,..., argn)
36:
37:
38: The arguments are collected by processing them in the same manner
39: as other text (thus, an arguments may itself be another macro),
40: and resulting output text is diverted into storage. m4 stores up
41: to nine arguments; any more will be processed but not saved. An
42: argument set consists of strings of text separated by commas
43: (commas inside quotation marks or parentheses do not terminate an
44: argument), and must contain balanced parentheses that are free of
45: quotation marks (i.e., that are unquoted). m4 strips arguments
46: of unquoted leading space (blanks, tabs, newline characters).
47:
48: m4 then removes the macro and its optional argument set from the
49: input stream, processes them, and replaces them in the input
50: stream with the resulting value. The value becomes the next
51: piece of text to be read.
52:
53: Quotation marks, of the form ` ', inhibit the recognition of
54: macro. m4 strips off one level of quotation marks when it en-
55: counters them (quotation marks are nestable). Thus, `_m_a_c_r_o' is
56: not processed, but is changed to macro and passed on.
57:
58: m4 determines the value of a user-defined macro by taking the
59: text that constitutes the macro's definition and replacing any
60: occurrence within that text of `$_n' (where n is `0' through `9')
61: with the text of the nth argument. Argument 0 is the macro it-
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
67:
68:
69: m4 Command m4
70:
71:
72:
73: self.
74:
75: m4 recognizes the following predefined macros:
76:
77: cchhaannggeeqquuoottee[([_o_p_e_n_q_u_o_t_e],[_c_l_o_s_e_q_u_o_t_e])]
78: Changes the quotation characters. Missing arguments default
79: to ` for open or ' for close. Quotation characters will not
80: nest if they are defined to be the same character. Value is
81: null.
82:
83: ddeeccrr[(_n_u_m_b_e_r)]
84: Decrement number (default, 0) by one and returns resulting
85: value.
86:
87: ddeeffiinnee(_m_a_c_r_o,_d_e_f_i_n_i_t_i_o_n)
88: Define or redefine macro. If a predefined macro is
89: redefined, its original definition is irrecoverably lost.
90: Value is null.
91:
92: ddiivveerrtt[(_n)]
93: Redirects output to output stream n (default is 0). The
94: standard output is 0, and 1 through 9 are maintained as tem-
95: porary files. Any other n results in output being thrown
96: away until the next divert macro. Value is null.
97:
98: ddiivvnnuumm
99: Value is current output stream number.
100:
101: ddnnll Delete to newline: removes all characters from the input
102: stream up to and including the next newline. Value is null.
103:
104: dduummppddeeff[(_m_a_c_r_o_s)]
105: Value is quoted definitions of all macros specified, or
106: names and definitions of all defined macros if no arguments.
107:
108: eerrrrpprriinntt(_t_e_x_t)
109: Print text on standard error file. Value is null.
110:
111: eevvaall(_e_x_p_r_e_s_s_i_o_n)
112: Value is a number that is the value of evaluated expression.
113: It recognizes, in order of decreasing precedence: paren-
114: theses, **, unary + -, * / %, binary + -, relations, and
115: logicals. Arithmetic is performed in longs.
116:
117: iiffddeeff(_m_a_c_r_o,_d_e_f_v_a_l_u_e,_u_n_d_e_f_v_a_l_u_e)
118: Return defvalue if macro is defined, and undefvalue if not.
119:
120: iiffeellssee(_a_r_g_1,_a_r_g_2,_a_r_g_3...)
121: Compares arg1 and arg2. If they are the same, returns arg3.
122: If not, and arg4 is the last argument, return arg4. Other-
123: wise, the process repeats, comparing arg4 and arg5, and so
124: on. Like other m4 macros, this takes a maximum of nine ar-
125: guments.
126:
127:
128:
129:
130: COHERENT Lexicon Page 2
131:
132:
133:
134:
135: m4 Command m4
136:
137:
138:
139: iinncclluuddee(_f_i_l_e)
140: Value is the entire contents of the file argument. If file
141: is not accessible, a fatal error results.
142:
143: iinnccrr[(_n_u_m_b_e_r)]
144: Increments given number (default, zero) by one and returns
145: resulting value.
146:
147: iinnddeexx(_t_e_x_t,_p_a_t_t_e_r_n)
148: Value is a number corresponding to position of pattern in
149: text. If pattern does not occur in text, value is -1.
150:
151: lleenn(_t_e_x_t)
152: Value is a number that corresponds to length of text.
153:
154: mmaakkeetteemmpp(_f_i_l_e_n_a_m_e_X_X_X_X_X_X)
155: Value is filename with last six characters, usually XXXXXX,
156: replaced with current process id and a single letter. Same
157: as system call mktemp.
158:
159: ssiinncclluuddee(_f_i_l_e)
160: Value is the entire contents of file. If file is not acces-
161: sible, return null and continue processing.
162:
163: ssuubbssttrr(_t_e_x_t[,_s_t_a_r_t[,_c_o_u_n_t]])
164: Value is a substring of text. start may be left-oriented
165: (nonnegative) or right-oriented (negative). count specifies
166: how many characters to the right (if positive) or to the
167: left (if negative) to return. If absent, it is assumed to
168: be large and of the same sign as start. If start is
169: omitted, it is assumed to be zero if count is positive or
170: omitted, or -1 if count is negative.
171:
172: ssyyssccmmdd(_c_o_m_m_a_n_d)
173: Pass command to the shell sh for execution. Value is null.
174: Same as system call system.
175:
176: ttrraannsslliitt(_t_e_x_t,_c_h_a_r_a_c_t_e_r_s[,_r_e_p_l_a_c_e_m_e_n_t_s])
177: Replaces characters in text with the corresponding charac-
178: ters from replacements. If the replacements is absent or
179: too short, replace characters with a null character. Value
180: is text with specified replacements.
181:
182: uunnddeeffiinnee(_m_a_c_r_o)
183: Remove macro definition. Value is null. If a predefined
184: macro is redefined, its original definition is irrecoverably
185: lost.
186:
187: uunnddiivveerrtt[(_s_t_r_e_a_m[,...])]
188: Dumps each specified stream into the current output stream.
189: With no arguments, undivert dumps all output streams in
190: numeric order. m4 will not dump any output stream into it-
191: self. At the end of processing, m4 automatically dumps all
192: diverted text to standard output in numeric order. Value is
193: null.
194:
195:
196: COHERENT Lexicon Page 3
197:
198:
199:
200:
201: m4 Command m4
202:
203:
204:
205:
206: ***** See Also *****
207:
208: commands, mktemp, system
209: _I_n_t_r_o_d_u_c_t_i_o_n _t_o _t_h_e _m_4 _M_a_c_r_o _P_r_o_c_e_s_s_o_r
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262: COHERENT Lexicon Page 4
263:
264:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.