summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/main.c b/main.c
index 4eb90e8..4272144 100644
--- a/main.c
+++ b/main.c
@@ -118,15 +118,15 @@ int fast_utf8_width(Str s) {
return n;
}
-int utf8_cp_idx(Str s, int dest) {
- int n = 0;
- for (int i = 0; i < s.n && n < dest; i++) {
+int utf8_cp_to_byte(Str s, int dest) {
+ int i, n;
+ for (i = 0, n = 0; i < s.n && n < dest; i++) {
if (s.s[i] & 0x80) {
i += stdc_leading_ones((unsigned char)s.s[i]) - 1;
}
n++;
}
- return n;
+ return i;
}
/* options */
@@ -559,7 +559,7 @@ void gfx_draw_pic(Pic *pfp, int y, int x, int max_lines, int max_cols, PicDrawFl
if (f & PIC_LEFT) x -= w;
if (f & PIC_TOP) y -= h;
for (int i = 0; i < h; i++) {
- int n = utf8_cp_idx(pfp->line[i], max_cols);
+ int n = utf8_cp_to_byte(pfp->line[i], max_cols);
mvaddnstr(y + i, x, pfp->line[i].s, n);
}
if (f & PIC_BORDER) gfx_draw_box(y - 1, x - 1, h + 2, w + 2);