shithub: sl

Download patch

ref: 99e0b90ee3d02bce33ccb3701103c6bc9e770bd2
parent: d40aee74db7bb917b66eab1b3e21470d1d5dd48e
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
--