Clean up some wuffs-c output (before clang-format)
diff --git a/cmd/wuffs-c/release.go b/cmd/wuffs-c/release.go
index 382d359..197a8b6 100644
--- a/cmd/wuffs-c/release.go
+++ b/cmd/wuffs-c/release.go
@@ -106,8 +106,8 @@
unformatted := bytes.NewBuffer(nil)
unformatted.WriteString("#ifndef WUFFS_INCLUDE_GUARD\n")
unformatted.WriteString("#define WUFFS_INCLUDE_GUARD\n\n")
- unformatted.WriteString(grSingleFileGuidance)
- unformatted.WriteString(grPragmaPush)
+ unformatted.WriteString(grSingleFileGuidance[1:]) // [1:] skips the initial '\n'.
+ unformatted.WriteString(grPragmaPush[1:]) // [1:] skips the initial '\n'.
h.seen = map[string]bool{}
for _, f := range h.filesList {
@@ -116,7 +116,7 @@
}
}
- unformatted.Write(grImplStartsHere)
+ unformatted.Write(grImplStartsHere[1:]) // [1:] skips the initial '\n'.
unformatted.WriteString("\n")
h.seen = map[string]bool{}
@@ -126,10 +126,9 @@
}
}
- unformatted.WriteString("\n")
unformatted.Write(grImplEndsHere)
unformatted.WriteString(grPragmaPop)
- unformatted.WriteString("\n\n#endif // WUFFS_INCLUDE_GUARD\n\n")
+ unformatted.WriteString("#endif // WUFFS_INCLUDE_GUARD\n")
if printTimings {
fmt.Fprintf(os.Stderr, "%8d milliseconds collecting the C code\n",
@@ -232,20 +231,20 @@
if i := bytes.Index(s, grImplStartsHere); i < 0 {
return fmt.Errorf("could not find %q in %s", grImplStartsHere, relFilename)
} else {
- f.fragments[0], s = s[:i], s[i+len(grImplStartsHere):]
+ f.fragments[0], s = bytes.TrimSpace(s[:i]), s[i+len(grImplStartsHere):]
}
if i := bytes.LastIndex(s, grImplEndsHere); i < 0 {
return fmt.Errorf("could not find %q in %s", grImplEndsHere, relFilename)
} else {
- f.fragments[1] = s[:i]
+ f.fragments[1] = bytes.TrimSpace(s[:i])
}
if relFilename == "wuffs-base.c" && (h.version != cf.Version{}) {
if subs, err := h.substituteWuffsVersion(f.fragments[0]); err != nil {
return err
} else {
- f.fragments[0] = subs
+ f.fragments[0] = bytes.TrimSpace(subs)
}
}
@@ -300,6 +299,7 @@
}
w.Write(f.fragments[which])
+ w.WriteString("\n\n")
h.seen[relFilename] = true
return nil
}
diff --git a/internal/cgen/cgen.go b/internal/cgen/cgen.go
index 0a580a5..b97a3e9 100644
--- a/internal/cgen/cgen.go
+++ b/internal/cgen/cgen.go
@@ -438,7 +438,7 @@
buf.writes("\n#ifdef __cplusplus\n")
buf.writes("#if __cplusplus >= 201103L\n")
- buf.printf("using unique_ptr = std::unique_ptr<wuffs_base__%s, decltype(&free)>;", n)
+ buf.printf("using unique_ptr = std::unique_ptr<wuffs_base__%s, decltype(&free)>;\n", n)
buf.writes("#endif\n\n")
for _, f := range builtInInterfaceMethods[qid] {