ref: 6a09db5047ac94dd363055452b1371b276c3928f
parent: 413350ab6658c7d7fd041a35d5b1981b4bc356b4
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Nov 12 10:57:49 EST 2024
ios_getutf8: don't update column number on bad runes
--- a/ios.c
+++ b/ios.c
@@ -834,8 +834,12 @@
ch = s->buf[s->bpos++];
else if(s->_eof || ios_read(s, &ch, 1) < 1)
return IOS_EOF;
- if(ch == '\n')
+ if(ch == '\n'){
s->lineno++;
+ s->colno = 0;
+ }else{
+ s->colno++;
+ }
return ch;
}
@@ -895,11 +899,13 @@
break;
}
chartorune(r, buf);
+ if(*r == Runeerror)
+ return 0;
if(*r == '\n')
s->colno = 0;
else
s->colno += wcwidth(*r);
- return *r == Runeerror ? 0 : 1;
+ return 1;
}
int