PageRenderTime 62ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/srclib/apr/build/make_var_export.awk

https://bitbucket.org/gencer/apache2nginx
AWK | 59 lines | 51 code | 6 blank | 2 comment | 0 complexity | 0f15daa748501970b84930e7b7d0157c MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
  1. # Based on apr's make_export.awk, which is
  2. # based on Ryan Bloom's make_export.pl
  3. /^#[ \t]*if(def)? (AP[RUI]?_|!?defined).*/ {
  4. if (old_filename != FILENAME) {
  5. if (old_filename != "") printf("%s", line)
  6. macro_no = 0
  7. found = 0
  8. count = 0
  9. old_filename = FILENAME
  10. line = ""
  11. }
  12. macro_stack[macro_no++] = macro
  13. macro = substr($0, length($1)+2)
  14. count++
  15. line = line "#ifdef " macro "\n"
  16. next
  17. }
  18. /^#[ \t]*endif/ {
  19. if (count > 0) {
  20. count--
  21. line = line "#endif /* " macro " */\n"
  22. macro = macro_stack[--macro_no]
  23. }
  24. if (count == 0) {
  25. if (found != 0) {
  26. printf("%s", line)
  27. }
  28. line = ""
  29. }
  30. next
  31. }
  32. function add_symbol (sym_name) {
  33. if (count) {
  34. found++
  35. }
  36. for (i = 0; i < count; i++) {
  37. line = line "\t"
  38. }
  39. line = line sym_name "\n"
  40. if (count == 0) {
  41. printf("%s", line)
  42. line = ""
  43. }
  44. }
  45. /^[ \t]*(extern[ \t]+)?AP[RUI]?_DECLARE_DATA .*;$/ {
  46. varname = $NF;
  47. gsub( /[*;]/, "", varname);
  48. gsub( /\[.*\]/, "", varname);
  49. add_symbol(varname);
  50. }
  51. END {
  52. printf("%s", line)
  53. }