[BACK]Return to m4.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / m4

Diff for /src/usr.bin/m4/m4.1 between version 1.9 and 1.10

version 1.9, 2000/01/11 14:06:11 version 1.10, 2000/03/10 19:07:20
Line 26 
Line 26 
 Macro calls have the form name(argument1[, argument2, ..., argumentN]).  Macro calls have the form name(argument1[, argument2, ..., argumentN]).
 .Pp  .Pp
 There cannot be any space following the macro name and the open  There cannot be any space following the macro name and the open
 parenthesis '('.  If the macro name is not followed by an open  parenthesis
   .Pq Ql ( .
   If the macro name is not followed by an open
 parenthesis it is processed with no arguments.  parenthesis it is processed with no arguments.
 .Pp  .Pp
 Macro names consist of a leading alphabetic or underscore  Macro names consist of a leading alphabetic or underscore
 possibly followed by alphanumeric or underscore characters, e.g.,  possibly followed by alphanumeric or underscore characters, e.g.,
 valid macro names match the pattern [a-zA-Z_][a-zA-Z0-9_]*.  valid macro names match the pattern
   .Dq [a-zA-Z_][a-zA-Z0-9_]* .
 .Pp  .Pp
 In arguments to macros, leading unquoted space, tab and newline  In arguments to macros, leading unquoted space, tab, and newline
 characters are ignored.  To quote strings, use left and right single  .Pq Ql \en
 quotes (e.g., ` this is a string with a leading space').  You can change  characters are ignored.
 the quote characters with the  To quote strings, use left and right single
   quotes (e.g.,
   .Sq \ this is a string with a leading space ) .
   You can change the quote characters with the
 .Ic changequote  .Ic changequote
 built-in macro.  built-in macro.
 .Pp  .Pp
Line 50 
Line 56 
 .Oc  .Oc
 Define the symbol  Define the symbol
 .Ar name  .Ar name
 to have some value (or NULL).  to have some value (or
   .Dv NULL ) .
 .It Fl "U" Ns Ar "name"  .It Fl "U" Ns Ar "name"
 Undefine the symbol  Undefine the symbol
 .Ar name .  .Ar name .
Line 60 
Line 67 
 to the include path.  to the include path.
 .Sh SYNTAX  .Sh SYNTAX
 .Nm m4  .Nm m4
 provides the following built-in macros.  They may be  provides the following built-in macros.
 redefined, losing their original meaning.  They may be redefined, losing their original meaning.
 Return values are NULL unless otherwise stated.  Return values are null unless otherwise stated.
 .Bl -tag -width changequotexxx  .Bl -tag -width changequotexxx
 .It Ic changecom  .It Ic changecom
 Change the start and end comment sequences.  The default is  Change the start and end comment sequences.
 the pound sign `#' and the newline character.  With no arguments  The default is the pound sign
 comments are turned off.  The maximum length for a comment marker is  .Pq Ql #
 five characters.  and the newline character.
   With no arguments comments are turned off.
   The maximum length for a comment marker is five characters.
 .It Ic changequote  .It Ic changequote
 Defines the quote symbols to be the first and second arguments.  Defines the quote symbols to be the first and second arguments.
 The symbols may be up to five characters long.  If no arguments are  The symbols may be up to five characters long.
   If no arguments are
 given it restores the default open and close single quotes.  given it restores the default open and close single quotes.
 .It Ic decr  .It Ic decr
 Decrements the argument by 1.  The argument must be a valid numeric string.  Decrements the argument by 1.
   The argument must be a valid numeric string.
 .It Ic define  .It Ic define
 Define a new macro named by the first argument to have the  Define a new macro named by the first argument to have the
 value of the second argument.  Each occurrence of $n (where n  value of the second argument.
 is 0 through 9) is replaced by the n'th argument.  $0 is the name  Each occurrence of
 of the calling macro.  Undefined arguments are replaced by a  .Ql $n
 NULL string.  $# is replaced by the number of arguments; $*  (where
 is replaced by all arguments comma separated; $@ is the same  .Ar n
 as $* but all arguments are quoted against further expansion.  is 0 through 9) is replaced by the
   .Ar n Ns 'th
   argument.
   .Ql $0
   is the name of the calling macro.
   Undefined arguments are replaced by a null string.
   .Ql $#
   is replaced by the number of arguments;
   .Ql $*
   is replaced by all arguments comma separated;
   .Ql $@
   is the same as
   .Ql $*
   but all arguments are quoted against further expansion.
 .It Ic defn  .It Ic defn
 Returns the quoted definition for each argument.  This can be used to rename  Returns the quoted definition for each argument.
   This can be used to rename
 macro definitions (even for built-in macros).  macro definitions (even for built-in macros).
 .It Ic divert  .It Ic divert
 There are 10 output queues (numbered 0-9).  There are 10 output queues (numbered 0-9).
 At the end of processing  At the end of processing
 .Nm m4  .Nm m4
 concatenates all the queues in numerical order to produce the  concatenates all the queues in numerical order to produce the
 final output.  Initially the output queue is 0.  The divert  final output.
   Initially the output queue is 0.
   The divert
 macro allows you to select a new output queue (an invalid argument  macro allows you to select a new output queue (an invalid argument
 passed to divert causes output to be discarded).  passed to divert causes output to be discarded).
 .It Ic divnum  .It Ic divnum
Line 105 
Line 132 
 Prints the first argument on the standard error output stream.  Prints the first argument on the standard error output stream.
 .It Ic eval  .It Ic eval
 Computes the first argument as an arithmetic expression using 32-bit  Computes the first argument as an arithmetic expression using 32-bit
 arithmetic.  Operators are the standard C ternary, arithmetic, logical,  arithmetic.
 shift, relational, bitwise, and parentheses operators.  You can specify  Operators are the standard C ternary, arithmetic, logical,
 octal, decimal, and hexadecimal numbers as in C.  The second argument (if  shift, relational, bitwise, and parentheses operators.
 any) specifies the radix for the result and the third argument (if  You can specify
 any) specifies the minimum number of digits in the result.  octal, decimal, and hexadecimal numbers as in C.
   The second argument (if any)
   specifies the radix for the result and the third argument (if any)
   specifies the minimum number of digits in the result.
 .It Ic expr  .It Ic expr
 This is an alias for  This is an alias for
 .Ic eval .  .Ic eval .
 .It Ic ifdef  .It Ic ifdef
 If the macro named by the first argument is defined then return the second  If the macro named by the first argument is defined then return the second
 argument, otherwise the third.  If there is no third argument,  argument, otherwise the third.
 the value is NULL.  The word `unix' is predefined.  If there is no third argument, the value is
   .Dv NULL .
   The word
   .Qq unix
   is predefined.
 .It Ic ifelse  .It Ic ifelse
 If the first argument matches the second argument then  If the first argument matches the second argument then
 .Ic ifelse  .Ic ifelse
 returns  returns
 the third argument.  If the match fails the three arguments are  the third argument.
   If the match fails the three arguments are
 discarded and the next three arguments are used until there is  discarded and the next three arguments are used until there is
 zero or one arguments left, either this last argument or NULL is  zero or one arguments left, either this last argument or
 returned if no other matches were found.  .Dv NULL
   is returned if no other matches were found.
 .It Ic include  .It Ic include
 Returns the contents of the file specified in the first argument.  Returns the contents of the file specified in the first argument.
 If the file is not found as is, look through the include path:  If the file is not found as is, look through the include path:
 first the directories specified with  first the directories specified with
 .Fl I  .Fl I
 on the command line, then the environment variable  on the command line, then the environment variable
 .Va M4PATH ,  .Ev M4PATH ,
 as a colon-separated list of directories.  as a colon-separated list of directories.
 Include aborts with an error message if the file cannot be included.  Include aborts with an error message if the file cannot be included.
 .It Ic incr  .It Ic incr
 Increments the argument by 1.  The argument must be a valid numeric string.  Increments the argument by 1.
   The argument must be a valid numeric string.
 .It Ic index  .It Ic index
 Returns the index of the second argument in the first argument (e.g.,  Returns the index of the second argument in the first argument (e.g.,
 index(the quick brown fox jumped, fox) returns 16).  If the second  .Ic index(the quick brown fox jumped, fox)
 argument is not found index returns -1.  returns 16).
   If the second
   argument is not found index returns \-1.
 .It Ic len  .It Ic len
 Returns the number of characters in the first argument.  Extra arguments  Returns the number of characters in the first argument.
   Extra arguments
 are ignored.  are ignored.
 .It Ic m4exit  .It Ic m4exit
 Immediately exits with the return value specified by the first argument,  Immediately exits with the return value specified by the first argument,
 0 if none.  0 if none.
 .It Ic m4wrap  .It Ic m4wrap
 Allows you to define what happens at the final EOF, usually for cleanup  Allows you to define what happens at the final
 purposes (e.g., m4wrap("cleanup(tempfile)") causes the macro cleanup to be  .Dv EOF ,
   usually for cleanup purposes (e.g.,
   .Ic m4wrap("cleanup(tempfile)")
   causes the macro cleanup to be
 invoked after all other processing is done.)  invoked after all other processing is done.)
 .It Ic maketemp  .It Ic maketemp
 Translates the string XXXXX in the first argument with the current process  Translates the string
 ID leaving other characters alone.  This can be used to create unique  .Dq XXXXX
   in the first argument with the current process
   ID leaving other characters alone.
   This can be used to create unique
 temporary file names.  temporary file names.
 .It Ic paste  .It Ic paste
 Includes the contents of the file specified by the first argument without  Includes the contents of the file specified by the first argument without
 any macro processing.  Aborts with an error message if the file cannot be  any macro processing.
   Aborts with an error message if the file cannot be
 included.  included.
 .It Ic popdef  .It Ic popdef
 Restores the  Restores the
Line 170 
Line 217 
 .Ic popdef .  .Ic popdef .
 .It Ic shift  .It Ic shift
 Returns all but the first argument, the remaining arguments are  Returns all but the first argument, the remaining arguments are
 quoted and pushed back with commas in between.  The quoting  quoted and pushed back with commas in between.
   The quoting
 nullifies the effect of the extra scan that will subsequently be  nullifies the effect of the extra scan that will subsequently be
 performed.  performed.
 .It Ic sinclude  .It Ic sinclude
Line 186 
Line 234 
 by the second argument and the length specified by the third argument.  by the second argument and the length specified by the third argument.
 If no third argument is present it returns the rest of the string.  If no third argument is present it returns the rest of the string.
 .It Ic syscmd  .It Ic syscmd
 Passes the first argument to the shell.  Nothing is returned.  Passes the first argument to the shell.
   Nothing is returned.
 .It Ic sysval  .It Ic sysval
 Returns the return value from the last  Returns the return value from the last
 .Ic syscmd .  .Ic syscmd .
 .It Ic translit  .It Ic translit
 Transliterate the characters in the first argument from the set  Transliterate the characters in the first argument from the set
 given by the second argument to the set given by the third.  You cannot  given by the second argument to the set given by the third.
   You cannot
 use  use
 .Xr tr 1  .Xr tr 1
 style abbreviations.  style abbreviations.

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10