Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses misc fixes and improvements:
details: https://anonhg.NetBSD.org/src/rev/2901d3d63537
branches: trunk
changeset: 752332:2901d3d63537
user: drochner <drochner%NetBSD.org@localhost>
date: Tue Feb 23 19:48:26 2010 +0000
description:
misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
diffstat:
lib/libcurses/acs.c | 161 ++++++++++++++++++++++++----------------
lib/libcurses/add_wchstr.c | 6 +-
lib/libcurses/addbytes.c | 6 +-
lib/libcurses/addch.c | 8 +-
lib/libcurses/border.c | 70 +++++++++++------
lib/libcurses/cchar.c | 22 +++++-
lib/libcurses/curses.h | 72 +++++++++--------
lib/libcurses/curses_private.h | 3 +-
lib/libcurses/ins_wch.c | 6 +-
lib/libcurses/ins_wstr.c | 14 ++-
lib/libcurses/line.c | 34 +++++++-
lib/libcurses/move.c | 15 +++-
lib/libcurses/touchwin.c | 28 ++++++-
13 files changed, 299 insertions(+), 146 deletions(-)
diffs (truncated from 892 to 300 lines):
diff -r fef206aa3564 -r 2901d3d63537 lib/libcurses/acs.c
--- a/lib/libcurses/acs.c Tue Feb 23 19:28:00 2010 +0000
+++ b/lib/libcurses/acs.c Tue Feb 23 19:48:26 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acs.c,v 1.17 2010/02/03 15:34:40 roy Exp $ */
+/* $NetBSD: acs.c,v 1.18 2010/02/23 19:48:26 drochner Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: acs.c,v 1.17 2010/02/03 15:34:40 roy Exp $");
+__RCSID("$NetBSD: acs.c,v 1.18 2010/02/23 19:48:26 drochner Exp $");
#endif /* not lint */
#include "curses.h"
@@ -40,6 +40,7 @@
chtype _acs_char[NUM_ACS];
#ifdef HAVE_WCHAR
#include <assert.h>
+#include <locale.h>
#include <langinfo.h>
#include <strings.h>
@@ -105,9 +106,7 @@
while (*aofac != '\0') {
if ((acs = *aofac) == '\0')
return;
- if (++aofac == '\0')
- return;
- if ((term = *aofac) == '\0')
+ if ((term = *++aofac) == '\0')
return;
/* Only add characters 1 to 127 */
if (acs < NUM_ACS)
@@ -158,72 +157,106 @@
}
/* Add the SUSv2 defaults (those that are not '+') */
+ if (!strcmp(setlocale(LC_CTYPE, NULL), "C"))
+ setlocale(LC_CTYPE, "");
lstr = nl_langinfo(CODESET);
_DIAGASSERT(lstr);
- if (!strcasecmp(lstr, "UTF-8")) {
+ if (strcasecmp(lstr, "UTF-8")) {
#ifdef DEBUG
__CTRACE(__CTRACE_INIT, "__init_wacs: setting defaults\n" );
#endif /* DEBUG */
- WACS_RARROW = ( wchar_t )btowc( '>' );
- WACS_LARROW = ( wchar_t )btowc( '<' );
- WACS_UARROW = ( wchar_t )btowc( '^' );
- WACS_DARROW = ( wchar_t )btowc( 'v' );
- WACS_BLOCK = ( wchar_t )btowc( '#' );
- WACS_CKBOARD = ( wchar_t )btowc( ':' );
- WACS_DEGREE = ( wchar_t )btowc( 39 ); /* ' */
- WACS_PLMINUS = ( wchar_t )btowc( '#' );
- WACS_BOARD = ( wchar_t )btowc( '#' );
- WACS_LANTERN = ( wchar_t )btowc( '#' );
- WACS_HLINE = ( wchar_t )btowc( '-' );
- WACS_S1 = ( wchar_t )btowc( '-' );
- WACS_S9 = ( wchar_t )btowc( '_' );
- WACS_VLINE = ( wchar_t )btowc( '|' );
- WACS_BULLET = ( wchar_t )btowc( 'o' );
- WACS_S3 = ( wchar_t )btowc( 'p' );
- WACS_S7 = ( wchar_t )btowc( 'r' );
- WACS_LEQUAL = ( wchar_t )btowc( 'y' );
- WACS_GEQUAL = ( wchar_t )btowc( 'z' );
- WACS_PI = ( wchar_t )btowc( '{' );
- WACS_NEQUAL = ( wchar_t )btowc( '|' );
- WACS_STERLING = ( wchar_t )btowc( '}' );
+ WACS_RARROW->vals[0] = ( wchar_t )btowc( '>' );
+ WACS_LARROW->vals[0] = ( wchar_t )btowc( '<' );
+ WACS_UARROW->vals[0] = ( wchar_t )btowc( '^' );
+ WACS_DARROW->vals[0] = ( wchar_t )btowc( 'v' );
+ WACS_BLOCK->vals[0] = ( wchar_t )btowc( '#' );
+ WACS_CKBOARD->vals[0] = ( wchar_t )btowc( ':' );
+ WACS_DEGREE->vals[0] = ( wchar_t )btowc( 39 ); /* ' */
+ WACS_PLMINUS->vals[0] = ( wchar_t )btowc( '#' );
+ WACS_BOARD->vals[0] = ( wchar_t )btowc( '#' );
+ WACS_LANTERN->vals[0] = ( wchar_t )btowc( '#' );
+ WACS_HLINE->vals[0] = ( wchar_t )btowc( '-' );
+ WACS_S1->vals[0] = ( wchar_t )btowc( '-' );
+ WACS_S9->vals[0] = ( wchar_t )btowc( '_' );
+ WACS_VLINE->vals[0] = ( wchar_t )btowc( '|' );
+ WACS_BULLET->vals[0] = ( wchar_t )btowc( 'o' );
+ WACS_S3->vals[0] = ( wchar_t )btowc( 'p' );
+ WACS_S7->vals[0] = ( wchar_t )btowc( 'r' );
+ WACS_LEQUAL->vals[0] = ( wchar_t )btowc( 'y' );
+ WACS_GEQUAL->vals[0] = ( wchar_t )btowc( 'z' );
+ WACS_PI->vals[0] = ( wchar_t )btowc( '{' );
+ WACS_NEQUAL->vals[0] = ( wchar_t )btowc( '|' );
+ WACS_STERLING->vals[0]= ( wchar_t )btowc( '}' );
} else {
/* Unicode defaults */
#ifdef DEBUG
__CTRACE(__CTRACE_INIT,
"__init_wacs: setting Unicode defaults\n" );
#endif /* DEBUG */
- WACS_RARROW = 0x2192;
- WACS_LARROW = 0x2190;
- WACS_UARROW = 0x2192;
- WACS_DARROW = 0x2193;
- WACS_BLOCK = 0x25ae;
- WACS_DIAMOND = 0x25c6;
- WACS_CKBOARD = 0x2592;
- WACS_DEGREE = 0x00b0;
- WACS_PLMINUS = 0x00b1;
- WACS_BOARD = 0x2592;
- WACS_LANTERN = 0x2603;
- WACS_LRCORNER = 0x2518;
- WACS_URCORNER = 0x2510;
- WACS_ULCORNER = 0x250c;
- WACS_LLCORNER = 0x2514;
- WACS_PLUS = 0x253c;
- WACS_HLINE = 0x2500;
- WACS_S1 = 0x23ba;
- WACS_S9 = 0x23bd;
- WACS_LTEE = 0x251c;
- WACS_RTEE = 0x2524;
- WACS_BTEE = 0x2534;
- WACS_TTEE = 0x252c;
- WACS_VLINE = 0x2502;
- WACS_BULLET = 0x00b7;
- WACS_S3 = 0x23bb;
- WACS_S7 = 0x23bc;
- WACS_LEQUAL = 0x2264;
- WACS_GEQUAL = 0x2265;
- WACS_PI = 0x03C0;
- WACS_NEQUAL = 0x2260;
- WACS_STERLING = 0x00A3;
+ WACS_RARROW->vals[0] = 0x2192;
+ ACS_RARROW = '+' | __ACS_IS_WACS;
+ WACS_LARROW->vals[0] = 0x2190;
+ ACS_LARROW = ',' | __ACS_IS_WACS;
+ WACS_UARROW->vals[0] = 0x2192;
+ ACS_UARROW = '-' | __ACS_IS_WACS;
+ WACS_DARROW->vals[0] = 0x2193;
+ ACS_DARROW = '.' | __ACS_IS_WACS;
+ WACS_BLOCK->vals[0] = 0x25ae;
+ ACS_BLOCK = '0' | __ACS_IS_WACS;
+ WACS_DIAMOND->vals[0] = 0x25c6;
+ ACS_DIAMOND = '`' | __ACS_IS_WACS;
+ WACS_CKBOARD->vals[0] = 0x2592;
+ ACS_CKBOARD = 'a' | __ACS_IS_WACS;
+ WACS_DEGREE->vals[0] = 0x00b0;
+ ACS_DEGREE = 'f' | __ACS_IS_WACS;
+ WACS_PLMINUS->vals[0] = 0x00b1;
+ ACS_PLMINUS = 'g' | __ACS_IS_WACS;
+ WACS_BOARD->vals[0] = 0x2592;
+ ACS_BOARD = 'h' | __ACS_IS_WACS;
+ WACS_LANTERN->vals[0] = 0x2603;
+ ACS_LANTERN = 'i' | __ACS_IS_WACS;
+ WACS_LRCORNER->vals[0]= 0x2518;
+ ACS_LRCORNER = 'j' | __ACS_IS_WACS;
+ WACS_URCORNER->vals[0]= 0x2510;
+ ACS_URCORNER = 'k' | __ACS_IS_WACS;
+ WACS_ULCORNER->vals[0]= 0x250c;
+ ACS_ULCORNER = 'l' | __ACS_IS_WACS;
+ WACS_LLCORNER->vals[0]= 0x2514;
+ ACS_LLCORNER = 'm' | __ACS_IS_WACS;
+ WACS_PLUS->vals[0] = 0x253c;
+ ACS_PLUS = 'n' | __ACS_IS_WACS;
+ WACS_HLINE->vals[0] = 0x2500;
+ ACS_HLINE = 'q' | __ACS_IS_WACS;
+ WACS_S1->vals[0] = 0x23ba;
+ ACS_S1 = 'o' | __ACS_IS_WACS;
+ WACS_S9->vals[0] = 0x23bd;
+ ACS_S9 = 's' | __ACS_IS_WACS;
+ WACS_LTEE->vals[0] = 0x251c;
+ ACS_LTEE = 't' | __ACS_IS_WACS;
+ WACS_RTEE->vals[0] = 0x2524;
+ ACS_RTEE = 'u' | __ACS_IS_WACS;
+ WACS_BTEE->vals[0] = 0x2534;
+ ACS_BTEE = 'v' | __ACS_IS_WACS;
+ WACS_TTEE->vals[0] = 0x252c;
+ ACS_TTEE = 'w' | __ACS_IS_WACS;
+ WACS_VLINE->vals[0] = 0x2502;
+ ACS_VLINE = 'x' | __ACS_IS_WACS;
+ WACS_BULLET->vals[0] = 0x00b7;
+ ACS_BULLET = '~' | __ACS_IS_WACS;
+ WACS_S3->vals[0] = 0x23bb;
+ ACS_S3 = 'p' | __ACS_IS_WACS;
+ WACS_S7->vals[0] = 0x23bc;
+ ACS_S7 = 'r' | __ACS_IS_WACS;
+ WACS_LEQUAL->vals[0] = 0x2264;
+ ACS_LEQUAL = 'y' | __ACS_IS_WACS;
+ WACS_GEQUAL->vals[0] = 0x2265;
+ ACS_GEQUAL = 'z' | __ACS_IS_WACS;
+ WACS_PI->vals[0] = 0x03C0;
+ ACS_PI = '{' | __ACS_IS_WACS;
+ WACS_NEQUAL->vals[0] = 0x2260;
+ ACS_NEQUAL = '|' | __ACS_IS_WACS;
+ WACS_STERLING->vals[0]= 0x00A3;
+ ACS_STERLING = '}' | __ACS_IS_WACS;
}
if (t_acs_chars(screen->term) == NULL) {
@@ -239,9 +272,7 @@
while (*aofac != '\0') {
if ((acs = *aofac) == '\0')
return;
- if (++aofac == '\0')
- return;
- if ((term = *aofac) == '\0')
+ if ((term = *++aofac) == '\0')
return;
/* Only add characters 1 to 127 */
if (acs < NUM_ACS) {
@@ -259,9 +290,11 @@
__cputchar_args, screen->outfd);
out:
- for (count=0; count < NUM_ACS; count++)
+ for (count=0; count < NUM_ACS; count++) {
memcpy(&screen->wacs_char[count], &_wacs_char[count],
sizeof(cchar_t));
+ screen->acs_char[count]= _acs_char[count];
+ }
}
void
diff -r fef206aa3564 -r 2901d3d63537 lib/libcurses/add_wchstr.c
--- a/lib/libcurses/add_wchstr.c Tue Feb 23 19:28:00 2010 +0000
+++ b/lib/libcurses/add_wchstr.c Tue Feb 23 19:48:26 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: add_wchstr.c,v 1.3 2009/07/22 16:57:14 roy Exp $ */
+/* $NetBSD: add_wchstr.c,v 1.4 2010/02/23 19:48:26 drochner Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: add_wchstr.c,v 1.3 2009/07/22 16:57:14 roy Exp $");
+__RCSID("$NetBSD: add_wchstr.c,v 1.4 2010/02/23 19:48:26 drochner Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -233,6 +233,8 @@
__CTRACE(__CTRACE_INPUT, "wadd_wchnstr: adding %x", wc);
#endif /* DEBUG */
cw = wcwidth(wc);
+ if (cw < 0)
+ cw = 1;
if (cw) {
/* spacing character */
#ifdef DEBUG
diff -r fef206aa3564 -r 2901d3d63537 lib/libcurses/addbytes.c
--- a/lib/libcurses/addbytes.c Tue Feb 23 19:28:00 2010 +0000
+++ b/lib/libcurses/addbytes.c Tue Feb 23 19:48:26 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: addbytes.c,v 1.35 2009/07/22 16:57:14 roy Exp $ */
+/* $NetBSD: addbytes.c,v 1.36 2010/02/23 19:48:26 drochner Exp $ */
/*
* Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: addbytes.c,v 1.35 2009/07/22 16:57:14 roy Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.36 2010/02/23 19:48:26 drochner Exp $");
#endif
#endif /* not lint */
@@ -438,6 +438,8 @@
/* check for enough space before the end of line */
cw = wcwidth(wch->vals[0]);
+ if (cw < 0)
+ cw = 1;
if (cw > win->maxx - *x) {
#ifdef DEBUG
__CTRACE(__CTRACE_INPUT,
diff -r fef206aa3564 -r 2901d3d63537 lib/libcurses/addch.c
--- a/lib/libcurses/addch.c Tue Feb 23 19:28:00 2010 +0000
+++ b/lib/libcurses/addch.c Tue Feb 23 19:48:26 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: addch.c,v 1.15 2007/05/28 15:01:53 blymn Exp $ */
+/* $NetBSD: addch.c,v 1.16 2010/02/23 19:48:26 drochner Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)addch.c 8.2 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: addch.c,v 1.15 2007/05/28 15:01:53 blymn Exp $");
+__RCSID("$NetBSD: addch.c,v 1.16 2010/02/23 19:48:26 drochner Exp $");
#endif
#endif /* not lint */
@@ -94,9 +94,7 @@
#endif
#ifdef HAVE_WCHAR
- cc.vals[0] = ch & __CHARTEXT;
Home |
Main Index |
Thread Index |
Old Index