[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 30/30] Change `winwstr` to return wide character count instead of
From: |
G. Branden Robinson |
Subject: |
[PATCH 30/30] Change `winwstr` to return wide character count instead of `OK`. |
Date: |
Sat, 8 Jun 2024 07:20:49 -0500 |
ncurses/widechar/lib_inwstr.c (winwstr): Do it.
man/curs_inwstr.3x (RETURN VALUE, NOTES, PORTABILITY): Document it.
test/test_inwstr seems to work fine, except for the 'w' key which just
beeps. I ran it on the "INSTALL" file and exercised 'h', 'j', 'k', 'l',
'+' and '-'.
---
man/curs_inwstr.3x | 54 ++++++++++++++---------------------
ncurses/widechar/lib_inwstr.c | 15 +++-------
2 files changed, 26 insertions(+), 43 deletions(-)
diff --git a/man/curs_inwstr.3x b/man/curs_inwstr.3x
index 72d3f124f..f6c06d28b 100644
--- a/man/curs_inwstr.3x
+++ b/man/curs_inwstr.3x
@@ -98,24 +98,12 @@ .SH DESCRIPTION
.BR \%winwstr "."
\fB\%ncurses\fP(3X) describes the variants of these functions.
.SH RETURN VALUE
-.BR \%inwstr ","
-.BR \%winwstr ","
-.BR \%mvinwstr ","
-and
-.B \%mvwinwstr
-return
-.B OK
-on successful operation.
-.BR \%innwstr ","
-.BR \%winnwstr ","
-.BR \%mvinnwstr ","
-and
-.B \%mvwinnwstr
-return the count of wide characters copied from
+On successful operation,
+these functions return the count of wide characters copied from
.I win
to
.IR wstr "."
-All return
+They return
.B ERR
upon failure.
.BR \%innwstr ","
@@ -135,7 +123,7 @@ .SH RETURN VALUE
.PP
In
.IR \%ncurses ","
-they return
+these functions return
.B ERR
if
.bP
@@ -174,22 +162,6 @@ .SH NOTES
and
.B \%mvwinnwstr
is recommended instead.
-.PP
-Unlike
-.BR \%instr ","
-.BR \%winstr ","
-.BR \%mvinstr ","
-and
-.BR \%mvwinstr ","
-the wide-character functions
-.BR \%inwstr ","
-.BR \%winwstr ","
-.BR \%mvinwstr ","
-and
-.B \%mvwinwstr
-return
-.B OK
-rather than a (wide) character count.
.SH EXTENSIONS
.BR \%innwstr ","
.BR \%winnwstr ","
@@ -231,6 +203,24 @@ .SH PORTABILITY
.I \%ncurses
reports any truncation with
.BR ERR "."
+.PP
+X/Open Curses specifies
+.BR \%inwstr ","
+.BR \%winwstr ","
+.BR \%mvinwstr ","
+and
+.B \%mvwinwstr
+as returning
+.B OK
+rather than a (wide) character count,
+unlike their non-wide counterparts
+.BR \%instr ","
+.BR \%winstr ","
+.BR \%mvinstr ","
+and
+.BR \%mvwinstr "."
+.I \%ncurses
+regards this inconsistency as an error in the standard.
.SH SEE ALSO
\fB\%curs_instr\fP(3X) describes comparable functions of the
.I \%ncurses
diff --git a/ncurses/widechar/lib_inwstr.c b/ncurses/widechar/lib_inwstr.c
index b2fdaeac7..c97b6e1f1 100644
--- a/ncurses/widechar/lib_inwstr.c
+++ b/ncurses/widechar/lib_inwstr.c
@@ -93,22 +93,15 @@ 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;
+ int result = ERR;
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;
+ if (win != 0) {
+ result = winnwstr(win, wstr,
+ CCHARW_MAX * (win->_maxx - win->_curx + 1));
}
returnCode(result);
}
--
2.30.2
signature.asc
Description: PGP signature
- [PATCH 30/30] Change `winwstr` to return wide character count instead of `OK`.,
G. Branden Robinson <=