This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Consolidate UTF-8 functions/macros into new file
authorKarl Williamson <khw@cpan.org>
Thu, 4 Jul 2019 18:05:32 +0000 (12:05 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 27 Sep 2019 22:39:27 +0000 (16:39 -0600)
It's easier to grok when these are all together, and not in several
files.

(cherry picked from commit 365c133b9378a47cbf5ccf78a6dfc713cb8388de)
Signed-off-by: Nicolas R <atoomic@cpan.org>
dist/Devel-PPPort/PPPort_pm.PL
dist/Devel-PPPort/parts/inc/misc
dist/Devel-PPPort/parts/inc/uv
dist/Devel-PPPort/t/uv.t

index ebe4fb2..0ac91d8 100644 (file)
@@ -688,6 +688,8 @@ __DATA__
 
 %include strlfuncs
 
+%include utf8
+
 %include pv_tools
 
 #endif /* _P_P_PORTABILITY_H_ */
index d7acea5..85d9d19 100644 (file)
@@ -32,15 +32,6 @@ START_EXTERN_C
 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
 
@@ -247,21 +238,6 @@ __UNDEFINED__  dVAR            dNOOP
 
 __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) \
@@ -515,8 +491,6 @@ __UNDEFINED__ C_ARRAY_END(a)                ((a) + C_ARRAY_LENGTH(a))
 __UNDEFINED__ LIKELY(x) (x)
 __UNDEFINED__ UNLIKELY(x) (x)
 
-__UNDEFINED__ UNICODE_REPLACEMENT  0xFFFD
-
 #ifndef MUTABLE_PTR
 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
 #  define MUTABLE_PTR(p) ({ void *_p = (p); _p; })
index 9dc6d9e..6123ed6 100644 (file)
 __UNDEFINED__
 my_strnlen
 SvUOK
-utf8_to_uvchr_buf
 
 =implementation
 
-#define D_PPP_MIN(a,b) (((a) <= (b)) ? (a) : (b))
-
 __UNDEFINED__  sv_setuv(sv, uv)                     \
                STMT_START {                         \
                  UV TeMpUv = uv;                    \
@@ -62,17 +59,6 @@ __UNDEFINED__  XSRETURN_UV(v)  STMT_START { XST_mUV(0,v);  XSRETURN(1); } STMT_E
 __UNDEFINED__  PUSHu(u)        STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG;  } STMT_END
 __UNDEFINED__  XPUSHu(u)       STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
 
-#if defined UTF8SKIP
-
-/* Don't use official version because it uses MIN, which may not be available */
-#undef UTF8_SAFE_SKIP
-
-__UNDEFINED__  UTF8_SAFE_SKIP(s, e)  (                                          \
-                                      ((((e) - (s)) <= 0)                       \
-                                      ? 0                                       \
-                                      : D_PPP_MIN(((e) - (s)), UTF8SKIP(s))))
-#endif
-
 #if !defined(my_strnlen)
 #if { NEED my_strnlen }
 
@@ -378,23 +364,6 @@ XPUSHu()
                 XPUSHu(43);
                 XSRETURN(1);
 
-#if defined(UTF8_SAFE_SKIP) && defined(UTF8SKIP)
-
-STRLEN
-UTF8_SAFE_SKIP(s, adjustment)
-        char * s
-        int adjustment
-        PREINIT:
-            const char *const_s;
-        CODE:
-            const_s = s;
-            /* Instead of passing in an 'e' ptr, use the real end, adjusted */
-            RETVAL = UTF8_SAFE_SKIP(const_s, s + UTF8SKIP(s) + adjustment);
-        OUTPUT:
-            RETVAL
-
-#endif
-
 STRLEN
 my_strnlen(s, max)
         char * s
@@ -404,60 +373,7 @@ my_strnlen(s, max)
         OUTPUT:
             RETVAL
 
-#ifdef utf8_to_uvchr_buf
-
-AV *
-utf8_to_uvchr_buf(s, adjustment)
-        unsigned char *s
-        int adjustment
-        PREINIT:
-            AV *av;
-            STRLEN len;
-            const unsigned char *const_s;
-        CODE:
-            av = newAV();
-            const_s = s;
-            av_push(av, newSVuv(utf8_to_uvchr_buf(const_s,
-                                                  s + UTF8SKIP(s) + adjustment,
-                                                  &len)));
-            if (len == (STRLEN) -1) {
-                av_push(av, newSViv(-1));
-            }
-            else {
-                av_push(av, newSVuv(len));
-            }
-            RETVAL = av;
-        OUTPUT:
-                RETVAL
-
-#endif
-
-#ifdef utf8_to_uvchr
-
-AV *
-utf8_to_uvchr(s)
-        unsigned char *s
-        PREINIT:
-            AV *av;
-            STRLEN len;
-            const unsigned char *const_s;
-        CODE:
-            av = newAV();
-            const_s = s;
-            av_push(av, newSVuv(utf8_to_uvchr(const_s, &len)));
-            if (len == (STRLEN) -1) {
-                av_push(av, newSViv(-1));
-            }
-            else {
-                av_push(av, newSVuv(len));
-            }
-            RETVAL = av;
-        OUTPUT:
-                RETVAL
-
-#endif
-
-=tests plan => 62
+=tests plan => 11
 
 BEGIN { require warnings if "$]" gt '5.006' }
 
index 4a68b91..0d27f87 100644 (file)
@@ -30,9 +30,9 @@ BEGIN {
     require 'testutil.pl' if $@;
   }
 
-  if (62) {
+  if (11) {
     load();
-    plan(tests => 62);
+    plan(tests => 11);
   }
 }