]> Savannah Git Hosting - gnulib.git/commit
c-ctype: port better to EBCDIC
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Sep 2015 19:17:06 +0000 (12:17 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Sep 2015 19:18:18 +0000 (12:18 -0700)
commit7e2a8ea26c4bf72c6d143170cf2a0ebff5b50d65
tree35acec3e089ad968796f83afa566a9c995b55cf9
parent6439a0af0ca6b0256a4273a8ae0175e896bcc8da
c-ctype: port better to EBCDIC

Problems reported by Daniel Richard G. in
http://lists.gnu.org/archive/html/bug-gnulib/2015-09/msg00020.html
* lib/c-ctype.c: Include <limits.h>, for CHAR_MIN and CHAR_MAX.
Include "verify.h".
(C_CTYPE_ASCII, C_CTYPE_CONSECUTIVE_DIGITS)
(C_CTYPE_CONSECUTIVE_LOWERCASE, C_CTYPE_CONSECUTIVE_UPPERCASE):
Define as enum constants with value false, if not defined, so that
code can use 'if' instead of 'ifdef'.  Using 'if' helps make the
code more portable, as both branches of the 'if' are compiled on
all platforms.
(C_CTYPE_EBCDIC): New constant.
(to_char): New static function.
(c_isalnum, c_isalpha, c_isdigit, c_islower, c_isgraph, c_isprint)
(c_ispunct, c_isupper, c_isxdigit, c_tolower, c_toupper):
Rewrite to use 'if' instead of 'ifdef'.
Use to_char if non-ASCII.  Prefer <= to >=.
Prefer true and false to 1 and 0, for booleans.
(c_iscntrl): Use 'if', not 'ifdef'.  Special case for EBCDIC.
Verify that the character set is either ASCII or EBCDIC.
* tests/test-c-ctype.c: Include <limits.h>, for CHAR_MIN
(to_char): New function.
(test_all): Port to EBCDIC.  Add some more tests, e.g., for c_ispunct.
ChangeLog
lib/c-ctype.c
tests/test-c-ctype.c