aboutsummaryrefslogtreecommitdiff
path: root/file.go
diff options
context:
space:
mode:
Diffstat (limited to 'file.go')
-rw-r--r--file.go35
1 files changed, 25 insertions, 10 deletions
diff --git a/file.go b/file.go
index c98beb1..42bc245 100644
--- a/file.go
+++ b/file.go
@@ -269,29 +269,44 @@ func (f *file) apply(conv *SPDXConv) (err error) {
f.applyDelete(&conv.cfg)
+ // Write the license identifier ...
+
+ var line bytes.Buffer
+ if f.commentPrefix != `` {
+ line.WriteString(f.commentPrefix + ` `)
+ }
// REUSE-IgnoreStart
- line := fmt.Sprintf("%sSPDX-License-Identifier: %s%s",
- f.commentPrefix, f.licenseID, f.commentSuffix)
+ line.WriteString(`SPDX-License-Identifier: ` + f.licenseID)
// REUSE-IgnoreEnd
+ if f.commentSuffix != `` {
+ line.WriteString(` ` + f.commentSuffix)
+ }
- rawline := []byte(line)
if f.hasSheBang {
f.idxLicenseID = 1
} else {
f.idxLicenseID = 0
}
- f.topLines = slices.Insert(f.topLines, f.idxLicenseID, rawline)
+ f.topLines = slices.Insert(f.topLines, f.idxLicenseID, bytes.Clone(line.Bytes()))
- if f.copyrightYear != `` {
- f.copyrightYear += ` `
+ // Write the copyright text ...
+
+ line.Reset()
+ if f.commentPrefix != `` {
+ line.WriteString(f.commentPrefix + ` `)
}
// REUSE-IgnoreStart
- line = fmt.Sprintf("%sSPDX-FileCopyrightText: %s%s%s",
- f.commentPrefix, f.copyrightYear, f.copyrightText, f.commentSuffix)
+ line.WriteString(`SPDX-FileCopyrightText: `)
// REUSE-IgnoreEnd
+ if f.copyrightYear != `` {
+ line.WriteString(f.copyrightYear + ` `)
+ }
+ line.WriteString(f.copyrightText)
+ if f.commentSuffix != `` {
+ line.WriteString(` ` + f.commentSuffix)
+ }
- rawline = []byte(line)
- f.topLines = slices.Insert(f.topLines, f.idxLicenseID+1, rawline)
+ f.topLines = slices.Insert(f.topLines, f.idxLicenseID+1, bytes.Clone(line.Bytes()))
f.insertEmptyLine(f.idxLicenseID + 2)