bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / build / make_var_export.awk
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
20 /^#[ \t]*if(def)? (AP[RU]?_|!?defined).*/ {
21         if (old_filename != FILENAME) {
22                 if (old_filename != "") printf("%s", line)
23                 macro_no = 0
24                 found = 0
25                 count = 0
26                 old_filename = FILENAME
27                 line = ""
28         }
29         macro_stack[macro_no++] = macro
30         macro = substr($0, length($1)+2)
31         count++
32         line = line "#ifdef " macro "\n"
33         next
34 }
35
36 /^#[ \t]*endif/ {
37         if (count > 0) {
38                 count--
39                 line = line "#endif /* " macro " */\n"
40                 macro = macro_stack[--macro_no]
41         }
42         if (count == 0) {
43                 if (found != 0) {
44                         printf("%s", line)
45                 }
46                 line = ""
47         }
48         next
49 }
50
51 function add_symbol (sym_name) {
52         if (count) {
53                 found++
54         }
55         for (i = 0; i < count; i++) {
56                 line = line "\t"
57         }
58         line = line sym_name "\n"
59
60         if (count == 0) {
61                 printf("%s", line)
62                 line = ""
63         }
64 }
65
66 /^[ \t]*(extern[ \t]+)?AP[RU]?_DECLARE_DATA .*;$/ {
67        varname = $NF;
68        gsub( /[*;]/, "", varname);
69        gsub( /\[.*\]/, "", varname);
70        add_symbol(varname);
71 }
72
73 END {
74         printf("%s", line)
75 }