[PATCH] manual: document wcwidth and wcswidth [BZ #33740]

Vincent Lefevre vincent@vinc17.net
Tue Jul 14 18:32:25 GMT 2026


On 2026-07-14 17:30:28 +0200, Nikola Arlotti wrote:
> This patch documents functions wcwidth and wcswidth, solving bug
> #33740. CC'ing Arjun so he can add it to his stats for the next
> glibc contribution workshop ;)
> 
> Signed-off-by: Nikola Arlotti <nikola.arlotti@gmail.com>
> 
> ---
>  manual/ctype.texi | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/manual/ctype.texi b/manual/ctype.texi
> index d09249c6cf..0eeb3f77de 100644
> --- a/manual/ctype.texi
> +++ b/manual/ctype.texi
> @@ -380,6 +380,30 @@ by a successful call to @code{wctype}.
>  This function is declared in @file{wctype.h}.
>  @end deftypefun
>  
> +@deftypefun int wcwidth (wchar_t @var{wc})
> +@standards{POSIX, wchar.h}
> +@safety{@prelim{}@mtsafe{@mtslocale{}}@assafe{}@acsafe{}}
> +This function returns the number of collumns needed to represent

collumns -> columns

> +the wide character @var{wc}. If @var{wc} is a printable wide character,
> +the value is 0 or higher. If @var{wc} is a null-wide character (L'\0'),
> +the value is 0. Otherwise, this function returns -1.

Except that this description is ambiguous when the number of columns
for a printable wide character depends on the context. See

  https://sourceware.org/bugzilla/show_bug.cgi?id=33741

> +@pindex wchar.h
> +This function is declared in @file{wchar.h}.
> +@end deftypefun
> +
> +@deftypefun int wcswidth (const wchar_t @var{*s}, size_t @var{n})
> +@standards{POSIX, wchar.h}
> +@safety{@prelim{}@mtsafe{@mtslocale{}}@assafe{}@acsafe{}}
> +This function returns the number of collumns needed to represent

collumns -> columns

> +the wide character string pointed to by @var{*s}, but at most
> +@var{n} wide characters. If a nonprintable wide character occurs
> +among these characters, this function returns -1.

Same issue. See also the following bug:

  https://sourceware.org/bugzilla/show_bug.cgi?id=32322

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)


More information about the Libc-alpha mailing list