support OE/MVS
[p5sagit/p5-mst-13.2.git] / handy.h
diff --git a/handy.h b/handy.h
index 233304b..eb26ed8 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -119,7 +119,7 @@ typedef unsigned short      U16;
 #define U16_MAX PERL_USHORT_MAX
 #define U16_MIN PERL_USHORT_MIN
 
-#if BYTEORDER > 0x4321
+#if LONGSIZE > 4
   typedef int          I32;
   typedef unsigned int U32;
 # define I32_MAX PERL_INT_MAX
@@ -183,11 +183,20 @@ typedef unsigned short    U16;
 #define isSPACE(c) \
        ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) =='\r' || (c) == '\f')
 #define isDIGIT(c)     ((c) >= '0' && (c) <= '9')
-#define isUPPER(c)     ((c) >= 'A' && (c) <= 'Z')
-#define isLOWER(c)     ((c) >= 'a' && (c) <= 'z')
-#define isPRINT(c)     (((c) > 32 && (c) < 127) || isSPACE(c))
-#define toUPPER(c)     (isLOWER(c) ? (c) - ('a' - 'A') : (c))
-#define toLOWER(c)     (isUPPER(c) ? (c) + ('a' - 'A') : (c))
+#ifdef EBCDIC
+    /* In EBCDIC we do not do locales: therefore() isupper() is fine. */
+#   define isUPPER(c)  isupper(c)
+#   define isLOWER(c)  islower(c)
+#   define isPRINT(c)  isprint(c)
+#   define toUPPER(c)  toupper(c)
+#   define toLOWER(c)  tolower(c)
+#else
+#   define isUPPER(c)  ((c) >= 'A' && (c) <= 'Z')
+#   define isLOWER(c)  ((c) >= 'a' && (c) <= 'z')
+#   define isPRINT(c)  (((c) > 32 && (c) < 127) || isSPACE(c))
+#   define toUPPER(c)  (isLOWER(c) ? (c) - ('a' - 'A') : (c))
+#   define toLOWER(c)  (isUPPER(c) ? (c) + ('a' - 'A') : (c))
+#endif
 
 #ifdef USE_NEXT_CTYPE
 
@@ -238,8 +247,13 @@ typedef unsigned short     U16;
 #  endif
 #endif /* USE_NEXT_CTYPE */
 
-/* This conversion works both ways, strangely enough. */
-#define toCTRL(c)    (toUPPER(c) ^ 64)
+#ifdef EBCDIC
+EXT int ebcdic_control _((int));
+#  define toCTRL(c)    ebcdic_control(c)
+#else
+  /* This conversion works both ways, strangely enough. */
+#  define toCTRL(c)    (toUPPER(c) ^ 64)
+#endif
 
 /* Line numbers are unsigned, 16 bits. */
 typedef U16 line_t;
@@ -263,6 +277,9 @@ typedef U16 line_t;
 */
 
 #ifndef lint
+
+#define NEWSV(x,len)   newSV(len)
+
 #ifndef LEAKTEST
 
 #define New(x,v,n,t)   (v = (t*)safemalloc((MEM_SIZE)((n)*sizeof(t))))
@@ -274,7 +291,6 @@ typedef U16 line_t;
 #define Renewc(v,n,t,c) \
          (v = (c*)saferealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t))))
 #define Safefree(d)    safefree((Malloc_t)(d))
-#define NEWSV(x,len)   newSV(len)
 
 #else /* LEAKTEST */
 
@@ -287,7 +303,6 @@ typedef U16 line_t;
 #define Renewc(v,n,t,c) \
          (v = (c*)safexrealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t))))
 #define Safefree(d)    safexfree((Malloc_t)(d))
-#define NEWSV(x,len)   newSV(x,len)
 
 #define MAXXCOUNT 1400
 #define MAXY_SIZE 80