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

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Re: got patch: add flag to ignore whitespace?
To:
gameoftrees@openbsd.org
Date:
Sun, 3 Jul 2022 14:28:13 +0200

Download raw body.

Thread
  • Mark Jamsek:

    got patch: add flag to ignore whitespace?

  • Stefan Sperling:
    
    > 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.
    
    The is*() functions take an int argument, which may have the value
    of any char and additionally EOF.  The idea seems to be that you
    can feed the return value of, say, getchar() to is*().
    
    On architectures like x86 where char is signed by default, passing
    a char to an int parameter will sign-extend the value.  In particular,
    a char with value 0xff will turn into 0xffffffff, which is -1, which
    is typically the value of EOF.  Oops.
    
    -- 
    Christian "naddy" Weisgerber                          naddy@mips.inka.de
    
    
    
  • Mark Jamsek:

    got patch: add flag to ignore whitespace?