Skip to content

Commit f7b395c

Browse files
author
Yorhel
committed
strutil.c: Fix error in str_offset_from_columns() with multicolumn char
The function would return one character too many if there is room for one more column and the character that follows happens to span multiple columns.
1 parent bc791b2 commit f7b395c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/strutil.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ int str_offset_from_columns(const char *str, int col) {
159159
int w = 0;
160160
while(*str && w < col) {
161161
w += gunichar_width(g_utf8_get_char(str));
162-
str = g_utf8_next_char(str);
162+
if(w <= col)
163+
str = g_utf8_next_char(str);
163164
}
164165
return str-ostr;
165166
}

0 commit comments

Comments
 (0)