aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <thomas.voss@humanwave.nl> 2026-03-19 16:36:46 +0100
committerThomas Voss <thomas.voss@humanwave.nl> 2026-03-19 16:36:46 +0100
commit855d07cfbe7a6e59955560c9a7ca8dffe8ac85bd (patch)
treef855a8f9f7f680e3561182dc1a45a1ce6b794981 /src
parent3b64f3818a755afac009f14c4e12551f159ca632 (diff)
Handle CLRF line-endings correctly
Diffstat (limited to 'src')
-rw-r--r--src/work.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/work.c b/src/work.c
index 4be1238..2ae55a2 100644
--- a/src/work.c
+++ b/src/work.c
@@ -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')