Module Name: src Committed By: blymn Date: Tue Nov 16 21:00:50 UTC 2021
Modified Files: src/lib/libcurses: ins_wstr.c Log Message: Fix handling of the tab special character. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/lib/libcurses/ins_wstr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libcurses/ins_wstr.c diff -u src/lib/libcurses/ins_wstr.c:1.18 src/lib/libcurses/ins_wstr.c:1.19 --- src/lib/libcurses/ins_wstr.c:1.18 Mon Nov 15 06:27:06 2021 +++ src/lib/libcurses/ins_wstr.c Tue Nov 16 21:00:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ins_wstr.c,v 1.18 2021/11/15 06:27:06 blymn Exp $ */ +/* $NetBSD: ins_wstr.c,v 1.19 2021/11/16 21:00:50 blymn Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: ins_wstr.c,v 1.18 2021/11/15 06:27:06 blymn Exp $"); +__RCSID("$NetBSD: ins_wstr.c,v 1.19 2021/11/16 21:00:50 blymn Exp $"); #endif /* not lint */ #include <string.h> @@ -194,9 +194,12 @@ wins_nwstr(WINDOW *win, const wchar_t *w continue; case L'\t': - w = min(win->maxx - x, TABSIZE - (x % TABSIZE)); - width += w * wcwidth(ws[0]); - x += w * wcwidth(ws[0]); + cw = wcwidth(ws[0]); + if (cw < 0) + cw = 1; + w = cw * (TABSIZE - (x % TABSIZE)); + width += w; + x += w; scp++; continue; } @@ -254,16 +257,16 @@ wins_nwstr(WINDOW *win, const wchar_t *w break; case L'\t': - w = min(win->maxx - x, - TABSIZE - (x % TABSIZE)); - width += w * wcwidth(ws[0]); - x += w * wcwidth(ws[0]); + cw = wcwidth(ws[0]); + if (cw < 0) + cw = 1; + w = cw * (TABSIZE - (x % TABSIZE)); + width += w; + x += w; len += w; scp++; - for (i = 0; i < w; i++ ) { - *lstr = *ws; - lstr++; - } + *lstr = *ws; + lstr++; continue; } w = wcwidth(*scp);