aboutsummaryrefslogtreecommitdiff
path: root/ncurses/widechar
diff options
context:
space:
mode:
Diffstat (limited to 'ncurses/widechar')
-rw-r--r--ncurses/widechar/charable.c8
-rw-r--r--ncurses/widechar/lib_add_wch.c10
-rw-r--r--ncurses/widechar/lib_cchar.c42
-rw-r--r--ncurses/widechar/lib_get_wch.c14
-rw-r--r--ncurses/widechar/lib_get_wstr.c8
-rw-r--r--ncurses/widechar/lib_hline_set.c10
-rw-r--r--ncurses/widechar/lib_in_wch.c8
-rw-r--r--ncurses/widechar/lib_ins_wch.c29
-rw-r--r--ncurses/widechar/lib_inwstr.c22
-rw-r--r--ncurses/widechar/lib_key_name.c15
-rw-r--r--ncurses/widechar/lib_slk_wset.c11
-rw-r--r--ncurses/widechar/lib_unget_wch.c7
-rw-r--r--ncurses/widechar/lib_vid_attr.c75
-rw-r--r--ncurses/widechar/lib_vline_set.c13
-rw-r--r--ncurses/widechar/lib_wacs.c17
-rw-r--r--ncurses/widechar/widechars.c8
16 files changed, 171 insertions, 126 deletions
diff --git a/ncurses/widechar/charable.c b/ncurses/widechar/charable.c
index 91ceb32ff738..104f59dd8560 100644
--- a/ncurses/widechar/charable.c
+++ b/ncurses/widechar/charable.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2003-2005,2008 Free Software Foundation, Inc. *
+ * Copyright (c) 2003-2008,2018 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,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: charable.c,v 1.5 2008/07/05 20:51:41 tom Exp $")
+MODULE_ID("$Id: charable.c,v 1.7 2018/06/30 20:46:25 tom Exp $")
NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch)
{
@@ -57,6 +57,8 @@ NCURSES_EXPORT(int) _nc_to_char(wint_t ch)
result = UChar(temp[0]);
else
result = -1;
+#else
+#error expected either wctob/wctomb
#endif
return result;
}
@@ -75,6 +77,8 @@ NCURSES_EXPORT(wint_t) _nc_to_widechar(int ch)
result = convert;
else
result = WEOF;
+#else
+#error expected either btowc/mbtowc
#endif
return result;
}
diff --git a/ncurses/widechar/lib_add_wch.c b/ncurses/widechar/lib_add_wch.c
index 38d3130a54c4..c780466f72a9 100644
--- a/ncurses/widechar/lib_add_wch.c
+++ b/ncurses/widechar/lib_add_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2004-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 2004-2016,2019 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 <wctype.h>
#endif
-MODULE_ID("$Id: lib_add_wch.c,v 1.12 2011/03/22 09:31:15 Petr.Pavlu Exp $")
+MODULE_ID("$Id: lib_add_wch.c,v 1.15 2019/05/04 20:31:31 tom Exp $")
/* clone/adapt lib_addch.c */
static const cchar_t blankchar = NewChar(BLANK_TEXT);
@@ -55,7 +55,7 @@ static const cchar_t blankchar = NewChar(BLANK_TEXT);
*/
/* Return bit mask for clearing color pair number if given ch has color */
-#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0))
+#define COLOR_MASK(ch) (~(attr_t)(((ch) & A_COLOR) ? A_COLOR : 0))
static NCURSES_INLINE cchar_t
render_char(WINDOW *win, cchar_t ch)
@@ -114,7 +114,7 @@ render_char(WINDOW *win, cchar_t ch)
#endif
static bool
-newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T * ypos)
+newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos)
{
bool result = FALSE;
@@ -195,7 +195,7 @@ wadd_wch_literal(WINDOW *win, cchar_t ch)
* adjustments.
*/
{
- int len = wcwidth(CharOf(ch));
+ int len = _nc_wacs_width(CharOf(ch));
int i;
int j;
wchar_t *chars;
diff --git a/ncurses/widechar/lib_cchar.c b/ncurses/widechar/lib_cchar.c
index 654bebb46d36..58a3b9401420 100644
--- a/ncurses/widechar/lib_cchar.c
+++ b/ncurses/widechar/lib_cchar.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001-2012,2014 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-2017,2019 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 *
@@ -35,7 +35,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_cchar.c,v 1.27 2014/02/01 22:10:42 tom Exp $")
+MODULE_ID("$Id: lib_cchar.c,v 1.32 2019/05/04 20:46:24 tom Exp $")
/*
* The SuSv2 description leaves some room for interpretation. We'll assume wch
@@ -47,22 +47,25 @@ NCURSES_EXPORT(int)
setcchar(cchar_t *wcval,
const wchar_t *wch,
const attr_t attrs,
- NCURSES_PAIRS_T color_pair,
+ NCURSES_PAIRS_T pair_arg,
const void *opts)
{
- unsigned i;
- unsigned len;
int code = OK;
+ int color_pair = pair_arg;
+ unsigned len;
TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%lu,%d,%p)"),
(void *) wcval, _nc_viswbuf(wch),
- (unsigned long) attrs, (int) color_pair, opts));
+ (unsigned long) attrs, color_pair, opts));
- if (opts != NULL
- || wch == NULL
- || ((len = (unsigned) wcslen(wch)) > 1 && wcwidth(wch[0]) < 0)) {
+ set_extended_pair(opts, color_pair);
+ if (wch == NULL
+ || ((len = (unsigned) wcslen(wch)) > 1 && _nc_wacs_width(wch[0]) < 0)
+ || color_pair < 0) {
code = ERR;
} else {
+ unsigned i;
+
if (len > CCHARW_MAX)
len = CCHARW_MAX;
@@ -71,7 +74,7 @@ setcchar(cchar_t *wcval,
* are only interested in adding non-spacing characters.
*/
for (i = 1; i < len; ++i) {
- if (wcwidth(wch[i]) != 0) {
+ if (_nc_wacs_width(wch[i]) != 0) {
len = i;
break;
}
@@ -96,21 +99,23 @@ NCURSES_EXPORT(int)
getcchar(const cchar_t *wcval,
wchar_t *wch,
attr_t *attrs,
- NCURSES_PAIRS_T *color_pair,
+ NCURSES_PAIRS_T *pair_arg,
void *opts)
{
- wchar_t *wp;
- int len;
int code = ERR;
+ int color_pair;
TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"),
(const void *) wcval,
(void *) wch,
(void *) attrs,
- (void *) color_pair,
+ (void *) pair_arg,
opts));
if (opts == NULL && wcval != NULL) {
+ wchar_t *wp;
+ int len;
+
len = ((wp = wmemchr(wcval->chars, L'\0', (size_t) CCHARW_MAX))
? (int) (wp - wcval->chars)
: CCHARW_MAX);
@@ -121,14 +126,17 @@ getcchar(const cchar_t *wcval,
* If the value is not a null, return the length plus 1 for null.
*/
code = (len < CCHARW_MAX) ? (len + 1) : CCHARW_MAX;
- } else if (attrs == 0 || color_pair == 0) {
+ } else if (attrs == 0 || pair_arg == 0) {
code = ERR;
} else if (len >= 0) {
*attrs = AttrOf(*wcval) & A_ATTRIBUTES;
- *color_pair = (NCURSES_PAIRS_T) GetPair(*wcval);
+ color_pair = GetPair(*wcval);
+ get_extended_pair(opts, color_pair);
+ *pair_arg = limit_PAIRS(color_pair);
wmemcpy(wch, wcval->chars, (size_t) len);
wch[len] = L'\0';
- code = OK;
+ if (*pair_arg >= 0)
+ code = OK;
}
}
diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c
index 71d560367d73..689101732fde 100644
--- a/ncurses/widechar/lib_get_wch.c
+++ b/ncurses/widechar/lib_get_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2011,2016 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,16 +40,13 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_get_wch.c,v 1.23 2011/05/28 23:00:29 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.24 2016/05/28 23:36:34 tom Exp $")
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;
- size_t count = 0;
int value = 0;
wchar_t wch;
#ifndef state_unused
@@ -64,8 +61,13 @@ wget_wch(WINDOW *win, wint_t *result)
*/
_nc_lock_global(curses);
sp = _nc_screen_of(win);
+
if (sp != 0) {
+ size_t count = 0;
+
for (;;) {
+ char buffer[(MB_LEN_MAX * 9) + 1]; /* allow some redundant shifts */
+
T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer)));
code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist
*) 0));
@@ -89,6 +91,8 @@ wget_wch(WINDOW *win, wint_t *result)
code = ERR;
break;
} else {
+ int status;
+
buffer[count++] = (char) UChar(value);
reset_mbytes(state);
status = count_mbytes(buffer, count, state);
diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c
index 27cdae0c1fd8..ce88023d1423 100644
--- a/ncurses/widechar/lib_get_wstr.c
+++ b/ncurses/widechar/lib_get_wstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2009,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2011,2018 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_get_wstr.c,v 1.13 2011/10/22 16:31:35 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.15 2018/09/01 20:13:00 tom Exp $")
static int
wadd_wint(WINDOW *win, wint_t *src)
@@ -100,6 +100,8 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
if (!win)
returnCode(ERR);
+ maxlen = _nc_getstr_limit(maxlen);
+
_nc_get_tty_mode(&buf);
oldnl = sp->_nl;
@@ -164,7 +166,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
} else {
beep();
}
- } else if (maxlen >= 0 && tmpstr - oldstr >= maxlen) {
+ } else if (tmpstr - oldstr >= maxlen) {
beep();
} else {
*tmpstr++ = ch;
diff --git a/ncurses/widechar/lib_hline_set.c b/ncurses/widechar/lib_hline_set.c
index da92b834f1c3..26813ae8e49c 100644
--- a/ncurses/widechar/lib_hline_set.c
+++ b/ncurses/widechar/lib_hline_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2010,2016 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,23 +39,21 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_hline_set.c,v 1.4 2010/12/19 01:45:03 tom Exp $")
+MODULE_ID("$Id: lib_hline_set.c,v 1.5 2016/05/28 23:36:34 tom Exp $")
NCURSES_EXPORT(int)
whline_set(WINDOW *win, const cchar_t *ch, int n)
{
int code = ERR;
- int start;
- int end;
T((T_CALLED("whline_set(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n));
if (win) {
struct ldat *line = &(win->_line[win->_cury]);
NCURSES_CH_T wch;
+ int start = win->_curx;
+ int end = start + n - 1;
- start = win->_curx;
- end = start + n - 1;
if (end > win->_maxx)
end = win->_maxx;
diff --git a/ncurses/widechar/lib_in_wch.c b/ncurses/widechar/lib_in_wch.c
index b2396508ba25..a665145c6b98 100644
--- a/ncurses/widechar/lib_in_wch.c
+++ b/ncurses/widechar/lib_in_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2006,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2009,2016 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,17 +39,19 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_in_wch.c,v 1.5 2009/10/24 22:37:55 tom Exp $")
+MODULE_ID("$Id: lib_in_wch.c,v 1.6 2016/05/28 23:36:34 tom Exp $")
NCURSES_EXPORT(int)
win_wch(WINDOW *win, cchar_t *wcval)
{
- int row, col;
int code = OK;
TR(TRACE_CCALLS, (T_CALLED("win_wch(%p,%p)"), (void *) win, (void *) wcval));
+
if (win != 0
&& wcval != 0) {
+ int row, col;
+
getyx(win, row, col);
*wcval = win->_line[row].text[col];
diff --git a/ncurses/widechar/lib_ins_wch.c b/ncurses/widechar/lib_ins_wch.c
index 2aa71a506639..12dc19c2a7ee 100644
--- a/ncurses/widechar/lib_ins_wch.c
+++ b/ncurses/widechar/lib_ins_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2017,2019 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_ins_wch.c,v 1.17 2011/10/22 16:34:50 tom Exp $")
+MODULE_ID("$Id: lib_ins_wch.c,v 1.23 2019/05/04 20:46:24 tom Exp $")
/*
* Insert the given character, updating the current location to simplify
@@ -48,8 +48,7 @@ MODULE_ID("$Id: lib_ins_wch.c,v 1.17 2011/10/22 16:34:50 tom Exp $")
NCURSES_EXPORT(int)
_nc_insert_wch(WINDOW *win, const cchar_t *wch)
{
- int cells = wcwidth(CharOf(CHDEREF(wch)));
- int cell;
+ int cells = _nc_wacs_width(CharOf(CHDEREF(wch)));
int code = OK;
if (cells < 0) {
@@ -59,6 +58,7 @@ _nc_insert_wch(WINDOW *win, const cchar_t *wch)
cells = 1;
if (win->_curx <= win->_maxx) {
+ int cell;
struct ldat *line = &(win->_line[win->_cury]);
NCURSES_CH_T *end = &(line->text[win->_curx]);
NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
@@ -73,7 +73,7 @@ _nc_insert_wch(WINDOW *win, const cchar_t *wch)
SetWidecExt(temp1[cell], cell);
}
- win->_curx++;
+ win->_curx = (NCURSES_SIZE_T) (win->_curx + cells);
}
}
return code;
@@ -82,15 +82,13 @@ _nc_insert_wch(WINDOW *win, const cchar_t *wch)
NCURSES_EXPORT(int)
wins_wch(WINDOW *win, const cchar_t *wch)
{
- NCURSES_SIZE_T oy;
- NCURSES_SIZE_T ox;
int code = ERR;
T((T_CALLED("wins_wch(%p, %s)"), (void *) win, _tracecchar_t(wch)));
if (win != 0) {
- oy = win->_cury;
- ox = win->_curx;
+ NCURSES_SIZE_T oy = win->_cury;
+ NCURSES_SIZE_T ox = win->_curx;
code = _nc_insert_wch(win, wch);
@@ -105,9 +103,6 @@ NCURSES_EXPORT(int)
wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
{
int code = ERR;
- NCURSES_SIZE_T oy;
- NCURSES_SIZE_T ox;
- const wchar_t *cp;
T((T_CALLED("wins_nwstr(%p,%s,%d)"),
(void *) win, _nc_viswbufn(wstr, n), n));
@@ -117,13 +112,15 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
if (n < 1)
n = (int) wcslen(wstr);
code = OK;
+
if (n > 0) {
+ const wchar_t *cp;
SCREEN *sp = _nc_screen_of(win);
+ NCURSES_SIZE_T oy = win->_cury;
+ NCURSES_SIZE_T ox = win->_curx;
- oy = win->_cury;
- ox = win->_curx;
- for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
- int len = wcwidth(*cp);
+ for (cp = wstr; ((cp - wstr) < n) && *cp; cp++) {
+ int len = _nc_wacs_width(*cp);
if ((len >= 0 && len != 1) || !is7bits(*cp)) {
cchar_t tmp_cchar;
diff --git a/ncurses/widechar/lib_inwstr.c b/ncurses/widechar/lib_inwstr.c
index a4f5b8ea2040..3443ec6cbcac 100644
--- a/ncurses/widechar/lib_inwstr.c
+++ b/ncurses/widechar/lib_inwstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2009,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2016,2017 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,31 +39,39 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_inwstr.c,v 1.6 2011/05/28 22:49:49 tom Exp $")
+MODULE_ID("$Id: lib_inwstr.c,v 1.8 2017/10/29 00:03:29 tom Exp $")
NCURSES_EXPORT(int)
winnwstr(WINDOW *win, wchar_t *wstr, int n)
{
- int row, col, inx;
int count = 0;
- int last = 0;
cchar_t *text;
- wchar_t wch;
T((T_CALLED("winnwstr(%p,%p,%d)"), (void *) win, (void *) wstr, n));
if (wstr != 0) {
if (win) {
+ int row, col;
+ int last = 0;
+ bool done = FALSE;
+
getyx(win, row, col);
text = win->_line[row].text;
- while (count < n && count != ERR) {
+ while (count < n && !done && count != ERR) {
+
if (!isWidecExt(text[col])) {
+ int inx;
+ wchar_t wch;
+
for (inx = 0; (inx < CCHARW_MAX)
&& ((wch = text[col].chars[inx]) != 0);
++inx) {
if (count + 1 > n) {
- if ((count = last) == 0) {
+ done = TRUE;
+ if (last == 0) {
count = ERR; /* error if we store nothing */
+ } else {
+ count = last; /* only store complete chars */
}
break;
}
diff --git a/ncurses/widechar/lib_key_name.c b/ncurses/widechar/lib_key_name.c
index da65f219c266..daf4ab022ae9 100644
--- a/ncurses/widechar/lib_key_name.c
+++ b/ncurses/widechar/lib_key_name.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2007,2017 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 *
@@ -35,7 +35,9 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_key_name.c,v 1.3 2008/10/11 20:15:14 tom Exp $")
+MODULE_ID("$Id: lib_key_name.c,v 1.4 2017/01/07 19:50:17 tom Exp $")
+
+#define MyData _nc_globals.key_name
NCURSES_EXPORT(NCURSES_CONST char *)
key_name(wchar_t c)
@@ -44,19 +46,16 @@ key_name(wchar_t c)
wchar_t *my_wchars;
size_t len;
- /* FIXME: move to _nc_globals */
- static char result[MB_LEN_MAX + 1];
-
memset(&my_cchar, 0, sizeof(my_cchar));
my_cchar.chars[0] = c;
my_cchar.chars[1] = L'\0';
my_wchars = wunctrl(&my_cchar);
- len = wcstombs(result, my_wchars, sizeof(result) - 1);
+ len = wcstombs(MyData, my_wchars, sizeof(MyData) - 1);
if (isEILSEQ(len) || (len == 0)) {
return 0;
}
- result[len] = '\0';
- return result;
+ MyData[len] = '\0';
+ return MyData;
}
diff --git a/ncurses/widechar/lib_slk_wset.c b/ncurses/widechar/lib_slk_wset.c
index 89275567557b..d3a148b13942 100644
--- a/ncurses/widechar/lib_slk_wset.c
+++ b/ncurses/widechar/lib_slk_wset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2003-2002,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 2003-2011,2016 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,23 +40,26 @@
#include <wctype.h>
#endif
-MODULE_ID("$Id: lib_slk_wset.c,v 1.13 2011/10/22 15:52:20 tom Exp $")
+MODULE_ID("$Id: lib_slk_wset.c,v 1.14 2016/05/28 23:36:34 tom Exp $")
NCURSES_EXPORT(int)
slk_wset(int i, const wchar_t *astr, int format)
{
int result = ERR;
- size_t arglen;
const wchar_t *str;
- char *mystr;
mbstate_t state;
T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format));
if (astr != 0) {
+ size_t arglen;
+
init_mb(state);
str = astr;
+
if ((arglen = wcsrtombs(NULL, &str, (size_t) 0, &state)) != (size_t) -1) {
+ char *mystr;
+
if ((mystr = (char *) _nc_doalloc(0, arglen + 1)) != 0) {
str = astr;
if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) {
diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c
index d5ae608e36ed..6a2346d570a3 100644
--- a/ncurses/widechar/lib_unget_wch.c
+++ b/ncurses/widechar/lib_unget_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2011,2016 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.15 2011/10/22 16:34:50 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.16 2016/05/28 23:36:34 tom Exp $")
/*
* Wrapper for wcrtomb() which obtains the length needed for the given
@@ -70,7 +70,6 @@ NCURSES_SP_NAME(unget_wch) (NCURSES_SP_DCLx const wchar_t wch)
int result = OK;
mbstate_t state;
size_t length;
- int n;
T((T_CALLED("unget_wch(%p, %#lx)"), (void *) SP_PARM, (unsigned long) wch));
@@ -82,6 +81,8 @@ NCURSES_SP_NAME(unget_wch) (NCURSES_SP_DCLx const wchar_t wch)
char *string;
if ((string = (char *) malloc(length)) != 0) {
+ int n;
+
init_mb(state);
/* ignore the result, since we already validated the character */
IGNORE_RC((int) wcrtomb(string, wch, &state));
diff --git a/ncurses/widechar/lib_vid_attr.c b/ncurses/widechar/lib_vid_attr.c
index 0be2b195c3d2..b0dfb6be9f82 100644
--- a/ncurses/widechar/lib_vid_attr.c
+++ b/ncurses/widechar/lib_vid_attr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2013,2014 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2018,2019 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 *
@@ -36,27 +36,34 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_vid_attr.c,v 1.22 2014/02/01 22:09:27 tom Exp $")
+MODULE_ID("$Id: lib_vid_attr.c,v 1.27 2019/04/13 22:40:48 tom Exp $")
#define doPut(mode) \
TPUTS_TRACE(#mode); \
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc)
#define TurnOn(mask, mode) \
- if ((turn_on & mask) && mode) { doPut(mode); }
+ if ((turn_on & mask) && mode) { \
+ TPUTS_TRACE(#mode); \
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \
+ }
#define TurnOff(mask, mode) \
- if ((turn_off & mask) && mode) { doPut(mode); turn_off &= ~mask; }
+ if ((turn_off & mask) && mode) { \
+ TPUTS_TRACE(#mode); \
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \
+ turn_off &= ~mask; \
+ }
/* if there is no current screen, assume we *can* do color */
#define SetColorsIf(why, old_attr, old_pair) \
if (can_color && (why)) { \
- TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \
- if ((pair != old_pair) \
- || (fix_pair0 && (pair == 0)) \
+ TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, color_pair)); \
+ if ((color_pair != old_pair) \
+ || (fix_pair0 && (color_pair == 0)) \
|| (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx \
- old_pair, pair, \
+ old_pair, color_pair, \
reverse, outc); \
} \
}
@@ -68,10 +75,11 @@ MODULE_ID("$Id: lib_vid_attr.c,v 1.22 2014/02/01 22:09:27 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
attr_t newmode,
- NCURSES_PAIRS_T pair,
- void *opts GCC_UNUSED,
+ NCURSES_PAIRS_T pair_arg,
+ void *opts OPTIONAL_PAIR,
NCURSES_SP_OUTC outc)
{
+ int color_pair = pair_arg;
#if NCURSES_EXT_COLORS
static attr_t previous_attr = A_NORMAL;
static int previous_pair = 0;
@@ -85,8 +93,12 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
#define fix_pair0 FALSE
#endif
+ if (!IsValidTIScreen(SP_PARM))
+ returnCode(ERR);
+
newmode &= A_ATTRIBUTES;
- T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
+ set_extended_pair(opts, color_pair);
+ T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), color_pair));
/* this allows us to go on whether or not newterm() has been called */
if (SP_PARM) {
@@ -107,7 +119,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
* If we have a terminal that cannot combine color with video
* attributes, use the colors in preference.
*/
- if ((pair != 0
+ if ((color_pair != 0
|| fix_pair0)
&& (no_color_video > 0)) {
/*
@@ -136,7 +148,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
}
if (newmode == previous_attr
- && pair == previous_pair)
+ && color_pair == previous_pair)
returnCode(OK);
if (reverse) {
@@ -144,9 +156,9 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
}
turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR;
- turn_on = (newmode & ~previous_attr) & ALL_BUT_COLOR;
+ turn_on = (newmode & ~(previous_attr & TPARM_ATTR)) & ALL_BUT_COLOR;
- SetColorsIf(((pair == 0) && !fix_pair0), previous_attr, previous_pair);
+ SetColorsIf(((color_pair == 0) && !fix_pair0), previous_attr, previous_pair);
if (newmode == A_NORMAL) {
if ((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
@@ -173,7 +185,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
previous_pair = 0;
}
- SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+ SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair);
} else if (set_attributes) {
if (turn_on || turn_off) {
TPUTS_TRACE("set_attributes");
@@ -201,7 +213,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
}
}
#endif
- SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+ SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair);
} else {
TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off)));
@@ -226,7 +238,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
previous_attr &= ALL_BUT_COLOR;
previous_pair = 0;
}
- SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+ SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair);
TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on)));
/* *INDENT-OFF* */
@@ -242,7 +254,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
#if USE_ITALIC
TurnOn(A_ITALIC, enter_italics_mode);
#endif
-#if USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode)
TurnOn(A_HORIZONTAL, enter_horizontal_hl_mode);
TurnOn(A_LEFT, enter_left_hl_mode);
TurnOn(A_LOW, enter_low_hl_mode);
@@ -259,16 +271,17 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
if (SP_PARM) {
SetAttr(SCREEN_ATTRS(SP_PARM), newmode);
- SetPair(SCREEN_ATTRS(SP_PARM), pair);
+ SetPair(SCREEN_ATTRS(SP_PARM), color_pair);
} else {
previous_attr = newmode;
- previous_pair = pair;
+ previous_pair = color_pair;
}
returnCode(OK);
#else
- T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), (int) pair));
- set_color(newmode, pair);
+ T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), color_pair));
+ (void) opts;
+ set_color(newmode, color_pair);
returnCode(NCURSES_SP_NAME(vidputs) (NCURSES_SP_ARGx newmode, outc));
#endif
}
@@ -276,14 +289,14 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
vid_puts(attr_t newmode,
- NCURSES_PAIRS_T pair,
+ NCURSES_PAIRS_T pair_arg,
void *opts GCC_UNUSED,
NCURSES_OUTC outc)
{
SetSafeOutcWrapper(outc);
return NCURSES_SP_NAME(vid_puts) (CURRENT_SCREEN,
newmode,
- pair,
+ pair_arg,
opts,
_nc_outc_wrapper);
}
@@ -293,22 +306,22 @@ vid_puts(attr_t newmode,
NCURSES_EXPORT(int)
NCURSES_SP_NAME(vid_attr) (NCURSES_SP_DCLx
attr_t newmode,
- NCURSES_PAIRS_T pair,
+ NCURSES_PAIRS_T pair_arg,
void *opts)
{
- T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), (int) pair));
+ T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), (int) pair_arg));
returnCode(NCURSES_SP_NAME(vid_puts) (NCURSES_SP_ARGx
newmode,
- pair,
+ pair_arg,
opts,
NCURSES_SP_NAME(_nc_putchar)));
}
#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
-vid_attr(attr_t newmode, NCURSES_PAIRS_T pair, void *opts)
+vid_attr(attr_t newmode, NCURSES_PAIRS_T pair_arg, void *opts)
{
- return NCURSES_SP_NAME(vid_attr) (CURRENT_SCREEN, newmode, pair, opts);
+ return NCURSES_SP_NAME(vid_attr) (CURRENT_SCREEN, newmode, pair_arg, opts);
}
#endif
@@ -325,6 +338,7 @@ NCURSES_SP_NAME(term_attrs) (NCURSES_SP_DCL0)
if (SP_PARM) {
attrs = NCURSES_SP_NAME(termattrs) (NCURSES_SP_ARG);
+#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode)
/* these are only supported for wide-character mode */
if (enter_horizontal_hl_mode)
attrs |= WA_HORIZONTAL;
@@ -338,6 +352,7 @@ NCURSES_SP_NAME(term_attrs) (NCURSES_SP_DCL0)
attrs |= WA_TOP;
if (enter_vertical_hl_mode)
attrs |= WA_VERTICAL;
+#endif
}
returnAttr(attrs);
diff --git a/ncurses/widechar/lib_vline_set.c b/ncurses/widechar/lib_vline_set.c
index 917caac44b44..585447aebcb2 100644
--- a/ncurses/widechar/lib_vline_set.c
+++ b/ncurses/widechar/lib_vline_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2010,2016 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,22 +39,21 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_vline_set.c,v 1.4 2010/12/19 01:50:50 tom Exp $")
+MODULE_ID("$Id: lib_vline_set.c,v 1.5 2016/05/28 23:36:34 tom Exp $")
NCURSES_EXPORT(int)
wvline_set(WINDOW *win, const cchar_t *ch, int n)
{
int code = ERR;
- int row, col;
- int end;
T((T_CALLED("wvline(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n));
if (win) {
NCURSES_CH_T wch;
- row = win->_cury;
- col = win->_curx;
- end = row + n - 1;
+ int row = win->_cury;
+ int col = win->_curx;
+ int end = row + n - 1;
+
if (end > win->_maxy)
end = win->_maxy;
diff --git a/ncurses/widechar/lib_wacs.c b/ncurses/widechar/lib_wacs.c
index dc3af21e11b2..da5b93e5495a 100644
--- a/ncurses/widechar/lib_wacs.c
+++ b/ncurses/widechar/lib_wacs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2013,2014 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2016,2018 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,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_wacs.c,v 1.14 2014/02/23 01:21:08 tom Exp $")
+MODULE_ID("$Id: lib_wacs.c,v 1.19 2018/05/05 17:26:44 tom Exp $")
NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 0;
@@ -106,7 +106,6 @@ _nc_init_wacs(void)
};
/* *INDENT-ON* */
- unsigned n, m;
int active = _nc_unicode_locale();
/*
@@ -120,9 +119,15 @@ _nc_init_wacs(void)
active ? "" : " not"));
if ((_nc_wacs = typeCalloc(cchar_t, ACS_LEN)) != 0) {
+ unsigned n;
for (n = 0; n < SIZEOF(table); ++n) {
+ unsigned m;
+#if NCURSES_WCWIDTH_GRAPHICS
int wide = wcwidth((wchar_t) table[n].value[active]);
+#else
+ int wide = 1;
+#endif
m = table[n].map;
if (active && (wide == 1)) {
@@ -133,9 +138,9 @@ _nc_init_wacs(void)
SetChar(_nc_wacs[m], table[n].value[0], A_NORMAL);
}
- T(("#%d, SetChar(%c, %#04x) = %s",
- n, m,
- table[n].value[active],
+ T(("#%d, width:%d SetChar(%c, %s) = %s",
+ n, wide, m,
+ _tracechar(table[n].value[active]),
_tracecchar_t(&_nc_wacs[m])));
}
}
diff --git a/ncurses/widechar/widechars.c b/ncurses/widechar/widechars.c
index 6951e2863fa0..28c362aa628c 100644
--- a/ncurses/widechar/widechars.c
+++ b/ncurses/widechar/widechars.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2012,2013 Free Software Foundation, Inc. *
+ * Copyright (c) 2012-2013,2018 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 *
@@ -30,9 +30,9 @@
#if USE_WIDEC_SUPPORT
-MODULE_ID("$Id: widechars.c,v 1.5 2013/03/02 18:55:51 tom Exp $")
+MODULE_ID("$Id: widechars.c,v 1.6 2018/06/24 00:06:37 tom Exp $")
-#if defined(__MINGW32__)
+#if defined(_WIN32)
/*
* MinGW has wide-character functions, but they do not work correctly.
*/
@@ -147,6 +147,6 @@ _nc_wctomb(char *s, wchar_t wc)
return result;
}
-#endif /* __MINGW32__ */
+#endif /* _WIN32 */
#endif /* USE_WIDEC_SUPPORT */