aboutsummaryrefslogtreecommitdiff
path: root/ncurses/widechar
diff options
context:
space:
mode:
authorRong-En Fan <rafan@FreeBSD.org>2008-11-09 14:08:54 +0000
committerRong-En Fan <rafan@FreeBSD.org>2008-11-09 14:08:54 +0000
commit6181f4622a00a9de81df01cecb5fa73ffdb697bc (patch)
treec963ba08ac935d7f048b78517309fe6fc2f496e6 /ncurses/widechar
parentc0e48ca1322e978a8f9795a5ddb251df2479f930 (diff)
downloadsrc-6181f4622a00a9de81df01cecb5fa73ffdb697bc.tar.gz
src-6181f4622a00a9de81df01cecb5fa73ffdb697bc.zip
- Import ncurses 5.7-20081102 (5.7 release) onto vendor branchvendor/ncurses/5.7-20081102
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=184798 svn path=/vendor/ncurses/5.7-20081102/; revision=184799; tag=vendor/ncurses/5.7-20081102
Diffstat (limited to 'ncurses/widechar')
-rw-r--r--ncurses/widechar/charable.c6
-rw-r--r--ncurses/widechar/lib_get_wch.c75
-rw-r--r--ncurses/widechar/lib_get_wstr.c27
-rw-r--r--ncurses/widechar/lib_key_name.c4
-rw-r--r--ncurses/widechar/lib_unget_wch.c6
5 files changed, 64 insertions, 54 deletions
diff --git a/ncurses/widechar/charable.c b/ncurses/widechar/charable.c
index cf7240780883..91ceb32ff738 100644
--- a/ncurses/widechar/charable.c
+++ b/ncurses/widechar/charable.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2003-2004,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 2003-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -32,13 +32,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: charable.c,v 1.4 2005/04/16 18:08:56 tom Exp $")
+MODULE_ID("$Id: charable.c,v 1.5 2008/07/05 20:51:41 tom Exp $")
NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch)
{
bool result;
#if HAVE_WCTOB
- result = (wctob((wint_t) ch) == ch);
+ result = (wctob((wint_t) ch) == (int) ch);
#else
result = (_nc_to_char(ch) >= 0);
#endif
diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c
index 7985df2571db..6cf3129f2d18 100644
--- a/ncurses/widechar/lib_get_wch.c
+++ b/ncurses/widechar/lib_get_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2006,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_get_wch.c,v 1.14 2007/05/12 19:03:16 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.17 2008/08/16 19:22:55 tom Exp $")
#if HAVE_MBTOWC && HAVE_MBLEN
#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
@@ -60,6 +60,7 @@ make an error
NCURSES_EXPORT(int)
wget_wch(WINDOW *win, wint_t *result)
{
+ SCREEN *sp;
int code;
char buffer[(MB_LEN_MAX * 9) + 1]; /* allow some redundant shifts */
int status;
@@ -76,44 +77,52 @@ wget_wch(WINDOW *win, wint_t *result)
* We can get a stream of single-byte characters and KEY_xxx codes from
* _nc_wgetch(), while we want to return a wide character or KEY_xxx code.
*/
- for (;;) {
- T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer)));
- code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist *) 0));
- if (code == ERR) {
- break;
- } else if (code == KEY_CODE_YES) {
- /*
- * If we were processing an incomplete multibyte character, return
- * an error since we have a KEY_xxx code which interrupts it. For
- * some cases, we could improve this by writing a new version of
- * lib_getch.c(!), but it is not clear whether the improvement
- * would be worth the effort.
- */
- if (count != 0) {
- ungetch((int) value);
+ _nc_lock_global(curses);
+ sp = _nc_screen_of(win);
+ if (sp != 0) {
+ for (;;) {
+ T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer)));
+ code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist
+ *) 0));
+ if (code == ERR) {
+ break;
+ } else if (code == KEY_CODE_YES) {
+ /*
+ * If we were processing an incomplete multibyte character,
+ * return an error since we have a KEY_xxx code which
+ * interrupts it. For some cases, we could improve this by
+ * writing a new version of lib_getch.c(!), but it is not clear
+ * whether the improvement would be worth the effort.
+ */
+ if (count != 0) {
+ _nc_ungetch(sp, (int) value);
+ code = ERR;
+ }
+ break;
+ } else if (count + 1 >= sizeof(buffer)) {
+ _nc_ungetch(sp, (int) value);
code = ERR;
- }
- break;
- } else if (count + 1 >= sizeof(buffer)) {
- ungetch((int) value);
- code = ERR;
- break;
- } else {
- buffer[count++] = UChar(value);
- reset_mbytes(state);
- status = count_mbytes(buffer, count, state);
- if (status >= 0) {
+ break;
+ } else {
+ buffer[count++] = (char) UChar(value);
reset_mbytes(state);
- if (check_mbytes(wch, buffer, count, state) != status) {
- code = ERR; /* the two calls should match */
- ungetch((int) value);
+ status = count_mbytes(buffer, count, state);
+ if (status >= 0) {
+ reset_mbytes(state);
+ if (check_mbytes(wch, buffer, count, state) != status) {
+ code = ERR; /* the two calls should match */
+ _nc_ungetch(sp, (int) value);
+ }
+ value = wch;
+ break;
}
- value = wch;
- break;
}
}
+ } else {
+ code = ERR;
}
*result = value;
+ _nc_unlock_global(curses);
T(("result %#lo", value));
returnCode(code);
}
diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c
index bf39aa1a188b..baa70a5a53f9 100644
--- a/ncurses/widechar/lib_get_wstr.c
+++ b/ncurses/widechar/lib_get_wstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2003,2004 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2004,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_get_wstr.c,v 1.8 2004/10/16 21:55:36 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.10 2008/08/16 19:25:33 tom Exp $")
static int
wadd_wint(WINDOW *win, wint_t *src)
@@ -48,7 +48,7 @@ wadd_wint(WINDOW *win, wint_t *src)
cchar_t tmp;
wchar_t wch[2];
- wch[0] = *src;
+ wch[0] = (wchar_t) (*src);
wch[1] = 0;
setcchar(&tmp, wch, A_NORMAL, 0, NULL);
return wadd_wch(win, &tmp);
@@ -86,6 +86,7 @@ WipeOut(WINDOW *win, int y, int x, wint_t *first, wint_t *last, bool echoed)
NCURSES_EXPORT(int)
wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
{
+ SCREEN *sp = _nc_screen_of(win);
TTY buf;
bool oldnl, oldecho, oldraw, oldcbreak;
wint_t erasec;
@@ -102,17 +103,17 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
_nc_get_tty_mode(&buf);
- oldnl = SP->_nl;
- oldecho = SP->_echo;
- oldraw = SP->_raw;
- oldcbreak = SP->_cbreak;
+ oldnl = sp->_nl;
+ oldecho = sp->_echo;
+ oldraw = sp->_raw;
+ oldcbreak = sp->_cbreak;
nl();
noecho();
noraw();
cbreak();
- erasec = erasechar();
- killc = killchar();
+ erasec = (wint_t) erasechar();
+ killc = (wint_t) killchar();
getyx(win, y, x);
@@ -209,10 +210,10 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
/* Restore with a single I/O call, to fix minor asymmetry between
* raw/noraw, etc.
*/
- SP->_nl = oldnl;
- SP->_echo = oldecho;
- SP->_raw = oldraw;
- SP->_cbreak = oldcbreak;
+ sp->_nl = oldnl;
+ sp->_echo = oldecho;
+ sp->_raw = oldraw;
+ sp->_cbreak = oldcbreak;
(void) _nc_set_tty_mode(&buf);
diff --git a/ncurses/widechar/lib_key_name.c b/ncurses/widechar/lib_key_name.c
index e24c9654d564..da65f219c266 100644
--- a/ncurses/widechar/lib_key_name.c
+++ b/ncurses/widechar/lib_key_name.c
@@ -35,7 +35,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_key_name.c,v 1.2 2007/06/12 21:01:13 tom Exp $")
+MODULE_ID("$Id: lib_key_name.c,v 1.3 2008/10/11 20:15:14 tom Exp $")
NCURSES_EXPORT(NCURSES_CONST char *)
key_name(wchar_t c)
@@ -54,7 +54,7 @@ key_name(wchar_t c)
my_wchars = wunctrl(&my_cchar);
len = wcstombs(result, my_wchars, sizeof(result) - 1);
if (isEILSEQ(len) || (len == 0)) {
- return "UNKNOWN KEY";
+ return 0;
}
result[len] = '\0';
diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c
index b2dc7ff96f1b..bb2c4a084b15 100644
--- a/ncurses/widechar/lib_unget_wch.c
+++ b/ncurses/widechar/lib_unget_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2004,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_unget_wch.c,v 1.9 2007/11/25 00:57:00 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.10 2008/06/07 14:50:37 tom Exp $")
/*
* Wrapper for wcrtomb() which obtains the length needed for the given
@@ -86,7 +86,7 @@ unget_wch(const wchar_t wch)
wcrtomb(string, wch, &state);
for (n = (int) (length - 1); n >= 0; --n) {
- if (ungetch(string[n]) != OK) {
+ if (_nc_ungetch(SP, string[n]) != OK) {
result = ERR;
break;
}