manual: document wcwidth and wcswidth [BZ #33740]

Message ID 20260714153044.20782-1-nikola.arlotti@gmail.com (mailing list archive)
State New
Headers
Series manual: document wcwidth and wcswidth [BZ #33740] |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Test failed

Commit Message

Nikola Arlotti July 14, 2026, 3:30 p.m. UTC
  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(+)
  

Comments

Vincent Lefevre July 14, 2026, 6:32 p.m. UTC | #1
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
  
Andreas K. Huettel July 15, 2026, 11:35 a.m. UTC | #2
Am Mittwoch, 15. Juli 2026, 00:30:28 Japanische Normalzeit schrieb Nikola Arlotti:
> 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 ;)

Pure documentation enhancement.
Can still go in the release once it has a RB.

> 
> 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
> +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.
> +
> +@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
> +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.
> +
> +@pindex wchar.h
> +This function is declared in @file{wchar.h}.
> +@end deftypefun
> +
>  To make it easier to use the commonly-used classification functions,
>  they are defined in the C library.  There is no need to use
>  @code{wctype} if the property string is one of the known character
>
  

Patch

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
+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.
+
+@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
+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.
+
+@pindex wchar.h
+This function is declared in @file{wchar.h}.
+@end deftypefun
+
 To make it easier to use the commonly-used classification functions,
 they are defined in the C library.  There is no need to use
 @code{wctype} if the property string is one of the known character