PageRenderTime 55ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/build/make_var_export.awk

https://bitbucket.org/gencer/apache2nginx
AWK | 75 lines | 51 code | 6 blank | 18 comment | 0 complexity | 6d29b7ee48ee9e322aaa5796f6b8e632 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. #
  17. # Based on apr's make_export.awk, which is
  18. # based on Ryan Bloom's make_export.pl
  19. /^#[ \t]*if(def)? (AP[RU]?_|!?defined).*/ {
  20. if (old_filename != FILENAME) {
  21. if (old_filename != "") printf("%s", line)
  22. macro_no = 0
  23. found = 0
  24. count = 0
  25. old_filename = FILENAME
  26. line = ""
  27. }
  28. macro_stack[macro_no++] = macro
  29. macro = substr($0, length($1)+2)
  30. count++
  31. line = line "#ifdef " macro "\n"
  32. next
  33. }
  34. /^#[ \t]*endif/ {
  35. if (count > 0) {
  36. count--
  37. line = line "#endif /* " macro " */\n"
  38. macro = macro_stack[--macro_no]
  39. }
  40. if (count == 0) {
  41. if (found != 0) {
  42. printf("%s", line)
  43. }
  44. line = ""
  45. }
  46. next
  47. }
  48. function add_symbol (sym_name) {
  49. if (count) {
  50. found++
  51. }
  52. for (i = 0; i < count; i++) {
  53. line = line "\t"
  54. }
  55. line = line sym_name "\n"
  56. if (count == 0) {
  57. printf("%s", line)
  58. line = ""
  59. }
  60. }
  61. /^[ \t]*(extern[ \t]+)?AP[RU]?_DECLARE_DATA .*;$/ {
  62. varname = $NF;
  63. gsub( /[*;]/, "", varname);
  64. gsub( /\[.*\]/, "", varname);
  65. add_symbol(varname);
  66. }
  67. END {
  68. printf("%s", line)
  69. }