summaryrefslogtreecommitdiff
path: root/fluid/code.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <git@matthiasm.com>2021-12-20 01:19:00 +0100
committerMatthias Melcher <github@matthiasm.com>2021-12-20 01:23:59 +0100
commit0d435d51aca65f76702369a1a7d389ee0e31e1e2 (patch)
tree1852658a6746459fc829a479059d3f8c2bb7738f /fluid/code.cxx
parente8961f10b87290ce9a0b9efc1a0439760b3b2e60 (diff)
GitHub #328: removed stray ';' in Fluid code generation.
Diffstat (limited to 'fluid/code.cxx')
-rw-r--r--fluid/code.cxx24
1 files changed, 18 insertions, 6 deletions
diff --git a/fluid/code.cxx b/fluid/code.cxx
index d6b4bdc38..da40970bf 100644
--- a/fluid/code.cxx
+++ b/fluid/code.cxx
@@ -384,12 +384,20 @@ void write_c(const char* format,...) {
/**
Write code (c) of size (n) to C file, with optional comment (com) w/o trailing space.
+ if the code line does not end in a ';' or '}', a ';' will be added.
+ \param[in] indent indentation string for all lines
+ \param[in] n number of bytes in code line
+ \param[in] c line of code
+ \param[in] com optional commentary
*/
void write_cc(const char *indent, int n, const char *c, const char *com) {
+ write_c("%s%.*s", indent, n, c);
+ char cc = c[n-1];
+ if (cc!='}' && cc!=';')
+ write_c(";");
if (*com)
- write_c("%s%.*s; %s\n", indent, n, c, com);
- else
- write_c("%s%.*s;\n", indent, n, c);
+ write_c(" %s", com);
+ write_c("\n");
}
/**
@@ -406,16 +414,20 @@ void write_h(const char* format,...) {
/**
Write code (c) of size (n) to H file, with optional comment (com) w/o trailing space.
+ if the code line does not end in a ';' or '}', a ';' will be added.
\param[in] indent indentation string for all lines
\param[in] n number of bytes in code line
\param[in] c line of code
\param[in] com optional commentary
*/
void write_hc(const char *indent, int n, const char* c, const char *com) {
+ write_h("%s%.*s", indent, n, c);
+ char cc = c[n-1];
+ if (cc!='}' && cc!=';')
+ write_h(";");
if (*com)
- write_h("%s%.*s; %s\n", indent, n, c, com);
- else
- write_h("%s%.*s;\n", indent, n, c);
+ write_h(" %s", com);
+ write_h("\n");
}
/**