The isspace(3) man page is out of date

Message ID CAAHpriOJtTzYvQfE1Y1PSwi8PddS05M+pq-PxebdAndATr0PTg@mail.gmail.com
State New
Headers
Series The isspace(3) man page is out of date |

Commit Message

Keith Thompson Aug. 7, 2026, 10 p.m. UTC
  The isspace(3) man page incorrectly states that isspace(c) is defined
only when isascii(c) is true or c is EOF.

In fact, ISO C (going back to C89/C90) requires isspace(c) to work
correctly when c is either within the range of unsigned char or equal
to EOF (almost certainly 0..255 or -1 for systems supported by
newlib). The implementation of isspace() is correct; this is only a
documentation issue.

The other is*() functions work correctly and are documented correctly.

The following patch fixes this by copying the wording from isalpha().

I have *not* updated it to clarify just what "whitespace" means, but
it would probably be a good idea.

commit 932bca35395f3fc920b8d90b1f4bc07dc13efb93 (HEAD -> isspace-man-page)
Author: Keith Thompson <Keith.S.Thompson@gmail.com>
Date:   2026-08-07 14:50:36 -0700

    Correct isspace(3) man page (copied wording from isalpha(3))

 locale specified by the locale object locale.  If <[locale]> is
  

Comments

Keith Thompson Aug. 7, 2026, 10:19 p.m. UTC | #1
On Fri, Aug 7, 2026 at 3:00 PM Keith Thompson
<Keith.S.Thompson@gmail.com> wrote:
>
> The isspace(3) man page incorrectly states that isspace(c) is defined
> only when isascii(c) is true or c is EOF.
>
> In fact, ISO C (going back to C89/C90) requires isspace(c) to work
> correctly when c is either within the range of unsigned char or equal
> to EOF (almost certainly 0..255 or -1 for systems supported by
> newlib). The implementation of isspace() is correct; this is only a
> documentation issue.
>
> The other is*() functions work correctly and are documented correctly.
>
> The following patch fixes this by copying the wording from isalpha().
>
> I have *not* updated it to clarify just what "whitespace" means, but
> it would probably be a good idea.
>
> commit 932bca35395f3fc920b8d90b1f4bc07dc13efb93 (HEAD -> isspace-man-page)
> Author: Keith Thompson <Keith.S.Thompson@gmail.com>
> Date:   2026-08-07 14:50:36 -0700
>
>     Correct isspace(3) man page (copied wording from isalpha(3))
>
> diff --git newlib/libc/ctype/isspace.c newlib/libc/ctype/isspace.c
> index 0def2c0ce..784f4d7ae 100644
> --- newlib/libc/ctype/isspace.c
> +++ newlib/libc/ctype/isspace.c
> @@ -18,7 +18,8 @@ SYNOPSIS
>  DESCRIPTION
>  <<isspace>> is a macro which classifies singlebyte charset values by table
>  lookup.  It is a predicate returning non-zero for whitespace
> -characters, and 0 for other characters.  It is defined only when
> <<isascii>>(<[c]>) is true or <[c]> is EOF.
> +characters, and 0 for other characters.  It is defined only if
> +<[c]> is representable as an unsigned char or if <[c]> is EOF.
>
>  <<isspace_l>> is like <<isspace>> but performs the check based on the
>  locale specified by the locale object locale.  If <[locale]> is

Looking back at the history of
<git://sourceware.org/git/newlib-cygwin.git>, it appears that this was
corrected for several functions in 2013.  isspace() was apparently
overlooked.

commit cc88e009edc0ac57241551c8bff2ee21269a2fb6
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   2013-05-23 14:46:51 +0000
  
Jeff Johnston Aug. 13, 2026, 9:17 p.m. UTC | #2
Patch manually typed in (please attach patches in the future so e-mail
tools don't mess with the patch).

Thanks,

-- Jeff J.

On Fri, Aug 7, 2026 at 6:01 PM Keith Thompson <Keith.S.Thompson@gmail.com>
wrote:

> The isspace(3) man page incorrectly states that isspace(c) is defined
> only when isascii(c) is true or c is EOF.
>
> In fact, ISO C (going back to C89/C90) requires isspace(c) to work
> correctly when c is either within the range of unsigned char or equal
> to EOF (almost certainly 0..255 or -1 for systems supported by
> newlib). The implementation of isspace() is correct; this is only a
> documentation issue.
>
> The other is*() functions work correctly and are documented correctly.
>
> The following patch fixes this by copying the wording from isalpha().
>
> I have *not* updated it to clarify just what "whitespace" means, but
> it would probably be a good idea.
>
> commit 932bca35395f3fc920b8d90b1f4bc07dc13efb93 (HEAD -> isspace-man-page)
> Author: Keith Thompson <Keith.S.Thompson@gmail.com>
> Date:   2026-08-07 14:50:36 -0700
>
>     Correct isspace(3) man page (copied wording from isalpha(3))
>
> diff --git newlib/libc/ctype/isspace.c newlib/libc/ctype/isspace.c
> index 0def2c0ce..784f4d7ae 100644
> --- newlib/libc/ctype/isspace.c
> +++ newlib/libc/ctype/isspace.c
> @@ -18,7 +18,8 @@ SYNOPSIS
>  DESCRIPTION
>  <<isspace>> is a macro which classifies singlebyte charset values by table
>  lookup.  It is a predicate returning non-zero for whitespace
> -characters, and 0 for other characters.  It is defined only when
> <<isascii>>(<[c]>) is true or <[c]> is EOF.
> +characters, and 0 for other characters.  It is defined only if
> +<[c]> is representable as an unsigned char or if <[c]> is EOF.
>
>  <<isspace_l>> is like <<isspace>> but performs the check based on the
>  locale specified by the locale object locale.  If <[locale]> is
>
>
  

Patch

diff --git newlib/libc/ctype/isspace.c newlib/libc/ctype/isspace.c
index 0def2c0ce..784f4d7ae 100644
--- newlib/libc/ctype/isspace.c
+++ newlib/libc/ctype/isspace.c
@@ -18,7 +18,8 @@  SYNOPSIS
 DESCRIPTION
 <<isspace>> is a macro which classifies singlebyte charset values by table
 lookup.  It is a predicate returning non-zero for whitespace
-characters, and 0 for other characters.  It is defined only when
<<isascii>>(<[c]>) is true or <[c]> is EOF.
+characters, and 0 for other characters.  It is defined only if
+<[c]> is representable as an unsigned char or if <[c]> is EOF.

 <<isspace_l>> is like <<isspace>> but performs the check based on the