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.

41 lines
1.1 KiB

  1. #
  2. # This perl script takes a file from STDIN and includes only the code which is
  3. # defined(__cplusplus) && !defined(CINTERFACE).
  4. #
  5. # This code then removes the code between the #else and corresponding #endif
  6. #
  7. # This script also removes the extra lf which was put in by error on the lines
  8. # containing "#pragma once".
  9. #
  10. #
  11. # if defined(__cplusplus) && !defined(CINTERFACE)
  12. #
  13. # {Keep all code in this block}
  14. #
  15. # else /* C style interface */
  16. #
  17. # {Delete all code in this block}
  18. #
  19. # endif /* C style interface */
  20. #
  21. $DeleteLine = 0;
  22. while (<STDIN>) {
  23. if (/^#if\s+defined\(\_\_cplusplus\)\s+\&\&\s+\!defined\(CINTERFACE\)\s*$/) {
  24. ;
  25. } elsif (/^#else\s*\/\*\s*C\s+style\s+interface\s*\*\//) {
  26. $DeleteLine = 1;
  27. } elsif (/^#endif\s*\/\*\s*C\s+style\s+interface\s*\*\//) {
  28. $DeleteLine = 0;
  29. } elsif (/^#pragma\s+once\s*$/) {
  30. print split(/\r/,$_);
  31. print "\n";
  32. } elsif (!$DeleteLine) {
  33. print $_;
  34. }
  35. }