/****************************************************************************
- * Copyright (c) 2002-2011,2016 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 *
#include <curses.priv.h>
-MODULE_ID("$Id: lib_inwstr.c,v 1.7 2016/05/28 23:36:34 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)
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;
&& ((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;
}