This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
dist/IO: Allow to be dual-lived
authorKarl Williamson <public@khwilliamson.com>
Tue, 4 Mar 2014 23:13:36 +0000 (16:13 -0700)
committerKarl Williamson <public@khwilliamson.com>
Tue, 4 Mar 2014 23:40:51 +0000 (16:40 -0700)
This dual-lived module has not been able to be compiled on releases
earlier than 5.10.1 since, I believe, that release, and not outside of
blead since commit 6f2d5cbc in the 5.19 series, both due to using macros
that were not backported.

This commit suitably defines the current missing macro when it isn't
available.

dist/IO/IO.pm
dist/IO/IO.xs

index 6edf83c..ba89f0c 100644 (file)
@@ -7,7 +7,7 @@ use Carp;
 use strict;
 use warnings;
 
-our $VERSION = "1.30";
+our $VERSION = "1.31";
 XSLoader::load 'IO', $VERSION;
 
 sub import {
index 360b067..9056cb6 100644 (file)
@@ -69,6 +69,31 @@ not_here(const char *s)
     NORETURN_FUNCTION_END;
 }
 
+#ifndef UVCHR_IS_INVARIANT   /* For use with Perls without this macro */
+#   if ('A' == 65)
+#       define UVCHR_IS_INVARIANT(cp) ((cp) < 128)
+#   elif (defined(NATIVE_IS_INVARIANT)) /* EBCDIC on old Perl */
+#       define UVCHR_IS_INVARIANT(cp) ((cp) < 256 && NATIVE_IS_INVARIANT(cp))
+#   elif defined(isASCII)    /* EBCDIC on very old Perl */
+        /* In EBCDIC, the invariants are the code points corresponding to ASCII,
+         * plus all the controls.  All but one EBCDIC control is below SPACE; it
+         * varies depending on the code page, determined by the ord of '^' */
+#       define UVCHR_IS_INVARIANT(cp) (isASCII(cp)                            \
+                                       || (cp) < ' '                          \
+                                       || (('^' == 106)    /* POSIX-BC */     \
+                                          ? (cp) == 95                        \
+                                          : (cp) == 0xFF)) /* 1047 or 037 */
+#   else    /* EBCDIC on very very old Perl */
+        /* This assumes isascii() is available, but that could be fixed by
+         * having the macro test for each printable ASCII char */
+#       define UVCHR_IS_INVARIANT(cp) (isascii(cp)                            \
+                                       || (cp) < ' '                          \
+                                       || (('^' == 106)    /* POSIX-BC */     \
+                                          ? (cp) == 95                        \
+                                          : (cp) == 0xFF)) /* 1047 or 037 */
+#   endif
+#endif
+
 
 #ifndef PerlIO
 #define PerlIO_fileno(f) fileno(f)