Programming Utilities Guide

Summary of Built-In m4 Macros

Table 6-1 Summary of Built-In m4 Macros

Built-In m4 Macros 

Description  

changequote(L, R)

Change left quote to L, right quote to R.

changecom

Change left and right comment markers from the default # and newline. 

decr

Return the value of the argument decremented by 1.  

define(name, stuff)

Define name as stuff.

defn(`name')

Return the quoted definition of the argument(s)  

divert(number)

Divert output to stream number

divnum

Return number of currently active diversions  

dnl

Delete up to and including newline  

dumpdef(`name', `name', . . .)

Dump specified definitions.  

errprint(s, s, . . .)

Write arguments s to standard error.

eval(numeric expression)

Evaluate numeric expression.

ifdef(`name', true string, false string)

Return true string if name is defined, false string if name is not defined.

ifelse(a, b, c, d)

If a and b are equal, return c, else return d.

include(file)

Include contents of file.  

incr(number)

Increment number by 1.  

index(s1, s2)

Return position in s1 where s2 occurs, or -1 if s2 does not work.

len(string)

Return length of string.

maketemp(. . .XXXXX. . .)

Make a temporary file.  

m4 exit

Cause immediate exit from m4.

m4 wrap

Argument 1 will be returned to the input stream at final EOF.

popdef

Remove current definition of argument(s).  

pushdef

Save any previous definition (similar to define())

shift

Return all but first argument(s)  

sinclude(file)

Include contents of file -- ignore and continue if file not found  

substr(string, position, number)

Return substring of string starting at position and number characters long

syscmd(command)

Run command in the system  

sysval

Return code from the last call to syscmd()

traceoff

Turn off trace globally and for any macros specified  

traceon

Turn on tracing for all macros, or with arguments, turn on tracing for named macros  

translit(string, from, to)

Transliterate characters in string from the set specified by from to the set specified by to

undefine(`name')

Remove name from the list of definitions  

undivert(number, number,. . .)

Append diversion number to the current diversion