summaryrefslogtreecommitdiff
path: root/jsongen.py.in
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-04-18 17:02:27 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-04-18 17:02:27 -0400
commit6fb031b70a114f352d59b0bb57a65c270fc9684b (patch)
tree5c930cbcffff2e2d391bf51d79b4011b5a8c78b5 /jsongen.py.in
parent87a2c417db34c8b7e767723224ec959272c8ba21 (diff)
downloadgpsd-6fb031b70a114f352d59b0bb57a65c270fc9684b.tar.gz
Avoid emitting trailing comma without following member in a struct initializer.
Some compilers (suncc, clang) dislike these.
Diffstat (limited to 'jsongen.py.in')
-rw-r--r--jsongen.py.in18
1 files changed, 10 insertions, 8 deletions
diff --git a/jsongen.py.in b/jsongen.py.in
index bf080c23..ac2616b4 100644
--- a/jsongen.py.in
+++ b/jsongen.py.in
@@ -404,14 +404,15 @@ stringspec = ""
def generate(spec):
global outboard
+ report = ""
for (attr, itype, default) in spec["fieldmap"]:
if attr in spec.get("stringbuffered", []):
if attr not in outboard:
- print " char %s[JSON_VAL_MAX+1];" % attr
+ report += " char %s[JSON_VAL_MAX+1];\n" % attr
outboard.append(attr)
- print " const struct json_attr_t %s[] = {" % spec["initname"]
+ report += " const struct json_attr_t %s[] = {\n" % spec["initname"]
if "header" in spec:
- print spec["header"]
+ report += spec["header"] + "\n"
for (attr, itype, default) in spec["fieldmap"]:
structname = spec["structname"]
if itype == "string":
@@ -424,18 +425,19 @@ def generate(spec):
target = structname + "." + attr
if "." in attr:
attr = attr[attr.rfind(".")+1:]
- print '\t{"%s",%st_%s,%s.addr.%s = %s%s,' % \
+ report += '\t{"%s",%st_%s,%s.addr.%s = %s%s,\n' % \
(attr, " "*(14-len(attr)), itype, " "*(10-len(itype)), itype, deref, target)
leader = " " * 39
if itype == "string":
- print leader + ".len = sizeof(%s)}," % target
+ report += leader + ".len = sizeof(%s)},\n" % target
else:
- print leader + ".dflt.%s = %s}," % (itype, default)
+ report += leader + ".dflt.%s = %s},\n" % (itype, default)
- print """\
- {NULL},
+ report += """\
+ {NULL}
};
"""
+ print report
# No code for generating dump functions yet.
# When we do this, remembeer that we have to suppress dump function