diff options
-rw-r--r-- | charclass_invlists.h | 136 | ||||
-rw-r--r-- | embed.fnc | 2 | ||||
-rw-r--r-- | inline_invlist.c | 14 | ||||
-rw-r--r-- | proto.h | 2 | ||||
-rw-r--r-- | regcomp.c | 27 | ||||
-rw-r--r-- | regen/mk_invlists.pl | 8 |
6 files changed, 53 insertions, 136 deletions
diff --git a/charclass_invlists.h b/charclass_invlists.h index 57fbe47af1..00b84bf878 100644 --- a/charclass_invlists.h +++ b/charclass_invlists.h @@ -11,9 +11,7 @@ static UV Latin1_invlist[] = { 2, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 0, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -27,9 +25,7 @@ static UV Latin1_invlist[] = { static UV AboveLatin1_invlist[] = { 1, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -42,9 +38,7 @@ static UV AboveLatin1_invlist[] = { static UV ASCII_invlist[] = { 2, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 0, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -58,9 +52,7 @@ static UV ASCII_invlist[] = { static UV L1Cased_invlist[] = { 16, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -88,9 +80,7 @@ static UV L1Cased_invlist[] = { static UV VertSpace_invlist[] = { 6, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -108,9 +98,7 @@ static UV VertSpace_invlist[] = { static UV PerlSpace_invlist[] = { 4, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -126,9 +114,7 @@ static UV PerlSpace_invlist[] = { static UV XPerlSpace_invlist[] = { 22, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -162,9 +148,7 @@ static UV XPerlSpace_invlist[] = { static UV PosixAlnum_invlist[] = { 6, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -182,9 +166,7 @@ static UV PosixAlnum_invlist[] = { static UV L1PosixAlnum_invlist[] = { 18, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -214,9 +196,7 @@ static UV L1PosixAlnum_invlist[] = { static UV PosixAlpha_invlist[] = { 4, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -232,9 +212,7 @@ static UV PosixAlpha_invlist[] = { static UV L1PosixAlpha_invlist[] = { 16, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -262,9 +240,7 @@ static UV L1PosixAlpha_invlist[] = { static UV PosixBlank_invlist[] = { 4, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -280,9 +256,7 @@ static UV PosixBlank_invlist[] = { static UV XPosixBlank_invlist[] = { 18, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -312,9 +286,7 @@ static UV XPosixBlank_invlist[] = { static UV PosixCntrl_invlist[] = { 4, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 0, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -330,9 +302,7 @@ static UV PosixCntrl_invlist[] = { static UV XPosixCntrl_invlist[] = { 4, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 0, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -348,9 +318,7 @@ static UV XPosixCntrl_invlist[] = { static UV PosixDigit_invlist[] = { 2, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -364,9 +332,7 @@ static UV PosixDigit_invlist[] = { static UV PosixGraph_invlist[] = { 2, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -380,9 +346,7 @@ static UV PosixGraph_invlist[] = { static UV L1PosixGraph_invlist[] = { 4, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -398,9 +362,7 @@ static UV L1PosixGraph_invlist[] = { static UV PosixLower_invlist[] = { 2, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -414,9 +376,7 @@ static UV PosixLower_invlist[] = { static UV L1PosixLower_invlist[] = { 12, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -440,9 +400,7 @@ static UV L1PosixLower_invlist[] = { static UV PosixPrint_invlist[] = { 2, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -456,9 +414,7 @@ static UV PosixPrint_invlist[] = { static UV L1PosixPrint_invlist[] = { 4, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -474,9 +430,7 @@ static UV L1PosixPrint_invlist[] = { static UV PosixPunct_invlist[] = { 8, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -496,9 +450,7 @@ static UV PosixPunct_invlist[] = { static UV L1PosixPunct_invlist[] = { 20, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -530,9 +482,7 @@ static UV L1PosixPunct_invlist[] = { static UV PosixSpace_invlist[] = { 4, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -548,9 +498,7 @@ static UV PosixSpace_invlist[] = { static UV XPosixSpace_invlist[] = { 22, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -584,9 +532,7 @@ static UV XPosixSpace_invlist[] = { static UV PosixUpper_invlist[] = { 2, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -600,9 +546,7 @@ static UV PosixUpper_invlist[] = { static UV L1PosixUpper_invlist[] = { 6, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -620,9 +564,7 @@ static UV L1PosixUpper_invlist[] = { static UV PosixWord_invlist[] = { 8, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -642,9 +584,7 @@ static UV PosixWord_invlist[] = { static UV L1PosixWord_invlist[] = { 20, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -676,9 +616,7 @@ static UV L1PosixWord_invlist[] = { static UV PosixXDigit_invlist[] = { 6, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -696,9 +634,7 @@ static UV PosixXDigit_invlist[] = { static UV XPosixXDigit_invlist[] = { 12, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -720,9 +656,7 @@ static UV XPosixXDigit_invlist[] = { static UV NonL1_Perl_Non_Final_Folds_invlist[] = { 44, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -776,9 +710,7 @@ static UV NonL1_Perl_Non_Final_Folds_invlist[] = { static UV _Perl_Multi_Char_Folds_invlist[] = { 58, /* Number of elements */ - 0, /* Current iteration position */ - 0, /* Cache of previous search index result */ - 1039476070, /* Version and data structure type */ + 1511554547, /* Version and data structure type */ 1, /* 0 if the list starts at 0; 1 if it starts at the element beyond 0 */ 0, @@ -1443,7 +1443,7 @@ EiM |void |invlist_set_previous_index|NN SV* const invlist|const IV index EiM |void |invlist_trim |NN SV* const invlist EiMR |SV* |invlist_clone |NN SV* const invlist EiMR |bool |invlist_is_iterating|NN SV* const invlist -EiMR |UV* |get_invlist_iter_addr |NN SV* invlist +EiMR |STRLEN*|get_invlist_iter_addr |NN SV* invlist EiM |void |invlist_iterinit|NN SV* invlist EsMR |bool |invlist_iternext|NN SV* invlist|NN UV* start|NN UV* end EiM |void |invlist_iterfinish|NN SV* invlist diff --git a/inline_invlist.c b/inline_invlist.c index f20f6daae0..5d239bd6cd 100644 --- a/inline_invlist.c +++ b/inline_invlist.c @@ -9,20 +9,16 @@ #if defined(PERL_IN_UTF8_C) || defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C) #define INVLIST_LEN_OFFSET 0 /* Number of elements in the inversion list */ -#define INVLIST_ITER_OFFSET 1 /* Current iteration position */ -#define INVLIST_PREVIOUS_INDEX_OFFSET 2 /* Place to cache index of previous - result */ /* This is a combination of a version and data structure type, so that one * being passed in can be validated to be an inversion list of the correct * vintage. When the structure of the header is changed, a new random number - * in the range 2**31-1 should be generated and the new() method changed to - * insert that at this location. Then, if an auxiliary program doesn't change - * correspondingly, it will be discovered immediately */ -#define INVLIST_VERSION_ID_OFFSET 3 -#define INVLIST_VERSION_ID 1039476070 + * in the range 2**31-1 should be generated. Then, if an auxiliary program + * doesn't change correspondingly, it will be discovered immediately */ +#define INVLIST_VERSION_ID_OFFSET 1 +#define INVLIST_VERSION_ID 1511554547 -#define INVLIST_ZERO_OFFSET 4 /* 0 or 1 */ +#define INVLIST_ZERO_OFFSET 2 /* 0 or 1 */ /* The UV at position ZERO contains either 0 or 1. If 0, the inversion list * contains the code point U+00000, and begins at element [0] in the array, * which always contains 0. If 1, the inversion list doesn't contain U+0000, @@ -6503,7 +6503,7 @@ STATIC bool S_could_it_be_a_POSIX_class(pTHX_ struct RExC_state_t *pRExC_state) #define PERL_ARGS_ASSERT_COULD_IT_BE_A_POSIX_CLASS \ assert(pRExC_state) -PERL_STATIC_INLINE UV* S_get_invlist_iter_addr(pTHX_ SV* invlist) +PERL_STATIC_INLINE STRLEN* S_get_invlist_iter_addr(pTHX_ SV* invlist) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_GET_INVLIST_ITER_ADDR \ @@ -7144,7 +7144,7 @@ S_get_invlist_previous_index_addr(pTHX_ SV* invlist) PERL_ARGS_ASSERT_GET_INVLIST_PREVIOUS_INDEX_ADDR; - return (IV *) (SvPVX(invlist) + (INVLIST_PREVIOUS_INDEX_OFFSET * sizeof (UV))); + return &(((XPVLV*) SvANY(invlist))->xiv_u.xivu_iv); } PERL_STATIC_INLINE IV @@ -7216,7 +7216,7 @@ Perl__new_invlist(pTHX_ IV initial_size) invlist_set_len(new_list, 0); /* Force iterinit() to be used to get iteration to work */ - *get_invlist_iter_addr(new_list) = UV_MAX; + *get_invlist_iter_addr(new_list) = (STRLEN) UV_MAX; /* This should force a segfault if a method doesn't initialize this * properly */ @@ -7225,7 +7225,7 @@ Perl__new_invlist(pTHX_ IV initial_size) *(zero_addr + 1) = 0; *get_invlist_previous_index_addr(new_list) = 0; -#if HEADER_LENGTH != 6 +#if HEADER_LENGTH != 4 # error Need to regenerate INVLIST_VERSION_ID by running perl -E 'say int(rand 2**31-1)', and then changing the #if to the new length #endif @@ -7254,12 +7254,9 @@ S__new_invlist_C_array(pTHX_ UV* list) Perl_croak(aTHX_ "panic: Incorrect version for previously generated inversion list"); } invlist_set_len(invlist, list[INVLIST_LEN_OFFSET]); + invlist_set_previous_index(invlist, 0); - /* Initialize the iteration pointer. - * XXX This could be done at compile time in charclass_invlists.h, but I - * (khw) am not confident that the suffixes for specifying the C constant - * UV_MAX are portable, e.g. 'ull' on a 32 bit machine that is configured - * to use 64 bits; might need a Configure probe */ + /* Initialize the iteration pointer. */ invlist_iterfinish(invlist); return invlist; @@ -8131,7 +8128,7 @@ S_invlist_clone(pTHX_ SV* const invlist) return new_invlist; } -PERL_STATIC_INLINE UV* +PERL_STATIC_INLINE STRLEN* S_get_invlist_iter_addr(pTHX_ SV* invlist) { /* Return the address of the UV that contains the current iteration @@ -8139,7 +8136,7 @@ S_get_invlist_iter_addr(pTHX_ SV* invlist) PERL_ARGS_ASSERT_GET_INVLIST_ITER_ADDR; - return (UV *) (SvPVX(invlist) + (INVLIST_ITER_OFFSET * sizeof (UV))); + return &(LvTARGOFF(invlist)); } PERL_STATIC_INLINE void @@ -8163,7 +8160,7 @@ S_invlist_iterfinish(pTHX_ SV* invlist) PERL_ARGS_ASSERT_INVLIST_ITERFINISH; - *get_invlist_iter_addr(invlist) = UV_MAX; + *get_invlist_iter_addr(invlist) = (STRLEN) UV_MAX; } STATIC bool @@ -8176,14 +8173,14 @@ S_invlist_iternext(pTHX_ SV* invlist, UV* start, UV* end) * <*start> and <*end> are unchanged, and the next call to this function * will start over at the beginning of the list */ - UV* pos = get_invlist_iter_addr(invlist); + STRLEN* pos = get_invlist_iter_addr(invlist); UV len = _invlist_len(invlist); UV *array; PERL_ARGS_ASSERT_INVLIST_ITERNEXT; if (*pos >= len) { - *pos = UV_MAX; /* Force iterinit() to be required next time */ + *pos = (STRLEN) UV_MAX; /* Force iterinit() to be required next time */ return FALSE; } @@ -8206,7 +8203,7 @@ S_invlist_is_iterating(pTHX_ SV* const invlist) { PERL_ARGS_ASSERT_INVLIST_IS_ITERATING; - return *(get_invlist_iter_addr(invlist)) < UV_MAX; + return *(get_invlist_iter_addr(invlist)) < (STRLEN) UV_MAX; } PERL_STATIC_INLINE UV @@ -8376,9 +8373,7 @@ S__invlistEQ(pTHX_ SV* const a, SV* const b, const bool complement_b) #undef FROM_INTERNAL_SIZE #undef INVLIST_LEN_OFFSET #undef INVLIST_ZERO_OFFSET -#undef INVLIST_ITER_OFFSET #undef INVLIST_VERSION_ID -#undef INVLIST_PREVIOUS_INDEX_OFFSET /* End of inversion list object */ diff --git a/regen/mk_invlists.pl b/regen/mk_invlists.pl index 8e131d6f58..d9f3d59ec0 100644 --- a/regen/mk_invlists.pl +++ b/regen/mk_invlists.pl @@ -15,7 +15,7 @@ require 'regen/regen_lib.pl'; # in the headers is used to minimize the possibility of things getting # out-of-sync, or the wrong data structure being passed. Currently that # random number is: -my $VERSION_DATA_STRUCTURE_TYPE = 1039476070; +my $VERSION_DATA_STRUCTURE_TYPE = 1511554547; my $out_fh = open_new('charclass_invlists.h', '>', {style => '*', by => $0, @@ -53,12 +53,6 @@ sub output_invlist ($$) { print $out_fh "\nstatic UV ${name}_invlist[] = {\n"; print $out_fh "\t$count,\t/* Number of elements */\n"; - - # This should be UV_MAX, but I (khw) am not confident that the suffixes - # for specifying the constant are portable, e.g. 'ull' on a 32 bit - # machine that is configured to use 64 bits; might need a Configure probe - print $out_fh "\t0,\t/* Current iteration position */\n"; - print $out_fh "\t0,\t/* Cache of previous search index result */\n"; print $out_fh "\t$VERSION_DATA_STRUCTURE_TYPE, /* Version and data structure type */\n"; print $out_fh "\t", $zero_or_one, ",\t/* 0 if the list starts at 0;", |