This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
parts/inc/misc: Backport UNI to/from NATIVE
authorKarl Williamson <khw@cpan.org>
Wed, 9 Oct 2019 15:05:06 +0000 (09:05 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 8 Nov 2019 19:01:12 +0000 (12:01 -0700)
And change the way we setup similar defines.  On perls before EBCDIC
existed, these simply return their arguments.  But a module now can
unconditionally include these, and it will do the right thing.

(cherry picked from commit e836478411ddc77f5155d0fd4e4f2a25f28dc47e)
Signed-off-by: Nicolas R <atoomic@cpan.org>
dist/Devel-PPPort/parts/inc/misc

index 1743e5d..a58e825 100644 (file)
@@ -284,20 +284,20 @@ typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*);
 # endif
 #endif
 
-/* On versions without this, only ASCII is supported */
-#ifdef NATIVE_TO_ASCII
+/* On versions without NATIVE_TO_ASCII, only ASCII is supported */
+#if defined(EBCDIC) && defined(NATIVE_TO_ASCI)
 __UNDEFINED__ NATIVE_TO_LATIN1(c) NATIVE_TO_ASCII(c)
-#else
-__UNDEFINED__ NATIVE_TO_LATIN1(c) (c)
-#endif
-
-#ifdef ASCII_TO_NATIVE
 __UNDEFINED__ LATIN1_TO_NATIVE(c) ASCII_TO_NATIVE(c)
+__UNDEFINED__ NATIVE_TO_UNI(c) ((c) > 255 ? (c) : NATIVE_TO_LATIN1(c))
+__UNDEFINED__ UNI_TO_NATIVE(c) ((c) > 255 ? (c) : LATIN1_TO_NATIVE(c))
 #else
+__UNDEFINED__ NATIVE_TO_LATIN1(c) (c)
 __UNDEFINED__ LATIN1_TO_NATIVE(c) (c)
+__UNDEFINED__ NATIVE_TO_UNI(c) (c)
+__UNDEFINED__ UNI_TO_NATIVE(c) (c)
 #endif
 
-/* Warning: LATIN1_TO_NATIVE, NATIVE_TO_LATIN1
+/* Warning: LATIN1_TO_NATIVE, NATIVE_TO_LATIN1 NATIVE_TO_UNI UNI_TO_NATIVE
    EBCDIC is not supported on versions earlier than 5.7.1
  */