]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/mk-string-arrays.awk
SourceFormat Enforcement
[thirdparty/squid.git] / src / mk-string-arrays.awk
index 42133a3f5cecd1089c4c41a4b43e67966a6996e6..197eb9bb3f263e401bbb68eb3ec934713eedfa6c 100644 (file)
@@ -1,3 +1,10 @@
+## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+##
+## Squid software is distributed under GPLv2+ license and includes
+## contributions from numerous individuals and organizations.
+## Please see the COPYING and CONTRIBUTORS files for details.
+##
+
 # tested with gawk, mawk, and nawk.
 # drop-in replacement for mk-string-arrays.pl.
 # creates "enum.c" (on stdout) from "enum.h".
@@ -14,14 +21,14 @@ BEGIN {
        print "/*"
        print " * Auto-Generated File. Changes will be destroyed."
        print " */"
-       print "#include \"config.h\""
+       print "#include \"squid.h\""
         codeSkip = 1
         e = 0
         nspath = ""
 }
 
 # when namespace is encountered store it
-/^namespace [a-zA-Z]+/ {
+/^namespace *[a-zA-Z]+/        {
        nspath = tolower($2) "/"                # nested folder
        namespace = $2                          # code namespace reconstruct
        next
@@ -33,7 +40,15 @@ codeSkip == 1                { next }
 
 /^[ \t]*[A-Z]/ {
        split($1, t, ",")                       # remove ,
-       Element[++e] = t[1]
+       if (sbuf) Element[++e] = "SBuf(\"" t[1] "\")"
+       else Element[++e] = "\"" t[1] "\""
+       next
+}
+
+/^#/ {
+       if (codeSkip) next
+
+       Wrapper[++e] = $0
        next
 }
 
@@ -42,16 +57,20 @@ codeSkip == 1               { next }
        type = t[1]
         codeSkip = 1
 
+       if (sbuf) print "#include \"SBuf.h\""
        print "#include \"" nspath type ".h\""
 
        # if namesapce is not empty ??
        if (namespace) print "namespace " namespace
        if (namespace) print "{"
 
-       print "\nconst char *" type "_str[] = {"
+       if (sbuf) print "\nconst SBuf " type "_sb[] = {"
+       else print "\nconst char * " type "_str[] = {"
        for ( i = 1; i < e; ++i)
-               print "\t\"" Element[i] "\","
-       print "\t\"" Element[i] "\""
+               if (Wrapper[i]) print Wrapper[i]
+               else print "\t" Element[i] ","
+
+       print "\t" Element[i]
        print "};"
        if (namespace) print "}; // namespace " namespace
        next