The current svn_ctype_* implementation depends on ASCII character encoding.
APR's ctype functions are portable, so use those on EBCDIC systems.

A somewhat surprising side effect is that svn messages become mostly
readable on z/OS with the help of svn_utf__cstring_from_utf8_fuzzy().

I thought it would be more readable to have one #if around the entire block
of svn_ctype_is* macros rather than around each individual macro.  I did not
want to create a second set of nearly duplicate Doxygen docs so I just
punted on those.  Let me know if you'd prefer to see it formatted
differently.

Greg

[[[ Use portable ctypes on EBCDIC systems ]]]
Index: subversion/include/svn_ctype.h
===================================================================
--- subversion/include/svn_ctype.h	(revision 947165)
+++ subversion/include/svn_ctype.h	(working copy)
@@ -31,6 +31,9 @@
 
 #include <apr.h>
 
+#if APR_CHARSET_EBCDIC
+#include <apr_lib.h>
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -76,6 +79,7 @@
 /** All printable ASCII */
 #define SVN_CTYPE_PRINT    (SVN_CTYPE_GRAPH | SVN_CTYPE_SPACE)
 
+#if !APR_CHARSET_EBCDIC
 
 /** Check if @a c is an ASCII control character. */
 #define svn_ctype_iscntrl(c)  svn_ctype_test((c), SVN_CTYPE_CNTRL)
@@ -114,6 +118,48 @@
 #define svn_ctype_isprint(c)  svn_ctype_test((c), SVN_CTYPE_PRINT)
 
 /** @} */
+
+#else /* EBCDIC - use the APR implementation */
+
+/** Check if c is a control character. */
+#define svn_ctype_iscntrl(c)  apr_iscntrl(c)
+
+/** Check if c is a whitespace character. */
+#define svn_ctype_isspace(c)  apr_isspace(c)
+
+/** Check if c is a digit. */
+#define svn_ctype_isdigit(c) apr_isdigit(c)
+
+/** Check if c is an uppercase letter. */
+#define svn_ctype_isupper(c)  apr_isupper(c)
+
+/** Check if c is a lowercase letter. */
+#define svn_ctype_islower(c)  apr_islower(c)
+
+/** Check if c is a punctuation mark. */
+#define svn_ctype_ispunct(c) apr_ispunct(c) 
+
+/** Check if c is a member of either the POSIX Portable Characters Set
+    or the POSIX Control Character Set. */
+#define svn_ctype_isascii(c) apr_isascii(c) 
+
+/** Check if c is a letter. */
+#define svn_ctype_isalpha(c) apr_isalpha(c) 
+
+/** Check if c is a letter or decimal digit. */
+#define svn_ctype_isalnum(c) apr_isalnum(c) 
+
+/** Check if c is a hexadecimal digit. */
+#define svn_ctype_isxdigit(c) apr_isxdigit(c)
+
+/** Check if c is a graphical (visible printable) character. */
+#define svn_ctype_isgraph(c) apr_isgraph(c) 
+
+/** Check if c is a printable character. */
+#define svn_ctype_isprint(c) apr_isprint(c) 
+
+#endif /* EBCDIC */
+
 
 /**
  * @defgroup ctype_extra Extended character classification

Reply via email to