Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
3.6 KiB

  1. dnl ---------------------------------------------------------------------------
  2. dnl
  3. dnl This file contains general m4 utilities.
  4. dnl
  5. dnl Copyright (C) Microsoft Corporation, 1997.
  6. dnl
  7. dnl ---------------------------------------------------------------------------
  8. dnl
  9. dnl /////////////////////////////////////////////////////////////////////////
  10. dnl Begin long m4 comment
  11. define(d_bcom, `divert(-1)dnl')dnl
  12. dnl
  13. dnl End long m4 comment
  14. define(d_ecom, `divert(0)dnl')dnl
  15. dnl
  16. d_bcom ////////////////////////////////////////////////////////////////////////
  17. Redefine m4 intrinsics with useful names
  18. d_ecom ////////////////////////////////////////////////////////////////////////
  19. define(d_shift, defn(`shift'))dnl
  20. undefine(`shift')dnl
  21. dnl
  22. define(d_len, defn(`len'))dnl
  23. undefine(`len')dnl
  24. dnl
  25. define(d_index, defn(`index'))dnl
  26. undefine(`index')dnl
  27. dnl
  28. d_bcom ////////////////////////////////////////////////////////////////////////
  29. Some useful generic macros
  30. d_ecom ////////////////////////////////////////////////////////////////////////
  31. define(d_Null, `$1')dnl Put the argument back on the macro evaluation stack
  32. define(d_Debug, `<$1><$2><$3><$4><$5>')dnl See what the arguments are (for debug)
  33. dnl
  34. d_bcom d_Rep ------------------------------------------------------------------
  35. Purpose: Repeat $1 tabbed and on a new line $2 times
  36. Arguments: line to be repeated in $1, one based count in $2
  37. d_ecom ------------------------------------------------------------------------
  38. define(d_Rep, `$1
  39. ifelse(eval($2 == 1), `1', `', `d_Rep(`$1', decr($2))')')dnl
  40. dnl
  41. d_bcom d_Repi -----------------------------------------------------------------
  42. Purpose: Repeat with a count
  43. Arguments: line to be repeated in $1, key in $2, begin count in $3,
  44. end count in $4
  45. Notes: Key must consist of characters not in string
  46. d_ecom ------------------------------------------------------------------------
  47. define(d_Repi, `patsubst(`$1', `$2', `$3')
  48. ifelse(`$3', `$4', `', `d_Repi(`$1', `$2', incr($3), $4)')')dnl
  49. dnl
  50. d_bcom d_RepStr ---------------------------------------------------------------
  51. Purpose: Repeat with string substitution
  52. Arguments line to be repeated in $1, key in $2, strings to substitute
  53. for key in $3, $4, ...
  54. Notes: Key must consist of characters not in string
  55. d_ecom ------------------------------------------------------------------------
  56. define(d_RepStr, `patsubst(`$1', `$2', `$3')dnl
  57. ifelse(`$#', 3, `', `d_RepStr(`$1', `$2', d_shift(d_shift(d_shift($@))))')')dnl
  58. dnl
  59. d_bcom d_UpCase ---------------------------------------------------------------
  60. Purpose: Makes argument all upper case
  61. Arguments: String in $1
  62. d_ecom ------------------------------------------------------------------------
  63. define(d_UpCase, `translit(`$1', `abcdefghijklmnopqrstuvwxyz', `ABCDEFGHIJKLMNOPQRSTUVWXYZ')')dnl
  64. dnl
  65. d_bcom d_ErrPrint -------------------------------------------------------------
  66. Purpose: Put error string both in file and to stderr
  67. Arguments String in $1
  68. Notes:
  69. d_ecom ------------------------------------------------------------------------
  70. define(d_ErrPrint, `errprint(`m4 macro error: <$1>')'`m4 macro error: <$1>')dnl
  71. dnl
  72. d_bcom d_Nth1------------------------------------------------------------------
  73. Purpose: Expands to n'th argument after n, one-based.
  74. Arguments Count in $1 followed by arguments.
  75. d_ecom ------------------------------------------------------------------------
  76. define(`d_Nth1', `ifelse(eval($1 <= 1), `1', `$2',
  77. `d_Nth1(decr($1), d_shift(d_shift($@)))')')dnl