diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-11-19 13:55:13 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-11-19 17:13:02 -0700 |
commit | 4ac6419dea3d3b14ab477d0cd4d87f251b709e28 (patch) | |
tree | c64e3c7e180ecdf77741675b518d43e4c74ea0fc /regcharclass.h | |
parent | 2cafb56b1b34a7d194edbc8deedcd3e3242a2994 (diff) | |
download | perl-4ac6419dea3d3b14ab477d0cd4d87f251b709e28.tar.gz |
Refactor is_XDIGIT_uni(), is_XDIGIT_utf8() and macros
This adds macros to regen/regcharclass.pl that are usable as part of the
is_XDIGIT_foo() macros in handy.h, so that no function call need be done
to handle above Latin1 input. These macros are quite small, and
unlikely to grow over time. The functions that implement these in
utf8.c are also changed to use the macros instead of generating a swash.
This should speed things up slightly, with less memory used over time as
the swash fills.
Diffstat (limited to 'regcharclass.h')
-rw-r--r-- | regcharclass.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/regcharclass.h b/regcharclass.h index b3a24eb8f5..3bdaffa1ca 100644 --- a/regcharclass.h +++ b/regcharclass.h @@ -331,6 +331,33 @@ ( 0x2028 == cp || 0x2029 == cp ) /* + XDIGIT: Hexadecimal digits + + \p{XDigit} +*/ +/*** GENERATED CODE ***/ +#define is_XDIGIT_utf8(s) \ +( ( ( 0x30 <= ((U8*)s)[0] && ((U8*)s)[0] <= 0x39 ) || ( 0x41 <= ((U8*)s)[0] && ((U8*)s)[0] <= 0x46 ) || ( 0x61 <= ((U8*)s)[0] && ((U8*)s)[0] <= 0x66 ) ) ? 1\ +: ( 0xEF == ((U8*)s)[0] ) ? \ + ( ( 0xBC == ((U8*)s)[1] ) ? \ + ( ( ( 0x90 <= ((U8*)s)[2] && ((U8*)s)[2] <= 0x99 ) || ( 0xA1 <= ((U8*)s)[2] && ((U8*)s)[2] <= 0xA6 ) ) ? 3 : 0 )\ + : ( ( 0xBD == ((U8*)s)[1] ) && ( 0x81 <= ((U8*)s)[2] && ((U8*)s)[2] <= 0x86 ) ) ? 3 : 0 )\ +: 0 ) + +/*** GENERATED CODE ***/ +#define is_XDIGIT_high(s) \ +( ( 0xEF == ((U8*)s)[0] ) ? \ + ( ( 0xBC == ((U8*)s)[1] ) ? \ + ( ( ( 0x90 <= ((U8*)s)[2] && ((U8*)s)[2] <= 0x99 ) || ( 0xA1 <= ((U8*)s)[2] && ((U8*)s)[2] <= 0xA6 ) ) ? 3 : 0 )\ + : ( ( 0xBD == ((U8*)s)[1] ) && ( 0x81 <= ((U8*)s)[2] && ((U8*)s)[2] <= 0x86 ) ) ? 3 : 0 )\ +: 0 ) + +/*** GENERATED CODE ***/ +#define is_XDIGIT_cp_high(cp) \ +( ( 0xFF10 <= cp && cp <= 0xFF19 ) || ( 0xFF19 < cp && \ +( ( 0xFF21 <= cp && cp <= 0xFF26 ) || ( 0xFF41 <= cp && cp <= 0xFF46 ) ) ) ) + +/* REPLACEMENT: Unicode REPLACEMENT CHARACTER 0xFFFD |