diff options
| author | Thomas Voss <thomas.voss@humanwave.nl> | 2026-03-19 16:36:46 +0100 |
|---|---|---|
| committer | Thomas Voss <thomas.voss@humanwave.nl> | 2026-03-19 16:36:46 +0100 |
| commit | 855d07cfbe7a6e59955560c9a7ca8dffe8ac85bd (patch) | |
| tree | f855a8f9f7f680e3561182dc1a45a1ce6b794981 /src | |
| parent | 3b64f3818a755afac009f14c4e12551f159ca632 (diff) | |
Handle CLRF line-endings correctly
Diffstat (limited to 'src')
| -rw-r--r-- | src/work.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -465,7 +465,12 @@ compute_pos(const char8_t *p, pos_state_t *ps) unsigned char c = *ps->buf.p; if (__builtin_expect(isascii(c), 1)) { /* ASCII fast path */ ps->buf.p++; - if (c == '\r' || c == '\n' || c == '\v' || c == '\f') { + if (c == '\n' || c == '\v' || c == '\f') { + ps->row++; + ps->col = 0; + } else if (c == '\r') { + if (ps->buf.p < p && *ps->buf.p == '\n') + ps->buf.p++; ps->row++; ps->col = 0; } else if (c == '\t') |