diff options
| author | gingerBill <bill@gingerbill.org> | 2024-04-19 00:19:02 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-04-19 00:19:02 +0100 |
| commit | 3812d5e002fd2a2f4762b7732c72e49c1c6ee767 (patch) | |
| tree | c5b9b036078dbc61359b7d308b2159f53604cb77 /core/encoding/csv | |
| parent | 2416380f34f26bb2ccf45f5ca075293a3e07af19 (diff) | |
Only override the comma value on `*_init` if it is "invalid"
Diffstat (limited to 'core/encoding/csv')
| -rw-r--r-- | core/encoding/csv/reader.odin | 5 | ||||
| -rw-r--r-- | core/encoding/csv/writer.odin | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/core/encoding/csv/reader.odin b/core/encoding/csv/reader.odin index 22eea9568..5d3626b9f 100644 --- a/core/encoding/csv/reader.odin +++ b/core/encoding/csv/reader.odin @@ -91,7 +91,10 @@ DEFAULT_RECORD_BUFFER_CAPACITY :: 256 // reader_init initializes a new Reader from r reader_init :: proc(reader: ^Reader, r: io.Reader, buffer_allocator := context.allocator) { - reader.comma = ',' + switch reader.comma { + case '\x00', '\n', '\r', 0xfffd: + reader.comma = ',' + } context.allocator = buffer_allocator reserve(&reader.record_buffer, DEFAULT_RECORD_BUFFER_CAPACITY) diff --git a/core/encoding/csv/writer.odin b/core/encoding/csv/writer.odin index 46145ecc1..132fa0a51 100644 --- a/core/encoding/csv/writer.odin +++ b/core/encoding/csv/writer.odin @@ -17,7 +17,10 @@ Writer :: struct { // writer_init initializes a Writer that writes to w writer_init :: proc(writer: ^Writer, w: io.Writer) { - writer.comma = ',' + switch writer.comma { + case '\x00', '\n', '\r', 0xfffd: + writer.comma = ',' + } writer.w = w } |