X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fwidechar%2Flib_inwstr.c;h=3443ec6cbcac4f9281a02eec2bd1517533ecc9dc;hp=a4f5b8ea2040b45b756550d3530a125075af47cb;hb=06078d3fa68db669ed37178c01873546b4b28745;hpb=d1a026123ac051716cdc16278345c1fb5c843b79 diff --git a/ncurses/widechar/lib_inwstr.c b/ncurses/widechar/lib_inwstr.c index a4f5b8ea..3443ec6c 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 -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; }