aboutsummaryrefslogtreecommitdiff
path: root/internal/extract/plain.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 12:11:42 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 12:11:42 +0200
commitbddbd74e4a73e8e32bcf648efd1cac5655f6d0cd (patch)
tree187e6a1fb722d9ab97d2076f69f997f5d371e943 /internal/extract/plain.go
parentcd7425b81f963a948f0abe7df3f9e58e190c2b78 (diff)
downloadkrino-bddbd74e4a73e8e32bcf648efd1cac5655f6d0cd.tar.gz
krino-bddbd74e4a73e8e32bcf648efd1cac5655f6d0cd.zip
comments that explain the code, not how it was written
About 340 comments cited the development process: task and plan numbers, fix waves, rulings, reviewers, and the author in the third person with a date. None of that exists outside the work itself, so to a reader it pointed at nothing. Each one now states the engineering reason it was standing in front of; where a comment was provenance and nothing else, it is gone. References to docs/design.md and docs/gui-design.md by section stay: both ship with the repository. The design documents lose their amendment diaries - CHANGELOG.md is that record - and the GUI's says plainly that the window has gone further than the document. Only comments changed. Every .go file was parsed and its code printed with comments stripped, before and after: the two hashes are identical across all 175 files.
Diffstat (limited to 'internal/extract/plain.go')
-rw-r--r--internal/extract/plain.go37
1 files changed, 18 insertions, 19 deletions
diff --git a/internal/extract/plain.go b/internal/extract/plain.go
index beffae1..956c3e6 100644
--- a/internal/extract/plain.go
+++ b/internal/extract/plain.go
@@ -39,13 +39,12 @@ func readDecoded(path string) (string, error) {
// sample that merely looks like UTF-8 must hold for the WHOLE file — no
// NUL byte anywhere, and no invalid UTF-8 anywhere past the sample — or
// the file is ErrUnsupported after all (a self-extracting installer has no
-// text in krino's sense, decided after the plan 10 re-check); the
-// Latin-1 fallback in decode
-// never applies to a sniffed file, only to a file whose extension already
-// names it as text. D2: when the file continues past the sample (n ==
-// sniffSize), the validity check is run against a trimmed copy with any
-// incomplete trailing rune removed, so a multi-byte rune that happens to
-// straddle byte sniffSize does not make an otherwise-valid file sniff as
+// text in krino's sense); the Latin-1 fallback in decode never applies to
+// a sniffed file, only to a file whose extension already names it as
+// text. When the file continues past the sample (n == sniffSize), the
+// validity check is run against a trimmed copy with any incomplete
+// trailing rune removed, so a multi-byte rune that happens to straddle
+// byte sniffSize does not make an otherwise-valid file sniff as
// unsupported; sample itself, used below to build the returned text, is
// left untouched — the rest of the file (read after the check) supplies
// the bytes trimming set aside.
@@ -89,13 +88,13 @@ func sniffText(path string) (string, error) {
}
// trimIncompleteTrailingRune drops an incomplete UTF-8 sequence left
-// dangling at the very end of b — D2's fix for a rune cut off exactly at
-// the sniff sample's boundary. It looks back at most utf8.UTFMax-1 bytes
-// for the start of the trailing rune; if the bytes from there to the end
-// are not a complete encoding (utf8.FullRune), that partial rune is cut,
-// since more bytes to finish it may simply not have been read yet. A
-// sample already ending cleanly (the common case, and every all-ASCII
-// sample) is returned unchanged.
+// dangling at the very end of b, so a rune cut off exactly at the sniff
+// sample's boundary is not mistaken for invalid UTF-8. It looks back at
+// most utf8.UTFMax-1 bytes for the start of the trailing rune; if the
+// bytes from there to the end are not a complete encoding (utf8.FullRune),
+// that partial rune is cut, since more bytes to finish it may simply not
+// have been read yet. A sample already ending cleanly (the common case,
+// and every all-ASCII sample) is returned unchanged.
func trimIncompleteTrailingRune(b []byte) []byte {
end := len(b)
start := end - 1
@@ -143,7 +142,7 @@ func decodeUTF16(b []byte, order binary.ByteOrder) string {
// decodeLatin1 decodes b as Latin-1: each byte is its own Unicode code
// point. Built directly as UTF-8 (at most two bytes per input byte), not
-// through a []rune of four bytes per input byte (triage 28d).
+// through a []rune of four bytes per input byte.
func decodeLatin1(b []byte) string {
var s strings.Builder
s.Grow(len(b) * 2)
@@ -200,10 +199,10 @@ func stripMarkup(s string) string {
gt := strings.IndexByte(s[j:], '>')
if gt == -1 {
- // D1: an unterminated tag (no closing '>') can no longer be
- // parsed as markup, but that is no reason to discard the rest
- // of the file - copy it through as literal text instead of
- // simply stopping the scan.
+ // An unterminated tag (no closing '>') can no longer be
+ // parsed as markup, but that is no reason to discard the
+ // rest of the file - copy it through as literal text
+ // instead of simply stopping the scan.
b.WriteString(s[i:])
break
}