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.

73 lines
1.9 KiB

  1. // Macro.C - contains routines that have to do with macros
  2. //
  3. // Copyright (c) 1988-1991, Microsoft Corporation. All Rights Reserved.
  4. //
  5. // Purpose:
  6. // Contains routines that have to do with macros
  7. //
  8. // Revision History:
  9. // 16-May-1991 SB Created from routines that existed elsewhere
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. static STRINGLIST **lastMacroChain = NULL;
  13. // findMacro - look up a string in a hash table
  14. //
  15. // Look up a macro name in a hash table and return the entry
  16. // or NULL.
  17. // If a macro and undefined, return NULL.
  18. MACRODEF * findMacro(char *str)
  19. {
  20. unsigned n;
  21. char *L_string = str;
  22. STRINGLIST *found;
  23. if (*L_string) {
  24. for (n = 0; *L_string; n += *L_string++); //Hash
  25. n %= MAXMACRO;
  26. #if defined(STATISTICS)
  27. CntfindMacro++;
  28. #endif
  29. lastMacroChain = (STRINGLIST **)&macroTable[n];
  30. for (found = *lastMacroChain; found; found = found->next) {
  31. #if defined(STATISTICS)
  32. CntmacroChains++;
  33. #endif
  34. if (!_tcscmp(found->text, str)) {
  35. return((((MACRODEF *)found)->flags & M_UNDEFINED) ? NULL : (MACRODEF *)found);
  36. }
  37. }
  38. } else {
  39. // set lastMacroChain, even for an empty name
  40. lastMacroChain = (STRINGLIST **)&macroTable[0];
  41. }
  42. return(NULL);
  43. }
  44. // insertMacro
  45. //
  46. // Macro insertion requires that we JUST did a findMacro, which action set lastMacroChain.
  47. void insertMacro(STRINGLIST * p)
  48. {
  49. #ifdef STATISTICS
  50. CntinsertMacro++;
  51. #endif
  52. assert(lastMacroChain != NULL);
  53. prependItem(lastMacroChain, p);
  54. lastMacroChain = NULL;
  55. }
  56. // 16/May/92 Bryant Init the macro table to a known state before
  57. // continuing.
  58. void initMacroTable(MACRODEF *table[])
  59. {
  60. unsigned num;
  61. for (num = 0; num < MAXMACRO; num++) {
  62. table[num] = NULL;
  63. }
  64. }