From: Karl Williamson Date: Fri, 27 May 2011 17:01:16 +0000 (-0600) Subject: Change inversion lists to SVs X-Git-Tag: accepted/trunk/20130322.191538~3467^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a25abddce2beacd697f218d5625b22c4e344ee10;p=platform%2Fupstream%2Fperl.git Change inversion lists to SVs The inversion list is an opaque object, currently implemented as an SV. Even if it ends up being an HV in the future, Nicholas is of the opinion that it should be presented to the world as an SV*. --- diff --git a/embed.fnc b/embed.fnc index cc55c2a..1057bfc 100644 --- a/embed.fnc +++ b/embed.fnc @@ -983,8 +983,8 @@ Ap |SV* |regclass_swash |NULLOK const regexp *prog \ |NN const struct regnode *node|bool doinit \ |NULLOK SV **listsvp|NULLOK SV **altsvp #ifdef PERL_IN_REGCOMP_C -EMi |U8 |set_regclass_bit|NN struct RExC_state_t* pRExC_state|NN regnode* node|const U8 value|NN HV** invlist_ptr|NN AV** alternate_ptr -EMs |U8 |set_regclass_bit_fold|NN struct RExC_state_t *pRExC_state|NN regnode* node|const U8 value|NN HV** invlist_ptr|NN AV** alternate_ptr +EMi |U8 |set_regclass_bit|NN struct RExC_state_t* pRExC_state|NN regnode* node|const U8 value|NN SV** invlist_ptr|NN AV** alternate_ptr +EMs |U8 |set_regclass_bit_fold|NN struct RExC_state_t *pRExC_state|NN regnode* node|const U8 value|NN SV** invlist_ptr|NN AV** alternate_ptr EMs |void |add_alternate |NN AV** alternate_ptr|NN U8* string|STRLEN len #endif Ap |I32 |pregexec |NN REGEXP * const prog|NN char* stringarg \ @@ -1301,22 +1301,22 @@ ApR |NV |str_to_version |NN SV *sv Ap |SV* |swash_init |NN const char* pkg|NN const char* name|NN SV* listsv|I32 minbits|I32 none Ap |UV |swash_fetch |NN SV *swash|NN const U8 *ptr|bool do_utf8 EXMpR |HV* |_swash_inversion_hash |NN SV* const swash -EXMpR |HV* |_new_invlist |IV initial_size -EXMpR |HV* |_swash_to_invlist |NN SV* const swash -EXMp |void |_append_range_to_invlist |NN HV* const invlist|const UV start|const UV end +EXMpR |SV* |_new_invlist |IV initial_size +EXMpR |SV* |_swash_to_invlist |NN SV* const swash +EXMp |void |_append_range_to_invlist |NN SV* const invlist|const UV start|const UV end #ifdef PERL_IN_REGCOMP_C -EiMR |HV* |add_cp_to_invlist |NULLOK HV* invlist|const UV cp -EsMR |HV* |add_range_to_invlist |NULLOK HV* invlist|const UV start|const UV end -EiMR |UV* |invlist_array |NN HV* const invlist -EiM |void |invlist_destroy |NN HV* const invlist -EsM |void |invlist_extend |NN HV* const invlist|const UV len -EsMR |HV* |invlist_intersection |NN HV* const a|NN HV* const b -EiMR |UV |invlist_len |NN HV* const invlist -EiMR |UV |invlist_max |NN HV* const invlist -EiM |void |invlist_set_len |NN HV* const invlist|const UV len -EiM |void |invlist_set_max |NN HV* const invlist|const UV max -EiM |void |invlist_trim |NN HV* const invlist -EsMR |HV* |invlist_union |NN HV* const a|NN HV* const b +EiMR |SV* |add_cp_to_invlist |NULLOK SV* invlist|const UV cp +EsMR |SV* |add_range_to_invlist |NULLOK SV* invlist|const UV start|const UV end +EiMR |UV* |invlist_array |NN SV* const invlist +EiM |void |invlist_destroy |NN SV* const invlist +EsM |void |invlist_extend |NN SV* const invlist|const UV len +EsMR |SV* |invlist_intersection |NN SV* const a|NN SV* const b +EiMR |UV |invlist_len |NN SV* const invlist +EiMR |UV |invlist_max |NN SV* const invlist +EiM |void |invlist_set_len |NN SV* const invlist|const UV len +EiM |void |invlist_set_max |NN SV* const invlist|const UV max +EiM |void |invlist_trim |NN SV* const invlist +EsMR |SV* |invlist_union |NN SV* const a|NN SV* const b #endif Ap |void |taint_env Ap |void |taint_proper |NULLOK const char* f|NN const char *const s diff --git a/intrpvar.h b/intrpvar.h index cb8a861..b2d4d5c 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -729,7 +729,7 @@ PERLVARI(Iutf8_foldclosures, HV *, NULL) /* List of characters that participate in folds (except marks, etc in * multi-char folds) */ -PERLVARI(Iutf8_foldable, HV *, NULL) +PERLVARI(Iutf8_foldable, SV *, NULL) PERLVAR(Icustom_ops, HV *) /* custom op registrations */ diff --git a/proto.h b/proto.h index d034326..3a97fa8 100644 --- a/proto.h +++ b/proto.h @@ -23,12 +23,12 @@ PERL_CALLCONV int Perl_Gv_AMupdate(pTHX_ HV* stash, bool destructing) assert(stash) PERL_CALLCONV const char * Perl_PerlIO_context_layers(pTHX_ const char *mode); -PERL_CALLCONV void Perl__append_range_to_invlist(pTHX_ HV* const invlist, const UV start, const UV end) +PERL_CALLCONV void Perl__append_range_to_invlist(pTHX_ SV* const invlist, const UV start, const UV end) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT__APPEND_RANGE_TO_INVLIST \ assert(invlist) -PERL_CALLCONV HV* Perl__new_invlist(pTHX_ IV initial_size) +PERL_CALLCONV SV* Perl__new_invlist(pTHX_ IV initial_size) __attribute__warn_unused_result__; PERL_CALLCONV HV* Perl__swash_inversion_hash(pTHX_ SV* const swash) @@ -37,7 +37,7 @@ PERL_CALLCONV HV* Perl__swash_inversion_hash(pTHX_ SV* const swash) #define PERL_ARGS_ASSERT__SWASH_INVERSION_HASH \ assert(swash) -PERL_CALLCONV HV* Perl__swash_to_invlist(pTHX_ SV* const swash) +PERL_CALLCONV SV* Perl__swash_to_invlist(pTHX_ SV* const swash) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT__SWASH_TO_INVLIST \ @@ -5992,7 +5992,7 @@ STATIC void S_add_alternate(pTHX_ AV** alternate_ptr, U8* string, STRLEN len) #define PERL_ARGS_ASSERT_ADD_ALTERNATE \ assert(alternate_ptr); assert(string) -PERL_STATIC_INLINE HV* S_add_cp_to_invlist(pTHX_ HV* invlist, const UV cp) +PERL_STATIC_INLINE SV* S_add_cp_to_invlist(pTHX_ SV* invlist, const UV cp) __attribute__warn_unused_result__; STATIC U32 S_add_data(struct RExC_state_t *pRExC_state, U32 n, const char *s) @@ -6002,7 +6002,7 @@ STATIC U32 S_add_data(struct RExC_state_t *pRExC_state, U32 n, const char *s) #define PERL_ARGS_ASSERT_ADD_DATA \ assert(pRExC_state); assert(s) -STATIC HV* S_add_range_to_invlist(pTHX_ HV* invlist, const UV start, const UV end) +STATIC SV* S_add_range_to_invlist(pTHX_ SV* invlist, const UV start, const UV end) __attribute__warn_unused_result__; STATIC void S_checkposixcc(pTHX_ struct RExC_state_t *pRExC_state) @@ -6041,57 +6041,57 @@ STATIC void S_cl_or(const struct RExC_state_t *pRExC_state, struct regnode_charc #define PERL_ARGS_ASSERT_CL_OR \ assert(pRExC_state); assert(cl); assert(or_with) -PERL_STATIC_INLINE UV* S_invlist_array(pTHX_ HV* const invlist) +PERL_STATIC_INLINE UV* S_invlist_array(pTHX_ SV* const invlist) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_INVLIST_ARRAY \ assert(invlist) -PERL_STATIC_INLINE void S_invlist_destroy(pTHX_ HV* const invlist) +PERL_STATIC_INLINE void S_invlist_destroy(pTHX_ SV* const invlist) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_INVLIST_DESTROY \ assert(invlist) -STATIC void S_invlist_extend(pTHX_ HV* const invlist, const UV len) +STATIC void S_invlist_extend(pTHX_ SV* const invlist, const UV len) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_INVLIST_EXTEND \ assert(invlist) -STATIC HV* S_invlist_intersection(pTHX_ HV* const a, HV* const b) +STATIC SV* S_invlist_intersection(pTHX_ SV* const a, SV* const b) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_INVLIST_INTERSECTION \ assert(a); assert(b) -PERL_STATIC_INLINE UV S_invlist_len(pTHX_ HV* const invlist) +PERL_STATIC_INLINE UV S_invlist_len(pTHX_ SV* const invlist) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_INVLIST_LEN \ assert(invlist) -PERL_STATIC_INLINE UV S_invlist_max(pTHX_ HV* const invlist) +PERL_STATIC_INLINE UV S_invlist_max(pTHX_ SV* const invlist) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_INVLIST_MAX \ assert(invlist) -PERL_STATIC_INLINE void S_invlist_set_len(pTHX_ HV* const invlist, const UV len) +PERL_STATIC_INLINE void S_invlist_set_len(pTHX_ SV* const invlist, const UV len) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_INVLIST_SET_LEN \ assert(invlist) -PERL_STATIC_INLINE void S_invlist_set_max(pTHX_ HV* const invlist, const UV max) +PERL_STATIC_INLINE void S_invlist_set_max(pTHX_ SV* const invlist, const UV max) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_INVLIST_SET_MAX \ assert(invlist) -PERL_STATIC_INLINE void S_invlist_trim(pTHX_ HV* const invlist) +PERL_STATIC_INLINE void S_invlist_trim(pTHX_ SV* const invlist) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_INVLIST_TRIM \ assert(invlist) -STATIC HV* S_invlist_union(pTHX_ HV* const a, HV* const b) +STATIC SV* S_invlist_union(pTHX_ SV* const a, SV* const b) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); @@ -6230,7 +6230,7 @@ STATIC void S_scan_commit(pTHX_ const struct RExC_state_t *pRExC_state, struct s #define PERL_ARGS_ASSERT_SCAN_COMMIT \ assert(pRExC_state); assert(data); assert(minlenp) -PERL_STATIC_INLINE U8 S_set_regclass_bit(pTHX_ struct RExC_state_t* pRExC_state, regnode* node, const U8 value, HV** invlist_ptr, AV** alternate_ptr) +PERL_STATIC_INLINE U8 S_set_regclass_bit(pTHX_ struct RExC_state_t* pRExC_state, regnode* node, const U8 value, SV** invlist_ptr, AV** alternate_ptr) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_4) @@ -6238,7 +6238,7 @@ PERL_STATIC_INLINE U8 S_set_regclass_bit(pTHX_ struct RExC_state_t* pRExC_state, #define PERL_ARGS_ASSERT_SET_REGCLASS_BIT \ assert(pRExC_state); assert(node); assert(invlist_ptr); assert(alternate_ptr) -STATIC U8 S_set_regclass_bit_fold(pTHX_ struct RExC_state_t *pRExC_state, regnode* node, const U8 value, HV** invlist_ptr, AV** alternate_ptr) +STATIC U8 S_set_regclass_bit_fold(pTHX_ struct RExC_state_t *pRExC_state, regnode* node, const U8 value, SV** invlist_ptr, AV** alternate_ptr) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_4) diff --git a/regcomp.c b/regcomp.c index a067af6..027c16a 100644 --- a/regcomp.c +++ b/regcomp.c @@ -5827,10 +5827,9 @@ S_reg_scan_name(pTHX_ RExC_state_t *pRExC_state, U32 flags) * this file. An inversion list is here implemented as a malloc'd C array with * some added info. More will be coming when functionality is added later. * - * It is currently implemented as an HV to the outside world, but is actually - * an SV pointing to an array of UVs that the SV thinks are bytes. This allows - * us to have an array of UV whose memory management is automatically handled - * by the existing facilities for SV's. + * It is currently implemented as an SV pointing to an array of UVs that the SV + * thinks are bytes. This allows us to have an array of UV whose memory + * management is automatically handled by the existing facilities for SV's. * * Some of the methods should always be private to the implementation, and some * should eventually be made public */ @@ -5838,7 +5837,7 @@ S_reg_scan_name(pTHX_ RExC_state_t *pRExC_state, U32 flags) #define INVLIST_INITIAL_LEN 10 PERL_STATIC_INLINE UV* -S_invlist_array(pTHX_ HV* const invlist) +S_invlist_array(pTHX_ SV* const invlist) { /* Returns the pointer to the inversion list's array. Every time the * length changes, this needs to be called in case malloc or realloc moved @@ -5850,7 +5849,7 @@ S_invlist_array(pTHX_ HV* const invlist) } PERL_STATIC_INLINE UV -S_invlist_len(pTHX_ HV* const invlist) +S_invlist_len(pTHX_ SV* const invlist) { /* Returns the current number of elements in the inversion list's array */ @@ -5860,7 +5859,7 @@ S_invlist_len(pTHX_ HV* const invlist) } PERL_STATIC_INLINE UV -S_invlist_max(pTHX_ HV* const invlist) +S_invlist_max(pTHX_ SV* const invlist) { /* Returns the maximum number of elements storable in the inversion list's * array, without having to realloc() */ @@ -5871,7 +5870,7 @@ S_invlist_max(pTHX_ HV* const invlist) } PERL_STATIC_INLINE void -S_invlist_set_len(pTHX_ HV* const invlist, const UV len) +S_invlist_set_len(pTHX_ SV* const invlist, const UV len) { /* Sets the current number of elements stored in the inversion list */ @@ -5881,7 +5880,7 @@ S_invlist_set_len(pTHX_ HV* const invlist, const UV len) } PERL_STATIC_INLINE void -S_invlist_set_max(pTHX_ HV* const invlist, const UV max) +S_invlist_set_max(pTHX_ SV* const invlist, const UV max) { /* Sets the maximum number of elements storable in the inversion list @@ -5897,7 +5896,7 @@ S_invlist_set_max(pTHX_ HV* const invlist, const UV max) } #ifndef PERL_IN_XSUB_RE -HV* +SV* Perl__new_invlist(pTHX_ IV initial_size) { @@ -5910,12 +5909,12 @@ Perl__new_invlist(pTHX_ IV initial_size) } /* Allocate the initial space */ - return (HV *) newSV(initial_size * sizeof(UV)); + return newSV(initial_size * sizeof(UV)); } #endif PERL_STATIC_INLINE void -S_invlist_destroy(pTHX_ HV* const invlist) +S_invlist_destroy(pTHX_ SV* const invlist) { /* Inversion list destructor */ @@ -5925,7 +5924,7 @@ S_invlist_destroy(pTHX_ HV* const invlist) } STATIC void -S_invlist_extend(pTHX_ HV* const invlist, const UV new_max) +S_invlist_extend(pTHX_ SV* const invlist, const UV new_max) { /* Grow the maximum size of an inversion list */ @@ -5935,7 +5934,7 @@ S_invlist_extend(pTHX_ HV* const invlist, const UV new_max) } PERL_STATIC_INLINE void -S_invlist_trim(pTHX_ HV* const invlist) +S_invlist_trim(pTHX_ SV* const invlist) { PERL_ARGS_ASSERT_INVLIST_TRIM; @@ -5953,7 +5952,7 @@ S_invlist_trim(pTHX_ HV* const invlist) #ifndef PERL_IN_XSUB_RE void -Perl__append_range_to_invlist(pTHX_ HV* const invlist, const UV start, const UV end) +Perl__append_range_to_invlist(pTHX_ SV* const invlist, const UV start, const UV end) { /* Subject to change or removal. Append the range from 'start' to 'end' at * the end of the inversion list. The range must be above any existing @@ -6024,8 +6023,8 @@ Perl__append_range_to_invlist(pTHX_ HV* const invlist, const UV start, const UV } #endif -STATIC HV* -S_invlist_union(pTHX_ HV* const a, HV* const b) +STATIC SV* +S_invlist_union(pTHX_ SV* const a, SV* const b) { /* Return a new inversion list which is the union of two inversion lists. * The basis for this comes from "Unicode Demystified" Chapter 13 by @@ -6045,7 +6044,7 @@ S_invlist_union(pTHX_ HV* const a, HV* const b) UV len_a = invlist_len(a); /* length of a's array */ UV len_b = invlist_len(b); - HV* u; /* the resulting union */ + SV* u; /* the resulting union */ UV* array_u; UV len_u; @@ -6175,8 +6174,8 @@ S_invlist_union(pTHX_ HV* const a, HV* const b) return u; } -STATIC HV* -S_invlist_intersection(pTHX_ HV* const a, HV* const b) +STATIC SV* +S_invlist_intersection(pTHX_ SV* const a, SV* const b) { /* Return the intersection of two inversion lists. The basis for this * comes from "Unicode Demystified" Chapter 13 by Richard Gillam, published @@ -6193,7 +6192,7 @@ S_invlist_intersection(pTHX_ HV* const a, HV* const b) UV len_a = invlist_len(a); /* length of a's array */ UV len_b = invlist_len(b); - HV* r; /* the resulting intersection */ + SV* r; /* the resulting intersection */ UV* array_r; UV len_r; @@ -6313,8 +6312,8 @@ S_invlist_intersection(pTHX_ HV* const a, HV* const b) return r; } -STATIC HV* -S_add_range_to_invlist(pTHX_ HV* invlist, const UV start, const UV end) +STATIC SV* +S_add_range_to_invlist(pTHX_ SV* invlist, const UV start, const UV end) { /* Add the range from 'start' to 'end' inclusive to the inversion list's * set. A pointer to the inversion list is returned. This may actually be @@ -6322,8 +6321,8 @@ S_add_range_to_invlist(pTHX_ HV* invlist, const UV start, const UV end) * passed in inversion list can be NULL, in which case a new one is created * with just the one range in it */ - HV* range_invlist; - HV* added_invlist; + SV* range_invlist; + SV* added_invlist; UV len; if (invlist == NULL) { @@ -6359,8 +6358,8 @@ S_add_range_to_invlist(pTHX_ HV* invlist, const UV start, const UV end) return added_invlist; } -PERL_STATIC_INLINE HV* -S_add_cp_to_invlist(pTHX_ HV* invlist, const UV cp) { +PERL_STATIC_INLINE SV* +S_add_cp_to_invlist(pTHX_ SV* invlist, const UV cp) { return add_range_to_invlist(invlist, cp, cp); } @@ -9303,7 +9302,7 @@ case ANYOF_N##NAME: \ break STATIC U8 -S_set_regclass_bit_fold(pTHX_ RExC_state_t *pRExC_state, regnode* node, const U8 value, HV** invlist_ptr, AV** alternate_ptr) +S_set_regclass_bit_fold(pTHX_ RExC_state_t *pRExC_state, regnode* node, const U8 value, SV** invlist_ptr, AV** alternate_ptr) { /* Handle the setting of folds in the bitmap for non-locale ANYOF nodes. @@ -9443,7 +9442,7 @@ S_set_regclass_bit_fold(pTHX_ RExC_state_t *pRExC_state, regnode* node, const U8 PERL_STATIC_INLINE U8 -S_set_regclass_bit(pTHX_ RExC_state_t *pRExC_state, regnode* node, const U8 value, HV** invlist_ptr, AV** alternate_ptr) +S_set_regclass_bit(pTHX_ RExC_state_t *pRExC_state, regnode* node, const U8 value, SV** invlist_ptr, AV** alternate_ptr) { /* This inline function sets a bit in the bitmap if not already set, and if * appropriate, its fold, returning the number of bits that actually @@ -9512,7 +9511,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, U32 depth) UV n; /* code points this node matches that can't be stored in the bitmap */ - HV* nonbitmap = NULL; + SV* nonbitmap = NULL; /* The items that are to match that aren't stored in the bitmap, but are a * result of things that are stored there. This is the fold closure of @@ -9528,7 +9527,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, U32 depth) * that matches. A 2nd list is used so that the 'nonbitmap' list is kept * empty unless there is something whose fold we don't know about, and will * have to go out to the disk to find. */ - HV* l1_fold_invlist = NULL; + SV* l1_fold_invlist = NULL; /* List of multi-character folds that are matched by this node */ AV* unicode_alternate = NULL; @@ -10039,7 +10038,7 @@ parseit: if (FOLD && nonbitmap) { UV i; - HV* fold_intersection; + SV* fold_intersection; UV* fold_list; /* This is a list of all the characters that participate in folds @@ -10221,7 +10220,7 @@ parseit: /* Combine the two lists into one. */ if (l1_fold_invlist) { if (nonbitmap) { - HV* temp = invlist_union(nonbitmap, l1_fold_invlist); + SV* temp = invlist_union(nonbitmap, l1_fold_invlist); invlist_destroy(nonbitmap); nonbitmap = temp; invlist_destroy(l1_fold_invlist); diff --git a/utf8.c b/utf8.c index 5f0e08c..99eea4b 100644 --- a/utf8.c +++ b/utf8.c @@ -2867,7 +2867,7 @@ Perl__swash_inversion_hash(pTHX_ SV* const swash) return ret; } -HV* +SV* Perl__swash_to_invlist(pTHX_ SV* const swash) { @@ -2889,7 +2889,7 @@ Perl__swash_to_invlist(pTHX_ SV* const swash) const STRLEN bits = SvUV(*bitssvp); const STRLEN octets = bits >> 3; /* if bits == 1, then octets == 0 */ - HV* invlist; + SV* invlist; PERL_ARGS_ASSERT__SWASH_TO_INVLIST;