1 /* wcsnwidth.c - compute display width of wide character string, up to max
2 specified width, return length. */
4 /* Copyright (C) 2012 Free Software Foundation, Inc.
6 This file is part of GNU Bash, the Bourne Again SHell.
8 Bash is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 Bash is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Bash. If not, see <http://www.gnu.org/licenses/>.
24 #if defined (HANDLE_MULTIBYTE)
30 /* Return the number of wide characters that will be displayed from wide string
31 PWCS. If the display width exceeds MAX, return the number of wide chars
32 from PWCS required to display MAX characters on the screen. */
34 wcsnwidth(pwcs, n, max)
43 while (n-- > 0 && (wc = *ws++) != L'\0')
48 else if (l == max - len)
50 else if (l > max - len)