Source code of Windows XP (NT5)
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.

95 lines
2.2 KiB

  1. # This awk script will take the horrendously #ifdefed reference implementation
  2. # stuff and turn it into something we can hand off to ISVs.
  3. #
  4. # Things that should be added to this script:
  5. # Remove CALLHOOKOBJECT calls
  6. # Remove DIR_CLASS, FAT_CLASS, MSTREAM_CLASS, etc #defined keywords
  7. # Remove HUGEP
  8. #
  9. BEGIN {
  10. nestlevel = 0;
  11. foo[nestlevel] = 0;
  12. display[nestlevel] = 1;
  13. RS = "\n";
  14. FS = "\n";
  15. Exclude_list = "(REF)|(CODESEGMENTS)|(INTERNAL_EXCLUSION_ALLOWED)|(EMPTYCOPYTO)|(OLDPROPS)|(CFS_SECURE)|(_M_I286)|(CHKDSK)|(DELAYCONVERT)|(INDINST)|(OLDPROP)";
  16. Include_list = "(OLEWIDECHAR)|(WIN32)|(USE_NOSNAPSHOT)|(USE_NOSCRATCH)|(FLAT)|(DIFAT_OPTIMIZATIONS)|(USE_NEW_GETFREE)|(SECURE)|(CACHE_ALLOCATE_OPTIMIZATION)|(SORTPAGETABLE)|(OPTIMIZE_LOOKUP)|(OPTIMIZE_FIXUP)|(DIFAT_LOOKUP_ARRAY)";
  17. Exclude_regexp = "(^#ifndef (" Exclude_list ")$)|(^#ifdef (" Include_list ")$)";
  18. Include_regexp = "(^#ifndef (" Include_list ")$)|(^#ifdef (" Exclude_list ")$)";
  19. }
  20. # #defines to include go here
  21. #/(^#ifndef ((REF)|(CODESEGMENTS)))|(^#ifdef ((OLEWIDECHAR)|(WIN32)))/ {
  22. #/ $(Exclude_regexp) / {
  23. $0 ~ Exclude_regexp {
  24. nestlevel++;
  25. foo[nestlevel] = 1;
  26. display[nestlevel] = display[nestlevel - 1];
  27. next;
  28. }
  29. # #defines to exclude go here
  30. #/(^#ifdef ((REF)|(CODESEGMENTS)))|(^#ifndef ((OLEWIDECHAR)|(WIN32)))/ {
  31. #/ $(Include_regexp) / {
  32. $0 ~ Include_regexp {
  33. nestlevel++;
  34. foo[nestlevel] = 1;
  35. display[nestlevel] = 0;
  36. next;
  37. }
  38. /^#if/ {
  39. if (nestlevel != 0)
  40. {
  41. nestlevel++;
  42. foo[nestlevel] = 0;
  43. display[nestlevel] = display[nestlevel - 1];
  44. }
  45. }
  46. /^#else/ {
  47. if (foo[nestlevel])
  48. {
  49. display[nestlevel] = !display[nestlevel];
  50. if (display[nestlevel - 1] == 0)
  51. {
  52. display[nestlevel] = 0;
  53. }
  54. next;
  55. }
  56. }
  57. #/#pragma hdrstop/ {next;}
  58. #/History:/,/(Notes:)|(\/\/-------)/ {
  59. # if (($0 ~ /(Notes:)|(\/\/-----)/) && (display[nestlevel]))
  60. # {
  61. # print $0;
  62. # }
  63. # next;
  64. #}
  65. /^#endif/ {
  66. if (nestlevel > 0) {
  67. nestlevel--;
  68. if (foo[nestlevel + 1] == 1)
  69. next;
  70. }
  71. }
  72. {
  73. if (display[nestlevel])
  74. {
  75. print;
  76. }
  77. }