1 1 GNU M4 1 ****** 1 1 This manual (31 December 2016) is for GNU M4 (version 1.4.18), a package 1 containing an implementation of the m4 macro language. 1 1 Copyright (C) 1989-1994, 2004-2014, 2016 Free Software Foundation, 1 Inc. 1 1 Permission is granted to copy, distribute and/or modify this 1 document under the terms of the GNU Free Documentation License, 1 Version 1.3 or any later version published by the Free Software 1 Foundation; with no Invariant Sections, no Front-Cover Texts, and 1 no Back-Cover Texts. A copy of the license is included in the 1 section entitled "GNU Free Documentation License." 1 1 GNU 'm4' is an implementation of the traditional UNIX macro 1 processor. It is mostly SVR4 compatible, although it has some 1 extensions (for example, handling more than 9 positional parameters to 1 macros). 'm4' also has builtin functions for including files, running 1 shell commands, doing arithmetic, etc. Autoconf needs GNU 'm4' for 1 generating 'configure' scripts, but not for running them. 1 1 GNU 'm4' was originally written by Rene' Seindal, with subsequent 1 changes by Franc,ois Pinard and other volunteers on the Internet. All 1 names and email addresses can be found in the files 'm4-1.4.18/AUTHORS' 1 and 'm4-1.4.18/THANKS' from the GNU M4 distribution. 1 1 This is release 1.4.18. It is now considered stable: future releases 1 in the 1.4.x series are only meant to fix bugs, increase speed, or 1 improve documentation. However... 1 1 An experimental feature, which would improve 'm4' usefulness, allows 1 for changing the syntax for what is a "word" in 'm4'. You should use: 1 ./configure --enable-changeword 1 if you want this feature compiled in. The current implementation slows 1 down 'm4' considerably and is hardly acceptable. In the future, 'm4' 1 2.0 will come with a different set of new features that provide similar 1 capabilities, but without the inefficiencies, so changeword will go away 1 and _you should not count on it_. 1
1 · Preliminaries Introduction and preliminaries · Invoking m4 Invoking 'm4' · Syntax Lexical and syntactic conventions 1 · Macros How to invoke macros · Definitions How to define new macros · Conditionals Conditionals, loops, and recursion 1 · Debugging How to debug macros and input 1 · Input Control Input control · File Inclusion File inclusion · Diversions Diverting and undiverting output 1 · Text handling Macros for text handling · Arithmetic Macros for doing arithmetic · Shell commands Macros for running shell commands · Miscellaneous Miscellaneous builtin macros · Frozen files Fast loading of frozen state 1 · Compatibility Compatibility with other versions of 'm4' · Answers Correct version of some examples 1 · Copying This Package How to make copies of the overall M4 package · Copying This Manual How to make copies of this manual · Indices Indices of concepts and macros 1 1 -- The Detailed Node Listing -- 1 1 Introduction and preliminaries 1 · Intro Introduction to 'm4' · History Historical references · Bugs Problems and bugs · Manual Using this manual 1 1 Invoking 'm4' 1 · Operation modes Command line options for operation modes · Preprocessor features Command line options for preprocessor features · Limits control Command line options for limits control · Frozen state Command line options for frozen state · Debugging options Command line options for debugging · Command line files Specifying input files on the command line 1 1 Lexical and syntactic conventions 1 · Names Macro names · Quoted strings Quoting input to 'm4' · Comments Comments in 'm4' input · Other tokens Other kinds of input tokens · Input processing How 'm4' copies input to output 1 1 How to invoke macros 1 · Invocation Macro invocation · Inhibiting Invocation Preventing macro invocation · Macro Arguments Macro arguments · Quoting Arguments On Quoting Arguments to macros · Macro expansion Expanding macros 1 1 How to define new macros 1 · Define Defining a new macro · Arguments Arguments to macros · Pseudo Arguments Special arguments to macros · Undefine Deleting a macro · Defn Renaming macros · Pushdef Temporarily redefining macros 1 · Indir Indirect call of macros · Builtin Indirect call of builtins 1 1 Conditionals, loops, and recursion 1 · Ifdef Testing if a macro is defined · Ifelse If-else construct, or multibranch · Shift Recursion in 'm4' · Forloop Iteration by counting · Foreach Iteration by list contents · Stacks Working with definition stacks · Composition Building macros with macros 1 1 How to debug macros and input 1 · Dumpdef Displaying macro definitions · Trace Tracing macro calls · Debug Levels Controlling debugging output · Debug Output Saving debugging output 1 1 Input control 1 · Dnl Deleting whitespace in input · Changequote Changing the quote characters · Changecom Changing the comment delimiters · Changeword Changing the lexical structure of words · M4wrap Saving text until end of input 1 1 File inclusion 1 · Include Including named files · Search Path Searching for include files 1 1 Diverting and undiverting output 1 · Divert Diverting output · Undivert Undiverting output · Divnum Diversion numbers · Cleardivert Discarding diverted text 1 1 Macros for text handling 1 · Len Calculating length of strings · Index macro Searching for substrings · Regexp Searching for regular expressions · Substr Extracting substrings · Translit Translating characters · Patsubst Substituting text by regular expression · Format Formatting strings (printf-like) 1 1 Macros for doing arithmetic 1 · Incr Decrement and increment operators · Eval Evaluating integer expressions 1 1 Macros for running shell commands 1 · Platform macros Determining the platform · Syscmd Executing simple commands · Esyscmd Reading the output of commands · Sysval Exit status · Mkstemp Making temporary files 1 1 Miscellaneous builtin macros 1 · Errprint Printing error messages · Location Printing current location · M4exit Exiting from 'm4' 1 1 Fast loading of frozen state 1 · Using frozen files Using frozen files · Frozen file format Frozen file format 1 1 Compatibility with other versions of 'm4' 1 · Extensions Extensions in GNU M4 · Incompatibilities Facilities in System V m4 not in GNU M4 · Other Incompatibilities Other incompatibilities 1 1 Correct version of some examples 1 · Improved exch Solution for 'exch' · Improved forloop Solution for 'forloop' · Improved foreach Solution for 'foreach' · Improved copy Solution for 'copy' · Improved m4wrap Solution for 'm4wrap' · Improved cleardivert Solution for 'cleardivert' · Improved capitalize Solution for 'capitalize' · Improved fatal_error Solution for 'fatal_error' 1 1 How to make copies of the overall M4 package 1 · GNU General Public License License for copying the M4 package 1 1 How to make copies of this manual 1 · GNU Free Documentation License License for copying this manual 1 1 Indices of concepts and macros 1 · Macro index Index for all 'm4' macros · Concept index Index for many concepts 1 1