Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libc/string



On Fri, 22 Feb 2008, Joerg Sonnenberger wrote:
> Modified Files:
>       src/lib/libc/string: strcspn.c strpbrk.c strspn.c

This code makes the undocumented assumption that CHAR_BIT is 8.  I think
it's OK to make the assumption, given the hardware that NetBSD currently
runs on.  However, I would like it to be documented, at least in a
comment, but preferably with something like this:

        #if CHAR_BIT != 8
         #error "This code assumes that CHAR_BIT is 8"
        #endif

Also, I think the code will do the wrong thing in the case that char is
signed and the string contains characters with negative values; I think
it needs casts to (unsigned char) in a few places.

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index