Daniel Richard G. wrote:
So to make a long story short: After I add \x15 and remove \x25 to/from _C_CTYPE_CNTRL for EBCDIC, the test passes in the signed-char case.
Thanks, given all that history let's rewrite it so that the compiler can decide what '\n' maps to, that way it'll work even in EBCDIC environments that agree with IANA instead of IBM. I installed the attached patch, which should fix the bugs you mentioned.
From b3807b62cc5e4e06a74c69665cb171ef51b40567 Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Fri, 25 Sep 2015 19:45:59 -0700 Subject: [PATCH] c-ctype: port better to z/OS EBCDIC Problems reported by Daniel Richard G. in: http://lists.gnu.org/archive/html/bug-gnulib/2015-09/msg00050.html * lib/c-ctype.h (_C_CTYPE_CNTRL): Rewrite in terms of the C standard escapes and _C_CTYPE_OTHER_CNTRL. (_C_CTYPE_OTHER_CNTRL): New macro. * tests/test-c-ctype.c (test_all): Test from CHAR_MIN, not from SCHAR_MIN, as the functions are defined only from values promoted from char or from unsigned char, not necessarily from signed char. --- ChangeLog | 13 +++++++++++++ lib/c-ctype.h | 41 +++++++++++++++++++++++------------------ tests/test-c-ctype.c | 2 +- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3b3f101..a347908 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2015-09-25 Paul Eggert <egg...@cs.ucla.edu> + + c-ctype: port better to z/OS EBCDIC + Problems reported by Daniel Richard G. in: + http://lists.gnu.org/archive/html/bug-gnulib/2015-09/msg00050.html + * lib/c-ctype.h (_C_CTYPE_CNTRL): Rewrite in terms of + the C standard escapes and _C_CTYPE_OTHER_CNTRL. + (_C_CTYPE_OTHER_CNTRL): New macro. + * tests/test-c-ctype.c (test_all): Test from CHAR_MIN, not + from SCHAR_MIN, as the functions are defined only from values + promoted from char or from unsigned char, not necessarily from + signed char. + 2015-09-25 Pavel Raiskup <prais...@redhat.com> gnulib-common.m4: fix gl_PROG_AR_RANLIB/AM_PROG_AR clash diff --git a/lib/c-ctype.h b/lib/c-ctype.h index 1292fc8..88e001f 100644 --- a/lib/c-ctype.h +++ b/lib/c-ctype.h @@ -80,30 +80,35 @@ extern "C" { #define _C_CTYPE_SIGNED_EBCDIC ('A' < 0) +/* Cases for control characters. */ + +#define _C_CTYPE_CNTRL \ + case '\a': case '\b': case '\f': case '\n': \ + case '\r': case '\t': case '\v': \ + _C_CTYPE_OTHER_CNTRL + +/* ASCII control characters other than those with \-letter escapes. */ + #if C_CTYPE_ASCII -# define _C_CTYPE_CNTRL \ +# define _C_CTYPE_OTHER_CNTRL \ case '\x00': case '\x01': case '\x02': case '\x03': \ - case '\x04': case '\x05': case '\x06': case '\x07': \ - case '\x08': case '\x09': case '\x0a': case '\x0b': \ - case '\x0c': case '\x0d': case '\x0e': case '\x0f': \ - case '\x10': case '\x11': case '\x12': case '\x13': \ - case '\x14': case '\x15': case '\x16': case '\x17': \ - case '\x18': case '\x19': case '\x1a': case '\x1b': \ - case '\x1c': case '\x1d': case '\x1e': case '\x1f': \ - case '\x7f' + case '\x04': case '\x05': case '\x06': case '\x0e': \ + case '\x0f': case '\x10': case '\x11': case '\x12': \ + case '\x13': case '\x14': case '\x15': case '\x16': \ + case '\x17': case '\x18': case '\x19': case '\x1a': \ + case '\x1b': case '\x1c': case '\x1d': case '\x1e': \ + case '\x1f': case '\x7f' #else /* Use EBCDIC code page 1047's assignments for ASCII control chars; assume all EBCDIC code pages agree about these assignments. */ -# define _C_CTYPE_CNTRL \ +# define _C_CTYPE_OTHER_CNTRL \ case '\x00': case '\x01': case '\x02': case '\x03': \ - case '\x05': case '\x07': case '\x0b': case '\x0c': \ - case '\x0d': case '\x0e': case '\x0f': case '\x10': \ - case '\x11': case '\x12': case '\x13': case '\x16': \ - case '\x18': case '\x19': case '\x1c': case '\x1d': \ - case '\x1e': case '\x1f': case '\x25': case '\x26': \ - case '\x27': case '\x2d': case '\x2e': case '\x2f': \ - case '\x32': case '\x37': case '\x3c': case '\x3d': \ - case '\x3f' + case '\x07': case '\x0e': case '\x0f': case '\x10': \ + case '\x11': case '\x12': case '\x13': case '\x18': \ + case '\x19': case '\x1c': case '\x1d': case '\x1e': \ + case '\x1f': case '\x26': case '\x27': case '\x2d': \ + case '\x2e': case '\x32': case '\x37': case '\x3c': \ + case '\x3d': case '\x3f' #endif /* Cases for hex letter digits, digits, lower, and upper, offset by N. */ diff --git a/tests/test-c-ctype.c b/tests/test-c-ctype.c index d25dc03..544adeb 100644 --- a/tests/test-c-ctype.c +++ b/tests/test-c-ctype.c @@ -70,7 +70,7 @@ test_all (void) int c; int n_isascii = 0; - for (c = SCHAR_MIN; c <= UCHAR_MAX; c++) + for (c = CHAR_MIN; c <= UCHAR_MAX; c++) { if (c < 0) { -- 2.1.0