diff options
author | Yorhel <git@yorhel.nl> | 2014-04-05 15:21:22 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2014-04-05 15:21:22 +0200 |
commit | f7b395cafce96450e96a68b4860108a14fe7eab2 (patch) | |
tree | 0efc8b48ae34869ee62155a7f5c05b341f23b6a3 | |
parent | bc791b28fce1766c71ffe22e7e5b77341e6aa449 (diff) |
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.
-rw-r--r-- | src/strutil.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/strutil.c b/src/strutil.c index 10527e1..2be37cc 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -159,7 +159,8 @@ int str_offset_from_columns(const char *str, int col) { int w = 0; while(*str && w < col) { w += gunichar_width(g_utf8_get_char(str)); - str = g_utf8_next_char(str); + if(w <= col) + str = g_utf8_next_char(str); } return str-ostr; } |