On Fri, 20 Jan 2023 09:32:38 -0700, Bob Beck wrote: > So isdigit(3) says in the first paragraph that > > 'The complete list of decimal digits is 0 and 1-9, in any locale.' > > Later on it says: > > 'On systems supporting non-ASCII single-byte character encodings, > different c arguments may correspond to the digits, and the results of > isdigit() may depend on the LC_CTYPE locale(1).' > > Argubly worring about non ASCII single byte character encodings > doesn't make sense for an OpenBSD man page, but setting that aside for > a minute it's the second part that is of concern.. "It may depend on > the LC_CTYPE locale()" - Ok, well does it or doesn't it?
On OpenBSD isdigit() never uses the locale, but you already knew that. > Various spec docs seem all over the place on this, so I am also > paging Dr. Posix in this email... Hi Philip! :) Is isdigit() > safe from being screwed up by locale or not? POSIX says that isdigit() may be influenced by the locale. Since LC_CTYPE defines the different character classes, of which "digit" is one, I think that part of the manual is correct as-is. However, perhaps we should make isdigit(3) match isalpha(3) like so: Index: lib/libc/gen/isdigit.3 =================================================================== RCS file: /cvs/src/lib/libc/gen/isdigit.3,v retrieving revision 1.13 diff -u -p -u -r1.13 isdigit.3 --- lib/libc/gen/isdigit.3 11 Sep 2022 06:38:10 -0000 1.13 +++ lib/libc/gen/isdigit.3 20 Jan 2023 16:58:20 -0000 @@ -51,7 +51,12 @@ The and .Fn isdigit_l functions test for any decimal-digit character. -The complete list of decimal digits is 0 and 1\(en9, in any locale. +In the C locale, the complete list of decimal digits is 0 and 1\(en9. +.Ox +always uses the C locale for these functions, +ignoring the global locale, the thread-specific locale, and the +.Fa locale +argument. .Sh RETURN VALUES These functions return zero if the character tests false or non-zero if the character tests true.