handy.h: Add isVERTWS_uni(), isVERTWS_utf8()
authorKarl Williamson <public@khwilliamson.com>
Mon, 19 Nov 2012 20:14:24 +0000 (13:14 -0700)
committerKarl Williamson <public@khwilliamson.com>
Tue, 20 Nov 2012 00:13:02 +0000 (17:13 -0700)
These two macros match the same things as \v does in patterns.  I'm
leaving them undocumented for now.

ext/XS-APItest/APItest.pm
ext/XS-APItest/APItest.xs
ext/XS-APItest/t/handy.t
handy.h
regcharclass.h
regen/regcharclass.pl

index 71c9cc1..68ec99c 100644 (file)
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 use Carp;
 
-our $VERSION = '0.45';
+our $VERSION = '0.46';
 
 require XSLoader;
 
index 8d5b312..2afbcd0 100644 (file)
@@ -3585,6 +3585,20 @@ test_isBLANK_utf8(unsigned char * p)
         RETVAL
 
 bool
+test_isVERTWS_uni(UV ord)
+    CODE:
+        RETVAL = isVERTWS_uni(ord);
+    OUTPUT:
+        RETVAL
+
+bool
+test_isVERTWS_utf8(unsigned char * p)
+    CODE:
+        RETVAL = isVERTWS_utf8(p);
+    OUTPUT:
+        RETVAL
+
+bool
 test_isUPPER_uni(UV ord)
     CODE:
         RETVAL = isUPPER_uni(ord);
index f822b8c..9433409 100644 (file)
@@ -28,6 +28,7 @@ my %properties = (
                    punct => 'XPosixPunct',
                    quotemeta => '_Perl_Quotemeta',
                    space => 'XPerlSpace',
+                   vertws => 'VertSpace',
                    upper => 'Upper',
                    xdigit => 'XDigit',
                 );
@@ -86,6 +87,7 @@ foreach my $name (sort keys %properties) {
             }
             next;
         }
+        if ($name ne 'vertws') {
             $ret = truth eval "test_is${function}_A($i)";
             if ($@) {
                 fail($@);
@@ -102,6 +104,7 @@ foreach my $name (sort keys %properties) {
                 my $truth = truth($matches && $i < 256);
                 is ($ret, $truth, "is${function}_L1( $display_name ) == $truth");
             }
+        }
         next if $name eq 'alnumc';
 
         $ret = truth eval "test_is${function}_uni($i)";
diff --git a/handy.h b/handy.h
index 613129e..e657919 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -930,6 +930,7 @@ EXTCONST U32 PL_charclass[];
 #define isIDFIRST_uni(c)        _generic_uni(_CC_IDFIRST, is_uni_idfirst, c)
 #define isALPHA_uni(c)          _generic_uni(_CC_ALPHA, is_uni_alpha, c)
 #define isSPACE_uni(c)          _generic_uni(_CC_SPACE, is_uni_space, c)
+#define isVERTWS_uni(c)         _generic_uni(_CC_VERTSPACE, is_VERTWS_cp_high, c)
 #define isDIGIT_uni(c)          _generic_uni(_CC_DIGIT, is_uni_digit, c)
 #define isUPPER_uni(c)          _generic_uni(_CC_UPPER, is_uni_upper, c)
 #define isLOWER_uni(c)          _generic_uni(_CC_LOWER, is_uni_lower, c)
@@ -1001,6 +1002,7 @@ EXTCONST U32 PL_charclass[];
 #define isALPHA_utf8(p)         _generic_utf8(_CC_ALPHA, is_utf8_alpha, p)
 #define isBLANK_utf8(p)         _generic_utf8(_CC_BLANK, is_utf8_blank, p)
 #define isSPACE_utf8(p)         _generic_utf8(_CC_SPACE, is_utf8_space, p)
+#define isVERTWS_utf8(p)        _generic_utf8(_CC_VERTSPACE, is_VERTWS_high, p)
 #define isDIGIT_utf8(p)         _generic_utf8(_CC_DIGIT, is_utf8_digit, p)
 #define isUPPER_utf8(p)         _generic_utf8(_CC_UPPER, is_utf8_upper, p)
 #define isLOWER_utf8(p)         _generic_utf8(_CC_LOWER, is_utf8_lower, p)
index f7b4229..497d091 100644 (file)
 : 0 )
 
 /*** GENERATED CODE ***/
+#define is_VERTWS_high(s)                                                   \
+( ( ( ( 0xE2 == ((U8*)s)[0] ) && ( 0x80 == ((U8*)s)[1] ) ) && ( ( ((U8*)s)[2] & 0xFE ) == 0xA8 ) ) ? 3 : 0 )
+
+/*** GENERATED CODE ***/
+#define is_VERTWS_high_safe(s,e)                                            \
+( ( ( ( ((e)-(s) > 2) && ( 0xE2 == ((U8*)s)[0] ) ) && ( 0x80 == ((U8*)s)[1] ) ) && ( ( ((U8*)s)[2] & 0xFE ) == 0xA8 ) ) ? 3 : 0 )
+
+/*** GENERATED CODE ***/
 #define is_VERTWS_latin1(s)                                                 \
 ( ( 0x0A <= ((U8*)s)[0] && ((U8*)s)[0] <= 0x0D ) || 0x85 == ((U8*)s)[0] )
 
 ( 0x85 == cp || ( 0x85 < cp &&                                              \
 ( 0x2028 == cp || 0x2029 == cp ) ) ) ) )
 
+/*** GENERATED CODE ***/
+#define is_VERTWS_cp_high(cp)                                               \
+( 0x2028 == cp || 0x2029 == cp )
+
 /*
        REPLACEMENT: Unicode REPLACEMENT CHARACTER
 
index 06ce406..830a014 100755 (executable)
@@ -1393,7 +1393,7 @@ HORIZWS: Horizontal Whitespace: \h \H
 \p{HorizSpace}
 
 VERTWS: Vertical Whitespace: \v \V
-=> generic UTF8 LATIN1 cp :fast safe
+=> generic UTF8 high LATIN1 cp cp_high :fast safe
 \p{VertSpace}
 
 REPLACEMENT: Unicode REPLACEMENT CHARACTER