indexOf wrote the node's remembered index even when it was right, so
Header.Get raced when a document was read from several goroutines.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Header.Set, Document.SetDefine and Document.AddHeader return an error for
a value or name that can't be written as one opcode, define or header, and
Build returns the same error for what it can't write.
- Set puts a new opcode after the last one's trailing comment, and never
where text on its line would become part of its value. Delete keeps the
line breaks it doesn't own.
- Node.Line and Node.Col are replaced by File.Position, which works lines and
columns out when asked, and a node remembers where it was in its file, so an
edit no longer renumbers the file or searches it from the start.
- Add FuzzEdit checks that an edited file reads back as its nodes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An opcode's value now ends at whitespace followed by the next opcode, so
sample=A=440.wav is one value.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Count variable expansions against MaxBytes and stop substituting past it, so
nested #defines can't grow exponentially. Read at most MaxBytes from a reader.
- Lex in linear time: end an opcode value at the next line break with the same
regexp, and merge text nodes by slicing. Cap variable names at 128 bytes.
- Read a byte order mark as space so a directive after it is recognised.
- Refuse in WriteFiles an include path that is absolute or leaves the folder, and
report include.outside and sample.outside from Validate.
- Give a lone sw_lokey or sw_hikey a one-key range.
- Sum controller modulations in a fixed order so Instrument is deterministic.
- Stop samplePrefix looping on a sample at the root.
- Validate without lexing plain opcodes again, and cache registry lookups.
- Add regression tests and FuzzWrite, FuzzEdit and FuzzBuild.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>