--- /home/ygrex/lib_addstr.c 2006-03-20 15:07:35.000000000 +0300 +++ lib_addstr.c 2006-03-20 15:26:41.000000000 +0300 @@ -58,7 +58,7 @@ waddnstr(WINDOW *win, const char *astr, TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); code = OK; if (n < 0) - n = (int) strlen(astr); + n = INT_MAX; TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); while ((n-- > 0) && (*str != '\0')) { @@ -90,13 +90,7 @@ waddchnstr(WINDOW *win, const chtype *as if (!win) returnCode(ERR); - if (n < 0) { - const chtype *str; - n = 0; - for (str = (const chtype *) astr; *str != 0; str++) - n++; - } - if (n > win->_maxx - x + 1) + if (n < 0 || n > win->_maxx - x + 1) n = win->_maxx - x + 1; if (n == 0) returnCode(code); @@ -114,16 +108,6 @@ waddchnstr(WINDOW *win, const chtype *as #if USE_WIDEC_SUPPORT NCURSES_EXPORT(int) -_nc_wchstrlen(const cchar_t *s) -{ - int result = 0; - while (CharOf(s[result]) != L'\0') { - result++; - } - return result; -} - -NCURSES_EXPORT(int) wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n) { static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); @@ -138,9 +122,8 @@ wadd_wchnstr(WINDOW *win, const cchar_t if (!win) returnCode(ERR); - if (n < 0) { - n = _nc_wchstrlen(astr); - } + if (n < 0) + for (n = 0; astr[n].chars[0] != '\0' && n < win->_maxx - x + 1; n++) if (n > win->_maxx - x + 1) n = win->_maxx - x + 1; if (n == 0) @@ -219,7 +202,7 @@ waddnwstr(WINDOW *win, const wchar_t *st TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); code = OK; if (n < 0) - n = (int) wcslen(str); + n = INT_MAX; TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); while ((n-- > 0) && (*str != L('\0'))) {