Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses Fix handling of the tab special character.
details: https://anonhg.NetBSD.org/src/rev/98acb16dcb16
branches: trunk
changeset: 1026293:98acb16dcb16
user: blymn <blymn%NetBSD.org@localhost>
date: Tue Nov 16 21:00:50 2021 +0000
description:
Fix handling of the tab special character.
diffstat:
lib/libcurses/ins_wstr.c | 29 ++++++++++++++++-------------
1 files changed, 16 insertions(+), 13 deletions(-)
diffs (59 lines):
diff -r deb2619ee908 -r 98acb16dcb16 lib/libcurses/ins_wstr.c
--- a/lib/libcurses/ins_wstr.c Tue Nov 16 20:42:47 2021 +0000
+++ b/lib/libcurses/ins_wstr.c Tue Nov 16 21:00:50 2021 +0000
@@ -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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index