"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got patch: add flag to ignore whitespace?
To:
Omar Polo <op@omarpolo.com>
Cc:
Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Sun, 3 Jul 2022 13:10:21 +0200

Download raw body.

Thread
On Sun, Jul 03, 2022 at 11:46:15AM +0200, Omar Polo wrote:
> I thought it was safe.  I'm calling isspace with a char, so I'm
> expecting only 255 possible values, none of which should be mapped to
> weird codepoints.  (rethinking, I probably don't want to know what other
> system do :D)

Actually, all the ctype functions need a cast to unsigned char, like
this: isspace((unsigned char)ch);

I don't recall why, but there was a sweep throughout the entire
OpenBSD tree at some point to add such casts.
 
> Even if it were safe however, isspace is still too much here since it
> also match \f and some other characters.  Checking only ' ' and \t seems
> better.

Yes, in this case it seems best to restrict ourselves to ' ' and \t only.