[master] 65e682328 Trivial refactor of generate.py
Nils Goroll
nils.goroll at uplex.de
Tue Feb 2 09:59:07 UTC 2021
commit 65e6823281c21e269088988bbb9013fbe597ea3a
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Feb 2 10:44:17 2021 +0100
Trivial refactor of generate.py
to split the output formattings from emit_file() from reading the file
The produced output lib/libvcc/vcc_fixed_token.c is identical
before/after.
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index b0668498b..94c13c000 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -431,21 +431,16 @@ def emit_vcl_tnames(fo, tokens):
#######################################################################
-def emit_file(fo, fd, bn):
- "Read a C-source file and spit out code that outputs it with VSB_cat()"
- fn = join(fd, bn)
-
- fi = open(fn)
- fc = fi.read()
- fi.close()
+def emit_strings(fo, name, fc):
+ "spit out code that outputs the fc iterable with VSB_cat()"
- w = 66 # Width of lines, after white space prefix
+ w = 66 # Width of lines, after white space prefix
maxlen = 10240 # Max length of string literal
x = 0
l = 0
- fo.write("\n\t/* %s */\n\n" % fn)
- fo.write('\tVSB_cat(sb, "/* ---===### %s ###===--- */\\n\\n");\n' % bn)
+
+ fo.write('\tVSB_cat(sb, "/* ---===### %s ###===--- */\\n\\n");\n' % name)
for c in fc:
if l == 0:
fo.write("\tVSB_cat(sb, \"")
@@ -488,6 +483,18 @@ def emit_file(fo, fd, bn):
fo.write("\t);\n")
fo.write('\tVSB_cat(sb, "\\n");\n')
+
+def emit_file(fo, fd, bn):
+ "Read a C-source file and spit out code that outputs it with VSB_cat()"
+ fn = join(fd, bn)
+
+ fi = open(fn)
+ fc = fi.read()
+ fi.close()
+
+ fo.write("\n\t/* %s */\n\n" % fn)
+ emit_strings(fo, bn, fc)
+
#######################################################################
More information about the varnish-commit
mailing list