Subject: Re: isprint() and isblank()
To: None <itojun@iijlab.net, tech-userlevel@netbsd.org>
From: Noriyuki Soda <soda@sra.co.jp>
List: tech-userlevel
Date: 01/21/2001 05:23:50
itojun-san wrote:
> the patch has bad sideeffect: isprint('\t') result will go strange
> unless you recompile your binary.
>
> isprint('\t') isblank('\t')
>
> used to be: false false (incorrect)
Strange.
I checked the behaviour on 1.4ish system and 1.5ish system.
And both systems returns correct answer as follows:
> correct one (if you recompile binaries and libc, it will be achieved):
> false true
Then, I checked our ctype.h and found the following definiton:
#if notyet
#define isblank(c) ((int)((_ctype_ + 1)[(int)(c)] & _B))
#endif
That is, the macro version of isblank() is never defined in NetBSD releases.
I next checked our isblank() implementation of libc. That is:
int
isblank(c)
int c;
{
return(c == ' ' || c == '\t');
}
So, the "_B" bit in _ctype_[] is only used for isprint() test,
and never used for isblank() test.
As itojun-san pointed out, we cannot set _B bit for '\t' character,
because it breaks isprint() implementation.
But it is not problem, because we do not actually use the _B bit,
and don't have to use it in future. We have to use for another
mechanism for isblank() implementation for loadable LC_CTYPE,
though.
--
soda