dnl --------------------------------------------------------------------------- dnl dnl This file contains general m4 utilities. dnl dnl Copyright (C) Microsoft Corporation, 1997. dnl dnl --------------------------------------------------------------------------- dnl dnl ///////////////////////////////////////////////////////////////////////// dnl Begin long m4 comment define(d_bcom, `divert(-1)dnl')dnl dnl dnl End long m4 comment define(d_ecom, `divert(0)dnl')dnl dnl d_bcom //////////////////////////////////////////////////////////////////////// Redefine m4 intrinsics with useful names d_ecom //////////////////////////////////////////////////////////////////////// define(d_shift, defn(`shift'))dnl undefine(`shift')dnl dnl define(d_len, defn(`len'))dnl undefine(`len')dnl dnl define(d_index, defn(`index'))dnl undefine(`index')dnl dnl d_bcom //////////////////////////////////////////////////////////////////////// Some useful generic macros d_ecom //////////////////////////////////////////////////////////////////////// define(d_Null, `$1')dnl Put the argument back on the macro evaluation stack define(d_Debug, `<$1><$2><$3><$4><$5>')dnl See what the arguments are (for debug) dnl d_bcom d_Rep ------------------------------------------------------------------ Purpose: Repeat $1 tabbed and on a new line $2 times Arguments: line to be repeated in $1, one based count in $2 d_ecom ------------------------------------------------------------------------ define(d_Rep, `$1 ifelse(eval($2 == 1), `1', `', `d_Rep(`$1', decr($2))')')dnl dnl d_bcom d_Repi ----------------------------------------------------------------- Purpose: Repeat with a count Arguments: line to be repeated in $1, key in $2, begin count in $3, end count in $4 Notes: Key must consist of characters not in string d_ecom ------------------------------------------------------------------------ define(d_Repi, `patsubst(`$1', `$2', `$3') ifelse(`$3', `$4', `', `d_Repi(`$1', `$2', incr($3), $4)')')dnl dnl d_bcom d_RepStr --------------------------------------------------------------- Purpose: Repeat with string substitution Arguments line to be repeated in $1, key in $2, strings to substitute for key in $3, $4, ... Notes: Key must consist of characters not in string d_ecom ------------------------------------------------------------------------ define(d_RepStr, `patsubst(`$1', `$2', `$3')dnl ifelse(`$#', 3, `', `d_RepStr(`$1', `$2', d_shift(d_shift(d_shift($@))))')')dnl dnl d_bcom d_UpCase --------------------------------------------------------------- Purpose: Makes argument all upper case Arguments: String in $1 d_ecom ------------------------------------------------------------------------ define(d_UpCase, `translit(`$1', `abcdefghijklmnopqrstuvwxyz', `ABCDEFGHIJKLMNOPQRSTUVWXYZ')')dnl dnl d_bcom d_ErrPrint ------------------------------------------------------------- Purpose: Put error string both in file and to stderr Arguments String in $1 Notes: d_ecom ------------------------------------------------------------------------ define(d_ErrPrint, `errprint(`m4 macro error: <$1>')'`m4 macro error: <$1>')dnl dnl d_bcom d_Nth1------------------------------------------------------------------ Purpose: Expands to n'th argument after n, one-based. Arguments Count in $1 followed by arguments. d_ecom ------------------------------------------------------------------------ define(`d_Nth1', `ifelse(eval($1 <= 1), `1', `$2', `d_Nth1(decr($1), d_shift(d_shift($@)))')')dnl