]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mk-globals-c.awk
CI: Remove unnecessary test-functionality test wrappers (#1393)
[thirdparty/squid.git] / src / mk-globals-c.awk
1 ## Copyright (C) 1996-2023 The Squid Software Foundation and contributors
2 ##
3 ## Squid software is distributed under GPLv2+ license and includes
4 ## contributions from numerous individuals and organizations.
5 ## Please see the COPYING and CONTRIBUTORS files for details.
6 ##
7
8 # tested with gawk, mawk, and nawk.
9 # modified to work with Solaris awk (junk).
10 # creates "globals.c" (on stdout) from "globals.h".
11 # when invoked: awk -f mk-globals-c.awk globals.h
12 #
13 # 2006 by Christopher Kerr.
14
15 BEGIN { Copyright = 0
16 print "#include \"squid.h\"" }
17
18 Copyright != 1 && /^ \*\/$/ { Copyright = 1; print; next }
19 Copyright != 1 { print; next }
20 /SQUID_GLOBALS_H/ { next }
21
22 # arrays defined elsewhere
23 /\[\];/ { next }
24
25 #
26 # Check exactly for lines beginning with " extern", generated
27 # from astyle (grrrrr ...)
28 #
29 /^ *extern / { # process "^extern " input lines.
30 # 0 1 2 #######
31 # extern int variable; /* val */ --> int variable; /* val */ #######
32 ##########################################################################
33 pos0 = index($0,"extern") #find how much whitespeace there is
34 str = substr($0,pos0,length($0))
35 len = length(str) - length("extern ") # sub(/extern /, "")
36 str = substr($0, length("extern ")+1, len) # strip "^extern ".
37
38 pos0 = index(str, ";") # position of ";".
39 pos1 = index(str, "/*") # position of "/*".
40 pos2 = index(str, "*/") # position of "*/".
41
42 if ( pos1 != 0 ) { # make assignment.
43
44 val = substr(str, pos1+3, pos2-pos1-4) # get comment value.
45 str = substr(str, 1, pos0-1) " = " val ";" # string to semi-colon.
46 }
47 print str; next # get next input line.
48 }
49 { print } # C preprocessor lines.