...
Code Block | ||
---|---|---|
| ||
size_t count_whitespace(char const *s, size_t length) { char const *t = s; /* possibly *t < 0 */ while (isspace(*t) && (t - s < length)) /* possibly *t < 0 */ ++t; return t - s; } |
Compliant Solution (Unsigned Char)
...
Code Block | ||
---|---|---|
| ||
size_t count_whitespace( const unsigned char *s, size_t length) { const unsigned char *t = s; while (isspace(*t) && (t - s < length)) ++t; return t - s; } |
...
Code Block | ||
---|---|---|
| ||
size_t count_whitespace( char const *s, size_t length) { char const *t = s; while (isspace((unsigned char)*t) && (t - s < length)) ++t; return t - s; } |
...