summaryrefslogtreecommitdiff
path: root/ncurses/widechar
diff options
context:
space:
mode:
Diffstat (limited to 'ncurses/widechar')
-rw-r--r--ncurses/widechar/charable.c9
-rw-r--r--ncurses/widechar/lib_add_wch.c12
-rw-r--r--ncurses/widechar/lib_box_set.c6
-rw-r--r--ncurses/widechar/lib_cchar.c8
-rw-r--r--ncurses/widechar/lib_get_wch.c10
-rw-r--r--ncurses/widechar/lib_get_wstr.c8
-rw-r--r--ncurses/widechar/lib_hline_set.c6
-rw-r--r--ncurses/widechar/lib_in_wch.c8
-rw-r--r--ncurses/widechar/lib_in_wchnstr.c10
-rw-r--r--ncurses/widechar/lib_ins_wch.c53
-rw-r--r--ncurses/widechar/lib_inwstr.c33
-rw-r--r--ncurses/widechar/lib_key_name.c6
-rw-r--r--ncurses/widechar/lib_pecho_wchar.c6
-rw-r--r--ncurses/widechar/lib_slk_wset.c8
-rw-r--r--ncurses/widechar/lib_unget_wch.c10
-rw-r--r--ncurses/widechar/lib_vid_attr.c26
-rw-r--r--ncurses/widechar/lib_vline_set.c6
-rw-r--r--ncurses/widechar/lib_wacs.c8
-rw-r--r--ncurses/widechar/lib_wunctrl.c13
-rw-r--r--ncurses/widechar/widechars.c12
20 files changed, 129 insertions, 129 deletions
diff --git a/ncurses/widechar/charable.c b/ncurses/widechar/charable.c
index 55d4890c8366..828ceb4a7463 100644
--- a/ncurses/widechar/charable.c
+++ b/ncurses/widechar/charable.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2025 Thomas E. Dickey *
* Copyright 2003-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,7 +33,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: charable.c,v 1.8 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: charable.c,v 1.9 2025/09/13 10:55:44 tom Exp $")
NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch)
{
@@ -52,9 +52,8 @@ NCURSES_EXPORT(int) _nc_to_char(wint_t ch)
#if HAVE_WCTOB
result = wctob(ch);
#elif HAVE_WCTOMB
- char temp[MB_LEN_MAX];
- result = wctomb(temp, ch);
- if (strlen(temp) == 1)
+ char temp[MB_LEN_MAX + 1];
+ if (wctomb(temp, ch) == 1)
result = UChar(temp[0]);
else
result = -1;
diff --git a/ncurses/widechar/lib_add_wch.c b/ncurses/widechar/lib_add_wch.c
index be1bbb051ad3..b72c2c8bad1b 100644
--- a/ncurses/widechar/lib_add_wch.c
+++ b/ncurses/widechar/lib_add_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 2004-2011,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <wctype.h>
#endif
-MODULE_ID("$Id: lib_add_wch.c,v 1.18 2023/07/15 17:34:12 tom Exp $")
+MODULE_ID("$Id: lib_add_wch.c,v 1.22 2025/01/19 00:51:54 tom Exp $")
/* clone/adapt lib_addch.c */
static const cchar_t blankchar = NewChar(BLANK_TEXT);
@@ -115,7 +115,7 @@ render_char(WINDOW *win, cchar_t ch)
#endif
static bool
-newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos)
+newline_forces_scroll(const WINDOW *win, NCURSES_SIZE_T *ypos)
{
bool result = FALSE;
@@ -307,7 +307,7 @@ wadd_wch_nosync(WINDOW *win, cchar_t ch)
/* the workhorse function -- add a character to the given window */
{
NCURSES_SIZE_T x, y;
- wchar_t *s;
+ const wchar_t *s;
int tabsize = 8;
#if USE_REENTRANT
SCREEN *sp = _nc_screen_of(win);
@@ -384,7 +384,7 @@ wadd_wch_nosync(WINDOW *win, cchar_t ch)
win->_flags &= ~_WRAPPED;
break;
default:
- if ((s = wunctrl(&ch)) != 0) {
+ if ((s = wunctrl(&ch)) != NULL) {
while (*s) {
cchar_t sch;
SetChar(sch, *s++, AttrOf(ch));
@@ -434,7 +434,7 @@ wecho_wchar(WINDOW *win, const cchar_t *wch)
{
int code = ERR;
- TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"),
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wecho_wchar(%p, %s)"),
(void *) win,
_tracecchar_t(wch)));
diff --git a/ncurses/widechar/lib_box_set.c b/ncurses/widechar/lib_box_set.c
index ef2e1a7d1583..9525cd0accc6 100644
--- a/ncurses/widechar/lib_box_set.c
+++ b/ncurses/widechar/lib_box_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-2009,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_box_set.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_box_set.c,v 1.8 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
wborder_set(WINDOW *win,
@@ -67,7 +67,7 @@ wborder_set(WINDOW *win,
if (!win)
returnCode(ERR);
-#define RENDER_WITH_DEFAULT(ch,def) w ##ch = _nc_render(win, (ch == 0) ? *(const ARG_CH_T)def : *ch)
+#define RENDER_WITH_DEFAULT(ch,def) w ##ch = _nc_render(win, (ch == NULL) ? *(const ARG_CH_T)def : *ch)
RENDER_WITH_DEFAULT(ls, WACS_VLINE);
RENDER_WITH_DEFAULT(rs, WACS_VLINE);
diff --git a/ncurses/widechar/lib_cchar.c b/ncurses/widechar/lib_cchar.c
index 451c5dcb518b..b535946161c5 100644
--- a/ncurses/widechar/lib_cchar.c
+++ b/ncurses/widechar/lib_cchar.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2022 Thomas E. Dickey *
+ * Copyright 2019-2022,2024 Thomas E. Dickey *
* Copyright 2001-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,7 +37,7 @@
#include <curses.priv.h>
#include <wchar.h>
-MODULE_ID("$Id: lib_cchar.c,v 1.38 2022/07/27 08:03:16 tom Exp $")
+MODULE_ID("$Id: lib_cchar.c,v 1.40 2024/12/07 18:07:52 tom Exp $")
/*
* The SuSv2 description leaves some room for interpretation. We'll assume wch
@@ -119,7 +119,7 @@ getcchar(const cchar_t *wcval,
} else
#endif
if (wcval != NULL) {
- wchar_t *wp;
+ const wchar_t *wp;
int len;
#if HAVE_WMEMCHR
@@ -135,7 +135,7 @@ 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 || pair_arg == 0) {
+ } else if (attrs == NULL || pair_arg == NULL) {
code = ERR;
} else if (len >= 0) {
int color_pair;
diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c
index 9f10d3bcf121..f8ae47a6912f 100644
--- a/ncurses/widechar/lib_get_wch.c
+++ b/ncurses/widechar/lib_get_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 2002-2011,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_get_wch.c,v 1.26 2021/04/17 16:12:54 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.28 2025/11/01 20:16:24 tom Exp $")
NCURSES_EXPORT(int)
wget_wch(WINDOW *win, wint_t *result)
@@ -62,7 +62,7 @@ wget_wch(WINDOW *win, wint_t *result)
_nc_lock_global(curses);
sp = _nc_screen_of(win);
- if (sp != 0) {
+ if (sp != NULL) {
size_t count = 0;
for (;;) {
@@ -103,7 +103,7 @@ wget_wch(WINDOW *win, wint_t *result)
code = ERR; /* the two calls should match */
safe_ungetch(SP_PARM, value);
}
- value = wch;
+ value = (int) wch;
break;
}
}
@@ -112,7 +112,7 @@ wget_wch(WINDOW *win, wint_t *result)
code = ERR;
}
- if (result != 0)
+ if (result != NULL)
*result = (wint_t) value;
_nc_unlock_global(curses);
diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c
index 3b3bd522c2d8..4aa9a0c46d6a 100644
--- a/ncurses/widechar/lib_get_wstr.c
+++ b/ncurses/widechar/lib_get_wstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2021,2023 Thomas E. Dickey *
+ * Copyright 2018-2023,2024 Thomas E. Dickey *
* Copyright 2002-2009,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,10 +40,10 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_get_wstr.c,v 1.21 2023/04/29 19:02:03 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.22 2024/07/27 19:22:23 tom Exp $")
static int
-wadd_wint(WINDOW *win, wint_t *src)
+wadd_wint(WINDOW *win, const wint_t *src)
{
cchar_t tmp;
wchar_t wch[2];
@@ -59,7 +59,7 @@ wadd_wint(WINDOW *win, wint_t *src)
* or other character, and handles reverse wraparound.
*/
static wint_t *
-WipeOut(WINDOW *win, int y, int x, wint_t *first, wint_t *last, int echoed)
+WipeOut(WINDOW *win, int y, int x, const wint_t *first, wint_t *last, int echoed)
{
if (last > first) {
*--last = '\0';
diff --git a/ncurses/widechar/lib_hline_set.c b/ncurses/widechar/lib_hline_set.c
index 8d5e02638a5a..3cb59c260954 100644
--- a/ncurses/widechar/lib_hline_set.c
+++ b/ncurses/widechar/lib_hline_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-2010,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_hline_set.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_hline_set.c,v 1.7 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
whline_set(WINDOW *win, const cchar_t *ch, int n)
@@ -60,7 +60,7 @@ whline_set(WINDOW *win, const cchar_t *ch, int n)
CHANGED_RANGE(line, start, end);
- if (ch == 0)
+ if (ch == NULL)
wch = *WACS_HLINE;
else
wch = *ch;
diff --git a/ncurses/widechar/lib_in_wch.c b/ncurses/widechar/lib_in_wch.c
index 1d27332279a7..a401305dc17d 100644
--- a/ncurses/widechar/lib_in_wch.c
+++ b/ncurses/widechar/lib_in_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-2009,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_in_wch.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_in_wch.c,v 1.8 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
win_wch(WINDOW *win, cchar_t *wcval)
@@ -49,8 +49,8 @@ win_wch(WINDOW *win, cchar_t *wcval)
TR(TRACE_CCALLS, (T_CALLED("win_wch(%p,%p)"), (void *) win, (void *) wcval));
- if (win != 0
- && wcval != 0) {
+ if (win != NULL
+ && wcval != NULL) {
int row, col;
getyx(win, row, col);
diff --git a/ncurses/widechar/lib_in_wchnstr.c b/ncurses/widechar/lib_in_wchnstr.c
index 40a2bb62b419..6f24888ba1d3 100644
--- a/ncurses/widechar/lib_in_wchnstr.c
+++ b/ncurses/widechar/lib_in_wchnstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-2007,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_in_wchnstr.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_in_wchnstr.c,v 1.11 2024/12/07 18:03:14 tom Exp $")
NCURSES_EXPORT(int)
win_wchnstr(WINDOW *win, cchar_t *wchstr, int n)
@@ -48,9 +48,9 @@ win_wchnstr(WINDOW *win, cchar_t *wchstr, int n)
int code = OK;
T((T_CALLED("win_wchnstr(%p,%p,%d)"), (void *) win, (void *) wchstr, n));
- if (win != 0
- && wchstr != 0) {
- NCURSES_CH_T *src;
+ if (win != NULL
+ && wchstr != NULL) {
+ const NCURSES_CH_T *src;
int row, col;
int j, k, limit;
diff --git a/ncurses/widechar/lib_ins_wch.c b/ncurses/widechar/lib_ins_wch.c
index ecaabcc9b73e..d880ff14f932 100644
--- a/ncurses/widechar/lib_ins_wch.c
+++ b/ncurses/widechar/lib_ins_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2020,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 2002-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_ins_wch.c,v 1.29 2023/11/21 21:53:28 tom Exp $")
+MODULE_ID("$Id: lib_ins_wch.c,v 1.34 2025/06/21 22:26:21 tom Exp $")
/*
* Insert the given character, updating the current location to simplify
@@ -63,7 +63,7 @@ _nc_insert_wch(WINDOW *win, const cchar_t *wch)
struct ldat *line = &(win->_line[win->_cury]);
NCURSES_CH_T *end = &(line->text[win->_curx]);
NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
- NCURSES_CH_T *temp2 = temp1 - cells;
+ const NCURSES_CH_T *temp2 = temp1 - cells;
CHANGED_TO_EOL(line, win->_curx, win->_maxx);
while (temp1 > end)
@@ -87,7 +87,7 @@ wins_wch(WINDOW *win, const cchar_t *wch)
T((T_CALLED("wins_wch(%p, %s)"), (void *) win, _tracecchar_t(wch)));
- if (win != 0) {
+ if (win != NULL) {
NCURSES_SIZE_T oy = win->_cury;
NCURSES_SIZE_T ox = win->_curx;
@@ -100,6 +100,14 @@ wins_wch(WINDOW *win, const cchar_t *wch)
returnCode(code);
}
+static int
+flush_wchars(WINDOW *win, wchar_t *wchars)
+{
+ cchar_t tmp_cchar;
+ (void) setcchar(&tmp_cchar, wchars, WA_NORMAL, (short) 0, (void *) 0);
+ return _nc_insert_wch(win, &tmp_cchar);
+}
+
NCURSES_EXPORT(int)
wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
{
@@ -108,9 +116,8 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
T((T_CALLED("wins_nwstr(%p,%s,%d)"),
(void *) win, _nc_viswbufn(wstr, n), n));
- if (win != 0
- && wstr != 0
- && n != 0) {
+ if (win != NULL
+ && wstr != NULL) {
if (n < 0) {
n = INT_MAX;
@@ -122,27 +129,37 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
SCREEN *sp = _nc_screen_of(win);
NCURSES_SIZE_T oy = win->_cury;
NCURSES_SIZE_T ox = win->_curx;
+ wchar_t tmp_wchars[1 + CCHARW_MAX];
+ int num_wchars = 0;
for (cp = wstr; ((cp - wstr) < n) && (*cp != L'\0'); cp++) {
int len = _nc_wacs_width(*cp);
- if ((len >= 0 && len != 1) || !is7bits(*cp)) {
- cchar_t tmp_cchar;
- wchar_t tmp_wchar = *cp;
- memset(&tmp_cchar, 0, sizeof(tmp_cchar));
- (void) setcchar(&tmp_cchar,
- &tmp_wchar,
- WA_NORMAL,
- (short) 0,
- (void *) 0);
- code = _nc_insert_wch(win, &tmp_cchar);
- } else {
+ if (is7bits(*cp) && len <= 0) {
+ if (num_wchars) {
+ if ((code = flush_wchars(win, tmp_wchars)) != OK)
+ break;
+ num_wchars = 0;
+ }
/* tabs, other ASCII stuff */
code = _nc_insert_ch(sp, win, (chtype) (*cp));
+ } else {
+ if (num_wchars > 0 && len > 0) {
+ if ((code = flush_wchars(win, tmp_wchars)) != OK)
+ break;
+ num_wchars = 0;
+ }
+ if (num_wchars < CCHARW_MAX) {
+ tmp_wchars[num_wchars++] = *cp;
+ tmp_wchars[num_wchars] = L'\0';
+ }
}
if (code != OK)
break;
}
+ if (code == OK && num_wchars) {
+ code = flush_wchars(win, tmp_wchars);
+ }
win->_curx = ox;
win->_cury = oy;
diff --git a/ncurses/widechar/lib_inwstr.c b/ncurses/widechar/lib_inwstr.c
index b2fdaeac7171..5f82c2eff586 100644
--- a/ncurses/widechar/lib_inwstr.c
+++ b/ncurses/widechar/lib_inwstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 2002-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,22 +34,22 @@
/*
** lib_inwstr.c
**
-** The routines winnwstr() and winwstr().
+** The routine winnwstr().
**
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_inwstr.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_inwstr.c,v 1.14 2025/01/19 00:51:54 tom Exp $")
NCURSES_EXPORT(int)
winnwstr(WINDOW *win, wchar_t *wstr, int n)
{
int count = 0;
- cchar_t *text;
+ const cchar_t *text;
T((T_CALLED("winnwstr(%p,%p,%d)"), (void *) win, (void *) wstr, n));
- if (wstr != 0) {
+ if (wstr != NULL) {
if (win) {
int row, col;
int last = 0;
@@ -57,6 +57,9 @@ winnwstr(WINDOW *win, wchar_t *wstr, int n)
getyx(win, row, col);
+ if (n < 0)
+ n = CCHARW_MAX * (win->_maxx - win->_curx + 1);
+
text = win->_line[row].text;
while (count < n && !done && count != ERR) {
@@ -92,23 +95,3 @@ winnwstr(WINDOW *win, wchar_t *wstr, int n)
}
returnCode(count);
}
-
-/*
- * X/Open says winwstr() returns OK if not ERR. If that is not a blunder, it
- * must have a null termination on the string (see above). Unlike winnstr(),
- * it does not define what happens for a negative count with winnwstr().
- */
-NCURSES_EXPORT(int)
-winwstr(WINDOW *win, wchar_t *wstr)
-{
- int result = OK;
-
- T((T_CALLED("winwstr(%p,%p)"), (void *) win, (void *) wstr));
- if (win == 0) {
- result = ERR;
- } else if (winnwstr(win, wstr,
- CCHARW_MAX * (win->_maxx - win->_curx + 1)) == ERR) {
- result = ERR;
- }
- returnCode(result);
-}
diff --git a/ncurses/widechar/lib_key_name.c b/ncurses/widechar/lib_key_name.c
index 379bdc2d48dd..c85909fe6b88 100644
--- a/ncurses/widechar/lib_key_name.c
+++ b/ncurses/widechar/lib_key_name.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 2007-2008,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_key_name.c,v 1.6 2023/06/03 12:15:34 tom Exp $")
+MODULE_ID("$Id: lib_key_name.c,v 1.7 2024/07/27 19:23:59 tom Exp $")
#define MyData _nc_globals.key_name
@@ -44,7 +44,7 @@ NCURSES_EXPORT(NCURSES_CONST char *)
key_name(wchar_t c)
{
cchar_t my_cchar;
- wchar_t *my_wchars;
+ const wchar_t *my_wchars;
size_t len;
NCURSES_CONST char *result = NULL;
diff --git a/ncurses/widechar/lib_pecho_wchar.c b/ncurses/widechar/lib_pecho_wchar.c
index 502967fd4e4d..617ee3e4b36b 100644
--- a/ncurses/widechar/lib_pecho_wchar.c
+++ b/ncurses/widechar/lib_pecho_wchar.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2024 Thomas E. Dickey *
* Copyright 2004,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,14 +33,14 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_pecho_wchar.c,v 1.4 2021/10/23 17:07:56 tom Exp $")
+MODULE_ID("$Id: lib_pecho_wchar.c,v 1.5 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
pecho_wchar(WINDOW *pad, const cchar_t *wch)
{
T((T_CALLED("pecho_wchar(%p, %s)"), (void *) pad, _tracech_t(wch)));
- if (pad == 0)
+ if (pad == NULL)
returnCode(ERR);
if (!IS_PAD(pad))
diff --git a/ncurses/widechar/lib_slk_wset.c b/ncurses/widechar/lib_slk_wset.c
index 5aa75ff962f0..eb4c10a1212f 100644
--- a/ncurses/widechar/lib_slk_wset.c
+++ b/ncurses/widechar/lib_slk_wset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2003-2011,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,7 +41,7 @@
#include <wctype.h>
#endif
-MODULE_ID("$Id: lib_slk_wset.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slk_wset.c,v 1.16 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
slk_wset(int i, const wchar_t *astr, int format)
@@ -52,7 +52,7 @@ slk_wset(int i, const wchar_t *astr, int format)
T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format));
- if (astr != 0) {
+ if (astr != NULL) {
size_t arglen;
init_mb(state);
@@ -61,7 +61,7 @@ slk_wset(int i, const wchar_t *astr, int format)
if ((arglen = wcsrtombs(NULL, &str, (size_t) 0, &state)) != (size_t) -1) {
char *mystr;
- if ((mystr = (char *) _nc_doalloc(0, arglen + 1)) != 0) {
+ if ((mystr = (char *) _nc_doalloc(NULL, arglen + 1)) != NULL) {
str = astr;
if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) {
/* glibc documentation claims that the terminating L'\0'
diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c
index 1a81fecc8705..9f3308bc389b 100644
--- a/ncurses/widechar/lib_unget_wch.c
+++ b/ncurses/widechar/lib_unget_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 2002-2011,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_unget_wch.c,v 1.18 2023/06/03 12:50:52 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.19 2024/12/07 20:08:15 tom Exp $")
/*
* Wrapper for wcrtomb() which obtains the length needed for the given
@@ -51,7 +51,7 @@ _nc_wcrtomb(char *target, wchar_t source, mbstate_t * state)
{
int result;
- if (target == 0) {
+ if (target == NULL) {
wchar_t temp[2];
const wchar_t *tempp = temp;
temp[0] = source;
@@ -75,13 +75,13 @@ NCURSES_SP_NAME(unget_wch) (NCURSES_SP_DCLx const wchar_t wch)
T((T_CALLED("unget_wch(%p, %#lx)"), (void *) SP_PARM, (unsigned long) wch));
init_mb(state);
- length = _nc_wcrtomb(0, wch, &state);
+ length = _nc_wcrtomb(NULL, wch, &state);
if (length != (size_t) (-1)
&& length != 0) {
char *string;
- if ((string = (char *) malloc(length)) != 0) {
+ if ((string = (char *) malloc(length)) != NULL) {
int n;
init_mb(state);
diff --git a/ncurses/widechar/lib_vid_attr.c b/ncurses/widechar/lib_vid_attr.c
index f108b307d9a7..864f73e9cb3b 100644
--- a/ncurses/widechar/lib_vid_attr.c
+++ b/ncurses/widechar/lib_vid_attr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2023 Thomas E. Dickey *
+ * Copyright 2018-2023,2024 Thomas E. Dickey *
* Copyright 2002-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,7 +37,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_vid_attr.c,v 1.31 2023/04/28 20:59:34 tom Exp $")
+MODULE_ID("$Id: lib_vid_attr.c,v 1.32 2024/12/07 20:08:59 tom Exp $")
#define doPut(mode) \
TPUTS_TRACE(#mode); \
@@ -87,9 +87,9 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
attr_t turn_on, turn_off;
bool reverse = FALSE;
- bool can_color = (SP_PARM == 0 || SP_PARM->_coloron);
+ bool can_color = (SP_PARM == NULL || SP_PARM->_coloron);
#if NCURSES_EXT_FUNCS
- bool fix_pair0 = (SP_PARM != 0 && SP_PARM->_coloron && !SP_PARM->_default_color);
+ bool fix_pair0 = (SP_PARM != NULL && SP_PARM->_coloron && !SP_PARM->_default_color);
#else
#define fix_pair0 FALSE
#endif
@@ -193,15 +193,15 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
TPUTS_TRACE("set_attributes");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
TIPARM_9(set_attributes,
- (newmode & A_STANDOUT) != 0,
- (newmode & A_UNDERLINE) != 0,
- (newmode & A_REVERSE) != 0,
- (newmode & A_BLINK) != 0,
- (newmode & A_DIM) != 0,
- (newmode & A_BOLD) != 0,
- (newmode & A_INVIS) != 0,
- (newmode & A_PROTECT) != 0,
- (newmode & A_ALTCHARSET) != 0),
+ (newmode & A_STANDOUT) != 0,
+ (newmode & A_UNDERLINE) != 0,
+ (newmode & A_REVERSE) != 0,
+ (newmode & A_BLINK) != 0,
+ (newmode & A_DIM) != 0,
+ (newmode & A_BOLD) != 0,
+ (newmode & A_INVIS) != 0,
+ (newmode & A_PROTECT) != 0,
+ (newmode & A_ALTCHARSET) != 0),
1, outc);
previous_attr &= ALL_BUT_COLOR;
previous_pair = 0;
diff --git a/ncurses/widechar/lib_vline_set.c b/ncurses/widechar/lib_vline_set.c
index f7bb5819b6df..e7af3bfefcf2 100644
--- a/ncurses/widechar/lib_vline_set.c
+++ b/ncurses/widechar/lib_vline_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-2010,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_vline_set.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_vline_set.c,v 1.7 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
wvline_set(WINDOW *win, const cchar_t *ch, int n)
@@ -58,7 +58,7 @@ wvline_set(WINDOW *win, const cchar_t *ch, int n)
if (end > win->_maxy)
end = win->_maxy;
- if (ch == 0)
+ if (ch == NULL)
wch = *WACS_VLINE;
else
wch = *ch;
diff --git a/ncurses/widechar/lib_wacs.c b/ncurses/widechar/lib_wacs.c
index 5b6f6da28936..d88279afd205 100644
--- a/ncurses/widechar/lib_wacs.c
+++ b/ncurses/widechar/lib_wacs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2024 Thomas E. Dickey *
* Copyright 2002-2015,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,9 +33,9 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_wacs.c,v 1.20 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_wacs.c,v 1.21 2024/12/07 20:08:32 tom Exp $")
-NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 0;
+NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = NULL;
NCURSES_EXPORT(void)
_nc_init_wacs(void)
@@ -119,7 +119,7 @@ _nc_init_wacs(void)
T(("initializing WIDE-ACS map (Unicode is%s active)",
active ? "" : " not"));
- if ((_nc_wacs = typeCalloc(cchar_t, ACS_LEN)) != 0) {
+ if ((_nc_wacs = typeCalloc(cchar_t, ACS_LEN)) != NULL) {
unsigned n;
for (n = 0; n < SIZEOF(table); ++n) {
diff --git a/ncurses/widechar/lib_wunctrl.c b/ncurses/widechar/lib_wunctrl.c
index 155da22926ba..259b68aa217f 100644
--- a/ncurses/widechar/lib_wunctrl.c
+++ b/ncurses/widechar/lib_wunctrl.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2001-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,17 +36,18 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_wunctrl.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_wunctrl.c,v 1.19 2024/12/07 18:03:14 tom Exp $")
NCURSES_EXPORT(wchar_t *)
NCURSES_SP_NAME(wunctrl) (NCURSES_SP_DCLx cchar_t *wc)
{
- static wchar_t str[CCHARW_MAX + 1], *wsp;
+ static wchar_t str[CCHARW_MAX + 1];
wchar_t *result;
- if (wc == 0) {
- result = 0;
- } else if (SP_PARM != 0 && Charable(*wc)) {
+ if (wc == NULL) {
+ result = NULL;
+ } else if (SP_PARM != NULL && Charable(*wc)) {
+ wchar_t *wsp;
const char *p =
NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx
(unsigned) _nc_to_char((wint_t)CharOf(*wc)));
diff --git a/ncurses/widechar/widechars.c b/ncurses/widechar/widechars.c
index d05ba98a8265..6ea008ddad65 100644
--- a/ncurses/widechar/widechars.c
+++ b/ncurses/widechar/widechars.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -31,9 +31,9 @@
#if USE_WIDEC_SUPPORT
-MODULE_ID("$Id: widechars.c,v 1.9 2020/08/29 16:22:03 juergen Exp $")
+MODULE_ID("$Id: widechars.c,v 1.11 2025/02/20 01:02:09 tom Exp $")
-#if (defined(_NC_WINDOWS)) && !defined(_NC_MSC)
+#if defined(_NC_MINGW)
/*
* MinGW has wide-character functions, but they do not work correctly.
*/
@@ -45,7 +45,7 @@ _nc_mbtowc(wchar_t *pwc, const char *s, size_t n)
int count;
int try;
- if (s != 0 && n != 0) {
+ if (s != NULL && n != 0) {
/*
* MultiByteToWideChar() can decide to return more than one
* wide-character. We want only one. Ignore any trailing null, both
@@ -96,7 +96,7 @@ _nc_mblen(const char *s, size_t n)
int count;
wchar_t temp;
- if (s != 0 && n != 0) {
+ if (s != NULL && n != 0) {
count = _nc_mbtowc(&temp, s, n);
if (count == 1) {
int check = WideCharToMultiByte(CP_UTF8,
@@ -148,6 +148,6 @@ _nc_wctomb(char *s, wchar_t wc)
return result;
}
-#endif /* _NC_WINDOWS */
+#endif /* _NC_MINGW */
#endif /* USE_WIDEC_SUPPORT */