Fix compilation issues with version older than 5.010
authorNicolas R <atoomic@cpan.org>
Wed, 15 May 2019 14:53:26 +0000 (08:53 -0600)
committerNicolas R <atoomic@cpan.org>
Thu, 16 May 2019 22:44:47 +0000 (16:44 -0600)
By adding more Perl versions to the Travis CI configuration
file we discovered that versions earlier 5.010 are broken.

Note that the uv.t does not raise the overflow warning
as expected by the test and we probably want to fix this in
a short future.

The test uv.t is simply not passing with 5.006 versions and
has several failures. I've currently disabled it.

Patch provided by Pali

dist/Devel-PPPort/Makefile.PL
dist/Devel-PPPort/PPPort_pm.PL
dist/Devel-PPPort/parts/inc/misc
dist/Devel-PPPort/parts/inc/uv
dist/Devel-PPPort/parts/inc/warn
dist/Devel-PPPort/t/uv.t

index 8915a4d..7c2064a 100644 (file)
@@ -77,13 +77,13 @@ sub configure
     $depend{'apicheck.i'} = 'ppport.h';
   }
 
-  open my $fh, '<', 'PPPort_pm.PL' or die "cannot open PPPort_pm.PL for reading: $!";
+  open FH, '<PPPort_pm.PL' or die "cannot open PPPort_pm.PL for reading: $!";
   my $version;
-  while (my $line = <$fh>) {
+  while (my $line = <FH>) {
     ($version) = $line =~ /^\$VERSION = '([\d.]+)';$/ and last;
   };
   die 'failed to extract $VERSION from PPPort_pm.PL' if not $version;
-  close $fh;
+  close FH;
 
   return {
     C        => \@C_FILES,
index abce21d..19d5985 100644 (file)
@@ -628,16 +628,22 @@ __DATA__
 
 %include limits
 
+%include magic_defs
+
 %include misc
 
+%include sv_xpvf
+
+%include SvPV
+
 %include warn
 
+%include format
+
 %include uv
 
 %include memory
 
-%include magic_defs
-
 %include mess
 
 %include variables
@@ -652,20 +658,14 @@ __DATA__
 
 %include MY_CXT
 
-%include format
-
 %include SvREFCNT
 
 %include newSV_type
 
 %include newSVpv
 
-%include SvPV
-
 %include Sv_set
 
-%include sv_xpvf
-
 %include shared_pv
 
 %include HvNAME
index 2bd2dcf..23a316f 100644 (file)
@@ -33,6 +33,14 @@ STMT_END
 STMT_START
 SvRX
 UTF8_MAXBYTES
+UTF8_ALLOW_ANYUV
+UTF8_ALLOW_EMPTY
+UTF8_ALLOW_CONTINUATION
+UTF8_ALLOW_NON_CONTINUATION
+UTF8_ALLOW_SHORT
+UTF8_ALLOW_LONG
+UTF8_ALLOW_OVERFLOW
+UTF8_ALLOW_ANY
 WIDEST_UTYPE
 XSRETURN
 
@@ -260,6 +268,19 @@ __UNDEFINED__  SVf             "_"
 
 __UNDEFINED__  UTF8_MAXBYTES   UTF8_MAXLEN
 
+__UNDEFINED__  UTF8_ALLOW_ANYUV                 0
+__UNDEFINED__  UTF8_ALLOW_EMPTY            0x0001
+__UNDEFINED__  UTF8_ALLOW_CONTINUATION     0x0002
+__UNDEFINED__  UTF8_ALLOW_NON_CONTINUATION 0x0004
+__UNDEFINED__  UTF8_ALLOW_SHORT            0x0008
+__UNDEFINED__  UTF8_ALLOW_LONG             0x0010
+__UNDEFINED__  UTF8_ALLOW_OVERFLOW         0x0080
+__UNDEFINED__  UTF8_ALLOW_ANY            ( UTF8_ALLOW_CONTINUATION      \
+                                          |UTF8_ALLOW_NON_CONTINUATION  \
+                                          |UTF8_ALLOW_SHORT             \
+                                          |UTF8_ALLOW_LONG              \
+                                          |UTF8_ALLOW_OVERFLOW)
+
 __UNDEFINED__  CPERLscope(x)   x
 
 __UNDEFINED__  PERL_HASH(hash,str,len) \
@@ -855,266 +876,304 @@ check_c_array()
                 mXPUSHi(*(C_ARRAY_END(x)-1)); /* 13 */
 
 bool
-test_isBLANK(UV ord)
+test_isBLANK(ord)
+    UV ord
     CODE:
         RETVAL = isBLANK(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isBLANK_A(UV ord)
+test_isBLANK_A(ord)
+    UV ord
     CODE:
         RETVAL = isBLANK_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isUPPER(UV ord)
+test_isUPPER(ord)
+    UV ord
     CODE:
         RETVAL = isUPPER(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isUPPER_A(UV ord)
+test_isUPPER_A(ord)
+    UV ord
     CODE:
         RETVAL = isUPPER_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isLOWER(UV ord)
+test_isLOWER(ord)
+    UV ord
     CODE:
         RETVAL = isLOWER(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isLOWER_A(UV ord)
+test_isLOWER_A(ord)
+    UV ord
     CODE:
         RETVAL = isLOWER_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isALPHA(UV ord)
+test_isALPHA(ord)
+    UV ord
     CODE:
         RETVAL = isALPHA(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isALPHA_A(UV ord)
+test_isALPHA_A(ord)
+    UV ord
     CODE:
         RETVAL = isALPHA_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isWORDCHAR(UV ord)
+test_isWORDCHAR(ord)
+    UV ord
     CODE:
         RETVAL = isWORDCHAR(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isWORDCHAR_A(UV ord)
+test_isWORDCHAR_A(ord)
+    UV ord
     CODE:
         RETVAL = isWORDCHAR_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isALPHANUMERIC(UV ord)
+test_isALPHANUMERIC(ord)
+    UV ord
     CODE:
         RETVAL = isALPHANUMERIC(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isALPHANUMERIC_A(UV ord)
+test_isALPHANUMERIC_A(ord)
+    UV ord
     CODE:
         RETVAL = isALPHANUMERIC_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isALNUM(UV ord)
+test_isALNUM(ord)
+    UV ord
     CODE:
         RETVAL = isALNUM(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isALNUM_A(UV ord)
+test_isALNUM_A(ord)
+    UV ord
     CODE:
         RETVAL = isALNUM_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isDIGIT(UV ord)
+test_isDIGIT(ord)
+    UV ord
     CODE:
         RETVAL = isDIGIT(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isDIGIT_A(UV ord)
+test_isDIGIT_A(ord)
+    UV ord
     CODE:
         RETVAL = isDIGIT_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isOCTAL(UV ord)
+test_isOCTAL(ord)
+    UV ord
     CODE:
         RETVAL = isOCTAL(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isOCTAL_A(UV ord)
+test_isOCTAL_A(ord)
+    UV ord
     CODE:
         RETVAL = isOCTAL_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isIDFIRST(UV ord)
+test_isIDFIRST(ord)
+    UV ord
     CODE:
         RETVAL = isIDFIRST(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isIDFIRST_A(UV ord)
+test_isIDFIRST_A(ord)
+    UV ord
     CODE:
         RETVAL = isIDFIRST_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isIDCONT(UV ord)
+test_isIDCONT(ord)
+    UV ord
     CODE:
         RETVAL = isIDCONT(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isIDCONT_A(UV ord)
+test_isIDCONT_A(ord)
+    UV ord
     CODE:
         RETVAL = isIDCONT_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isSPACE(UV ord)
+test_isSPACE(ord)
+    UV ord
     CODE:
         RETVAL = isSPACE(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isSPACE_A(UV ord)
+test_isSPACE_A(ord)
+    UV ord
     CODE:
         RETVAL = isSPACE_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isASCII(UV ord)
+test_isASCII(ord)
+    UV ord
     CODE:
         RETVAL = isASCII(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isASCII_A(UV ord)
+test_isASCII_A(ord)
+    UV ord
     CODE:
         RETVAL = isASCII_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isCNTRL(UV ord)
+test_isCNTRL(ord)
+    UV ord
     CODE:
         RETVAL = isCNTRL(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isCNTRL_A(UV ord)
+test_isCNTRL_A(ord)
+    UV ord
     CODE:
         RETVAL = isCNTRL_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isPRINT(UV ord)
+test_isPRINT(ord)
+    UV ord
     CODE:
         RETVAL = isPRINT(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isPRINT_A(UV ord)
+test_isPRINT_A(ord)
+    UV ord
     CODE:
         RETVAL = isPRINT_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isGRAPH(UV ord)
+test_isGRAPH(ord)
+    UV ord
     CODE:
         RETVAL = isGRAPH(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isGRAPH_A(UV ord)
+test_isGRAPH_A(ord)
+    UV ord
     CODE:
         RETVAL = isGRAPH_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isPUNCT(UV ord)
+test_isPUNCT(ord)
+    UV ord
     CODE:
         RETVAL = isPUNCT(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isPUNCT_A(UV ord)
+test_isPUNCT_A(ord)
+    UV ord
     CODE:
         RETVAL = isPUNCT_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isXDIGIT(UV ord)
+test_isXDIGIT(ord)
+    UV ord
     CODE:
         RETVAL = isXDIGIT(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isXDIGIT_A(UV ord)
+test_isXDIGIT_A(ord)
+    UV ord
     CODE:
         RETVAL = isXDIGIT_A(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isPSXSPC(UV ord)
+test_isPSXSPC(ord)
+    UV ord
     CODE:
         RETVAL = isPSXSPC(ord);
     OUTPUT:
         RETVAL
 
 bool
-test_isPSXSPC_A(UV ord)
+test_isPSXSPC_A(ord)
+    UV ord
     CODE:
         RETVAL = isPSXSPC_A(ord);
     OUTPUT:
@@ -1122,17 +1181,17 @@ test_isPSXSPC_A(UV ord)
 
 STRLEN
 av_tindex(av)
-        AV *av
+        SV *av
         CODE:
-                RETVAL = av_tindex(av);
+                RETVAL = av_tindex((AV*)SvRV(av));
         OUTPUT:
                 RETVAL
 
 STRLEN
 av_top_index(av)
-        AV *av
+        SV *av
         CODE:
-                RETVAL = av_top_index(av);
+                RETVAL = av_top_index((AV*)SvRV(av));
         OUTPUT:
                 RETVAL
 
index bb5f19e..3c03ba5 100644 (file)
@@ -103,13 +103,19 @@ my_strnlen(const char *str, Size_t maxlen)
  * intended to work with modern perls, the tighter restrictions could be
  * relaxed.  khw thinks this is unlikely, but has been wrong in the past. */
 
+#if { VERSION < 5.10.0 }
+#  define D_PPP_CU8 U8
+#else
+#  define D_PPP_CU8 const U8
+#endif
+
 #ifndef utf8_to_uvchr_buf
    /* Choose which underlying implementation to use.  At least one must be
     * present or the perl is too early to handle this function */
 #  if defined(utf8n_to_uvchr) || defined(utf8_to_uv)
 #    if defined(utf8n_to_uvchr)   /* This is the preferred implementation */
 #      define _ppport_utf8_to_uvchr_buf_callee utf8n_to_uvchr
-#    else
+#    elif { VERSION >= 5.6.1 }
 #      define _ppport_utf8_to_uvchr_buf_callee utf8_to_uv
 #    endif
 
@@ -119,7 +125,7 @@ my_strnlen(const char *str, Size_t maxlen)
 #  if { NEED utf8_to_uvchr_buf }
 
 UV
-utf8_to_uvchr_buf(pTHX_ const U8 *s, const U8 *send, STRLEN *retlen)
+utf8_to_uvchr_buf(pTHX_ D_PPP_CU8 *s, const U8 *send, STRLEN *retlen)
 {
     UV ret;
     STRLEN curlen;
@@ -358,7 +364,11 @@ UTF8_SAFE_SKIP(s, adjustment)
         int adjustment
         CODE:
             /* Instead of passing in an 'e' ptr, use the real end, adjusted */
+#if defined(UTF8_SAFE_SKIP) && defined(UTF8SKIP)
             RETVAL = UTF8_SAFE_SKIP(s, s + UTF8SKIP(s) + adjustment);
+#else
+            RETVAL = 0;
+#endif
         OUTPUT:
             RETVAL
 
@@ -380,9 +390,14 @@ utf8_to_uvchr_buf(s, adjustment)
             STRLEN len;
         CODE:
             av = newAV();
+#ifdef utf8_to_uvchr_buf
             av_push(av, newSVuv(utf8_to_uvchr_buf(s,
                                                   s + UTF8SKIP(s) + adjustment,
                                                   &len)));
+#else
+            av_push(av, newSVuv(0));
+            len = (STRLEN) -1;
+#endif
             if (len == (STRLEN) -1) {
                 av_push(av, newSViv(-1));
             }
@@ -401,7 +416,12 @@ utf8_to_uvchr(s)
             STRLEN len;
         CODE:
             av = newAV();
+#ifdef utf8_to_uvchr
             av_push(av, newSVuv(utf8_to_uvchr(s, &len)));
+#else
+            av_push(av, newSVuv(0));
+            len = (STRLEN) -1;
+#endif
             if (len == (STRLEN) -1) {
                 av_push(av, newSViv(-1));
             }
@@ -414,6 +434,9 @@ utf8_to_uvchr(s)
 
 =tests plan => 52
 
+# skip tests on 5.6.0 and earlier
+BEGIN { if ("$]" le '5.006') { skip 'skip: broken utf8 support', 0 for 1..52; exit; } }
+
 ok(&Devel::PPPort::sv_setuv(42), 42);
 ok(&Devel::PPPort::newSVuv(123), 123);
 ok(&Devel::PPPort::sv_2uv("4711"), 4711);
@@ -495,7 +518,7 @@ else {
         {                 # Old algorithm supposedly failed to detect this
             input      => "\xff\x80\x90\x90\x90\xbf\xbf\xbf\xbf\xbf\xbf\xbf\xbf",
             adjustment => 0,
-            warning    => qr/overflow/,
+            warning    => ("$]" le 5.008006) ? qr/Malformed UTF-8 character/ : qr/overflow/,
             no_warnings_returned_length => 13,
         },
     );
index b4a5695..df8a385 100644 (file)
@@ -105,6 +105,7 @@ warner(U32 err, const char *pat, ...)
 =xsinit
 
 #define NEED_warner
+#define NEED_vnewSVpvf
 
 =xsubs
 
index 7f5d78b..5c8d487 100644 (file)
@@ -48,6 +48,9 @@ bootstrap Devel::PPPort;
 
 package main;
 
+# skip tests on 5.6.0 and earlier
+BEGIN { if ("$]" le '5.006') { skip 'skip: broken utf8 support', 0 for 1..52; exit; } }
+
 ok(&Devel::PPPort::sv_setuv(42), 42);
 ok(&Devel::PPPort::newSVuv(123), 123);
 ok(&Devel::PPPort::sv_2uv("4711"), 4711);
@@ -129,7 +132,7 @@ else {
         {                 # Old algorithm supposedly failed to detect this
             input      => "\xff\x80\x90\x90\x90\xbf\xbf\xbf\xbf\xbf\xbf\xbf\xbf",
             adjustment => 0,
-            warning    => qr/overflow/,
+            warning    => ("$]" le 5.008006) ? qr/Malformed UTF-8 character/ : qr/overflow/,
             no_warnings_returned_length => 13,
         },
     );