summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-02-18 19:37:53 -0700
committerKarl Williamson <khw@cpan.org>2019-11-06 18:57:38 -0700
commita9269870d0bdf863ca3ff8c0027e0894d4847393 (patch)
tree15955d7982ecdab2db1104817389ee2da1f928de
parent24ad3c33bfe900c8e9ba2f41266556fab11f6d38 (diff)
downloadperl-a9269870d0bdf863ca3ff8c0027e0894d4847393.tar.gz
Move some static fcns from regcomp.c to invlist_inline.h
They are still only accessible from regcomp.c, but this is in preparation for them to be usable from other core files as well.
-rw-r--r--embed.fnc34
-rw-r--r--embed.h8
-rw-r--r--invlist_inline.h147
-rw-r--r--proto.h30
-rw-r--r--regcomp.c138
5 files changed, 185 insertions, 172 deletions
diff --git a/embed.fnc b/embed.fnc
index 4f63e5eabb..0950aebd95 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1869,35 +1869,39 @@ Apd |void |sv_vsetpvfn |NN SV *const sv|NN const char *const pat|const STRLEN pa
ApR |NV |str_to_version |NN SV *sv
EXpR |SV* |swash_init |NN const char* pkg|NN const char* name|NN SV* listsv|I32 minbits|I32 none
EXp |UV |swash_fetch |NN SV *swash|NN const U8 *ptr|bool do_utf8
-#ifdef PERL_IN_REGCOMP_C
+#if defined(PERL_IN_REGCOMP_C)
EiR |SV* |add_cp_to_invlist |NULLOK SV* invlist|const UV cp
+Ei |void |invlist_extend |NN SV* const invlist|const UV len
+Ei |void |invlist_set_len|NN SV* const invlist|const UV len|const bool offset
+EiRT |UV |invlist_highest|NN SV* const invlist
+EiRT |STRLEN*|get_invlist_iter_addr |NN SV* invlist
+EiT |void |invlist_iterinit|NN SV* invlist
+EiRT |bool |invlist_iternext|NN SV* invlist|NN UV* start|NN UV* end
+EiT |void |invlist_iterfinish|NN SV* invlist
+#endif
+#if defined(PERL_IN_REGCOMP_C)
EiRT |bool |invlist_is_iterating|NN SV* const invlist
+EiR |SV* |invlist_contents|NN SV* const invlist \
+ |const bool traditional_style
#ifndef PERL_EXT_RE_BUILD
EiRT |UV* |_invlist_array_init |NN SV* const invlist|const bool will_have_0
EiRT |UV |invlist_max |NN SV* const invlist
-ES |void |_append_range_to_invlist |NN SV* const invlist|const UV start|const UV end
-ES |void |invlist_extend |NN SV* const invlist|const UV len
-ES |void |invlist_replace_list_destroys_src|NN SV *dest|NN SV *src
EiRT |IV* |get_invlist_previous_index_addr|NN SV* invlist
-Ei |void |invlist_set_len|NN SV* const invlist|const UV len|const bool offset
EiT |void |invlist_set_previous_index|NN SV* const invlist|const IV index
EiRT |IV |invlist_previous_index|NN SV* const invlist
EiT |void |invlist_trim |NN SV* invlist
Ei |void |invlist_clear |NN SV* invlist
-S |void |initialize_invlist_guts|NN SV* invlist|const Size_t initial_size
#endif
-EiRT |STRLEN*|get_invlist_iter_addr |NN SV* invlist
-EiT |void |invlist_iterinit|NN SV* invlist
-ESRT |bool |invlist_iternext|NN SV* invlist|NN UV* start|NN UV* end
-EiT |void |invlist_iterfinish|NN SV* invlist
-EiRT |UV |invlist_highest|NN SV* const invlist
-ESR |SV* |invlist_contents|NN SV* const invlist \
- |const bool traditional_style
ESRT |bool |new_regcurly |NN const char *s|NN const char *e
ERS |SV* |make_exactf_invlist |NN RExC_state_t *pRExC_state \
|NN regnode *node
+#ifndef PERL_EXT_RE_BUILD
+ES |void |_append_range_to_invlist |NN SV* const invlist|const UV start|const UV end
+ES |void |invlist_replace_list_destroys_src|NN SV *dest|NN SV *src
+S |void |initialize_invlist_guts|NN SV* invlist|const Size_t initial_size
+#endif
#endif
-#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C)
+#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C) || defined(PERL_IN_OP_C) || defined(PERL_IN_DOOP_C)
m |void |_invlist_intersection |NN SV* const a|NN SV* const b|NN SV** i
EXp |void |_invlist_intersection_maybe_complement_2nd \
|NULLOK SV* const a|NN SV* const b \
@@ -1935,7 +1939,7 @@ EXp |SV* |_get_regclass_nonbitmap_data \
|NULLOK SV **lonly_utf8_locale \
|NULLOK SV **output_invlist
#endif
-#if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C)
+#if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C) || defined(PERL_IN_OP_C)
EXp |void |_invlist_dump |NN PerlIO *file|I32 level \
|NN const char* const indent \
|NN SV* const invlist
diff --git a/embed.h b/embed.h
index d6d36a1d7b..ae4794f51a 100644
--- a/embed.h
+++ b/embed.h
@@ -957,11 +957,9 @@
#define _invlist_array_init S__invlist_array_init
#define get_invlist_previous_index_addr S_get_invlist_previous_index_addr
#define invlist_clear(a) S_invlist_clear(aTHX_ a)
-#define invlist_extend(a,b) S_invlist_extend(aTHX_ a,b)
#define invlist_max S_invlist_max
#define invlist_previous_index S_invlist_previous_index
#define invlist_replace_list_destroys_src(a,b) S_invlist_replace_list_destroys_src(aTHX_ a,b)
-#define invlist_set_len(a,b,c) S_invlist_set_len(aTHX_ a,b,c)
#define invlist_set_previous_index S_invlist_set_previous_index
#define invlist_trim S_invlist_trim
# endif
@@ -1033,11 +1031,13 @@
#define handle_regex_sets(a,b,c,d,e) S_handle_regex_sets(aTHX_ a,b,c,d,e)
#define handle_user_defined_property(a,b,c,d,e,f,g,h,i,j) Perl_handle_user_defined_property(aTHX_ a,b,c,d,e,f,g,h,i,j)
#define invlist_contents(a,b) S_invlist_contents(aTHX_ a,b)
+#define invlist_extend(a,b) S_invlist_extend(aTHX_ a,b)
#define invlist_highest S_invlist_highest
#define invlist_is_iterating S_invlist_is_iterating
#define invlist_iterfinish S_invlist_iterfinish
#define invlist_iterinit S_invlist_iterinit
#define invlist_iternext S_invlist_iternext
+#define invlist_set_len(a,b,c) S_invlist_set_len(aTHX_ a,b,c)
#define is_ssc_worth_it S_is_ssc_worth_it
#define join_exact(a,b,c,d,e,f,g) S_join_exact(aTHX_ a,b,c,d,e,f,g)
#define make_exactf_invlist(a,b) S_make_exactf_invlist(aTHX_ a,b)
@@ -1080,7 +1080,7 @@
#define ssc_union(a,b,c) S_ssc_union(aTHX_ a,b,c)
#define study_chunk(a,b,c,d,e,f,g,h,i,j,k) S_study_chunk(aTHX_ a,b,c,d,e,f,g,h,i,j,k)
# endif
-# if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C)
+# if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C) || defined(PERL_IN_OP_C)
#define _invlist_dump(a,b,c,d) Perl__invlist_dump(aTHX_ a,b,c,d)
# endif
# if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_PERL_C) || defined(PERL_IN_UTF8_C)
@@ -1112,7 +1112,7 @@
#define grok_bslash_x(a,b,c,d,e,f,g,h) Perl_grok_bslash_x(aTHX_ a,b,c,d,e,f,g,h)
#define regcurly S_regcurly
# endif
-# if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C)
+# if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C) || defined(PERL_IN_OP_C) || defined(PERL_IN_DOOP_C)
#define _add_range_to_invlist(a,b,c) Perl__add_range_to_invlist(aTHX_ a,b,c)
#define _invlist_intersection_maybe_complement_2nd(a,b,c,d) Perl__invlist_intersection_maybe_complement_2nd(aTHX_ a,b,c,d)
#define _invlist_invert(a) Perl__invlist_invert(aTHX_ a)
diff --git a/invlist_inline.h b/invlist_inline.h
index 047a834ba8..795b8952a0 100644
--- a/invlist_inline.h
+++ b/invlist_inline.h
@@ -90,13 +90,154 @@ S_invlist_array(SV* const invlist)
return ((UV *) SvPVX(invlist) + *get_invlist_offset_addr(invlist));
}
-# ifndef PERL_IN_REGCOMP_C
+#endif
+#if defined(PERL_IN_REGCOMP_C)
+
+PERL_STATIC_INLINE void
+S_invlist_extend(pTHX_ SV* const invlist, const UV new_max)
+{
+ /* Grow the maximum size of an inversion list */
+
+ PERL_ARGS_ASSERT_INVLIST_EXTEND;
+
+ assert(SvTYPE(invlist) == SVt_INVLIST);
+
+ /* Add one to account for the zero element at the beginning which may not
+ * be counted by the calling parameters */
+ SvGROW((SV *)invlist, TO_INTERNAL_SIZE(new_max + 1));
+}
+
+PERL_STATIC_INLINE void
+S_invlist_set_len(pTHX_ SV* const invlist, const UV len, const bool offset)
+{
+ /* Sets the current number of elements stored in the inversion list.
+ * Updates SvCUR correspondingly */
+ PERL_UNUSED_CONTEXT;
+ PERL_ARGS_ASSERT_INVLIST_SET_LEN;
+
+ assert(SvTYPE(invlist) == SVt_INVLIST);
+
+ SvCUR_set(invlist,
+ (len == 0)
+ ? 0
+ : TO_INTERNAL_SIZE(len + offset));
+ assert(SvLEN(invlist) == 0 || SvCUR(invlist) <= SvLEN(invlist));
+}
+
+PERL_STATIC_INLINE SV*
+S_add_cp_to_invlist(pTHX_ SV* invlist, const UV cp) {
+ return _add_range_to_invlist(invlist, cp, cp);
+}
+
+PERL_STATIC_INLINE UV
+S_invlist_highest(SV* const invlist)
+{
+ /* Returns the highest code point that matches an inversion list. This API
+ * has an ambiguity, as it returns 0 under either the highest is actually
+ * 0, or if the list is empty. If this distinction matters to you, check
+ * for emptiness before calling this function */
+
+ UV len = _invlist_len(invlist);
+ UV *array;
+
+ PERL_ARGS_ASSERT_INVLIST_HIGHEST;
+
+ if (len == 0) {
+ return 0;
+ }
+
+ array = invlist_array(invlist);
+
+ /* The last element in the array in the inversion list always starts a
+ * range that goes to infinity. That range may be for code points that are
+ * matched in the inversion list, or it may be for ones that aren't
+ * matched. In the latter case, the highest code point in the set is one
+ * less than the beginning of this range; otherwise it is the final element
+ * of this range: infinity */
+ return (ELEMENT_RANGE_MATCHES_INVLIST(len - 1))
+ ? UV_MAX
+ : array[len - 1] - 1;
+}
+
+PERL_STATIC_INLINE STRLEN*
+S_get_invlist_iter_addr(SV* invlist)
+{
+ /* Return the address of the UV that contains the current iteration
+ * position */
+
+ PERL_ARGS_ASSERT_GET_INVLIST_ITER_ADDR;
+
+ assert(is_invlist(invlist));
+
+ return &(((XINVLIST*) SvANY(invlist))->iterator);
+}
+
+PERL_STATIC_INLINE void
+S_invlist_iterinit(SV* invlist) /* Initialize iterator for invlist */
+{
+ PERL_ARGS_ASSERT_INVLIST_ITERINIT;
+
+ *get_invlist_iter_addr(invlist) = 0;
+}
+
+PERL_STATIC_INLINE void
+S_invlist_iterfinish(SV* invlist)
+{
+ /* Terminate iterator for invlist. This is to catch development errors.
+ * Any iteration that is interrupted before completed should call this
+ * function. Functions that add code points anywhere else but to the end
+ * of an inversion list assert that they are not in the middle of an
+ * iteration. If they were, the addition would make the iteration
+ * problematical: if the iteration hadn't reached the place where things
+ * were being added, it would be ok */
+
+ PERL_ARGS_ASSERT_INVLIST_ITERFINISH;
+
+ *get_invlist_iter_addr(invlist) = (STRLEN) UV_MAX;
+}
+
+STATIC bool
+S_invlist_iternext(SV* invlist, UV* start, UV* end)
+{
+ /* An C<invlist_iterinit> call on <invlist> must be used to set this up.
+ * This call sets in <*start> and <*end>, the next range in <invlist>.
+ * Returns <TRUE> if successful and the next call will return the next
+ * range; <FALSE> if was already at the end of the list. If the latter,
+ * <*start> and <*end> are unchanged, and the next call to this function
+ * will start over at the beginning of the list */
+
+ STRLEN* pos = get_invlist_iter_addr(invlist);
+ UV len = _invlist_len(invlist);
+ UV *array;
+
+ PERL_ARGS_ASSERT_INVLIST_ITERNEXT;
+
+ if (*pos >= len) {
+ *pos = (STRLEN) UV_MAX; /* Force iterinit() to be required next time */
+ return FALSE;
+ }
+
+ array = invlist_array(invlist);
+
+ *start = array[(*pos)++];
+
+ if (*pos >= len) {
+ *end = UV_MAX;
+ }
+ else {
+ *end = array[(*pos)++] - 1;
+ }
+
+ return TRUE;
+}
+
+#endif
+
+#ifndef PERL_IN_REGCOMP_C
/* These symbols are only needed later in regcomp.c */
# undef TO_INTERNAL_SIZE
# undef FROM_INTERNAL_SIZE
-# endif
-
#endif
#endif /* PERL_INVLIST_INLINE_H_ */
diff --git a/proto.h b/proto.h
index 1169fee6da..9ba4dd9251 100644
--- a/proto.h
+++ b/proto.h
@@ -4232,9 +4232,6 @@ PERL_STATIC_INLINE void S_invlist_clear(pTHX_ SV* invlist);
#define PERL_ARGS_ASSERT_INVLIST_CLEAR \
assert(invlist)
#endif
-STATIC void S_invlist_extend(pTHX_ SV* const invlist, const UV len);
-#define PERL_ARGS_ASSERT_INVLIST_EXTEND \
- assert(invlist)
#ifndef PERL_NO_INLINE_FUNCTIONS
PERL_STATIC_INLINE UV S_invlist_max(SV* const invlist)
__attribute__warn_unused_result__;
@@ -4253,11 +4250,6 @@ STATIC void S_invlist_replace_list_destroys_src(pTHX_ SV *dest, SV *src);
#define PERL_ARGS_ASSERT_INVLIST_REPLACE_LIST_DESTROYS_SRC \
assert(dest); assert(src)
#ifndef PERL_NO_INLINE_FUNCTIONS
-PERL_STATIC_INLINE void S_invlist_set_len(pTHX_ SV* const invlist, const UV len, const bool offset);
-#define PERL_ARGS_ASSERT_INVLIST_SET_LEN \
- assert(invlist)
-#endif
-#ifndef PERL_NO_INLINE_FUNCTIONS
PERL_STATIC_INLINE void S_invlist_set_previous_index(SV* const invlist, const IV index);
#define PERL_ARGS_ASSERT_INVLIST_SET_PREVIOUS_INDEX \
assert(invlist)
@@ -5611,12 +5603,19 @@ STATIC regnode_offset S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV **
PERL_CALLCONV SV * Perl_handle_user_defined_property(pTHX_ const char * name, const STRLEN name_len, const bool is_utf8, const bool to_fold, const bool runtime, const bool deferrable, SV* contents, bool *user_defined_ptr, SV * msg, const STRLEN level);
#define PERL_ARGS_ASSERT_HANDLE_USER_DEFINED_PROPERTY \
assert(name); assert(contents); assert(user_defined_ptr); assert(msg)
-STATIC SV* S_invlist_contents(pTHX_ SV* const invlist, const bool traditional_style)
+#ifndef PERL_NO_INLINE_FUNCTIONS
+PERL_STATIC_INLINE SV* S_invlist_contents(pTHX_ SV* const invlist, const bool traditional_style)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_INVLIST_CONTENTS \
assert(invlist)
+#endif
#ifndef PERL_NO_INLINE_FUNCTIONS
+PERL_STATIC_INLINE void S_invlist_extend(pTHX_ SV* const invlist, const UV len);
+#define PERL_ARGS_ASSERT_INVLIST_EXTEND \
+ assert(invlist)
+#endif
+#ifndef PERL_NO_INLINE_FUNCTIONS
PERL_STATIC_INLINE UV S_invlist_highest(SV* const invlist)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_INVLIST_HIGHEST \
@@ -5640,11 +5639,18 @@ PERL_STATIC_INLINE void S_invlist_iterinit(SV* invlist);
#define PERL_ARGS_ASSERT_INVLIST_ITERINIT \
assert(invlist)
#endif
-STATIC bool S_invlist_iternext(SV* invlist, UV* start, UV* end)
+#ifndef PERL_NO_INLINE_FUNCTIONS
+PERL_STATIC_INLINE bool S_invlist_iternext(SV* invlist, UV* start, UV* end)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_INVLIST_ITERNEXT \
assert(invlist); assert(start); assert(end)
+#endif
+#ifndef PERL_NO_INLINE_FUNCTIONS
+PERL_STATIC_INLINE void S_invlist_set_len(pTHX_ SV* const invlist, const UV len, const bool offset);
+#define PERL_ARGS_ASSERT_INVLIST_SET_LEN \
+ assert(invlist)
+#endif
STATIC bool S_is_ssc_worth_it(const RExC_state_t * pRExC_state, const regnode_ssc * ssc);
#define PERL_ARGS_ASSERT_IS_SSC_WORTH_IT \
assert(pRExC_state); assert(ssc)
@@ -5797,7 +5803,7 @@ STATIC SSize_t S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, S
#define PERL_ARGS_ASSERT_STUDY_CHUNK \
assert(pRExC_state); assert(scanp); assert(minlenp); assert(deltap); assert(last)
#endif
-#if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C)
+#if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C) || defined(PERL_IN_OP_C)
PERL_CALLCONV void Perl__invlist_dump(pTHX_ PerlIO *file, I32 level, const char* const indent, SV* const invlist);
#define PERL_ARGS_ASSERT__INVLIST_DUMP \
assert(file); assert(indent); assert(invlist)
@@ -5899,7 +5905,7 @@ PERL_STATIC_INLINE I32 S_regcurly(const char *s)
#endif
#endif
-#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C)
+#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C) || defined(PERL_IN_OP_C) || defined(PERL_IN_DOOP_C)
PERL_CALLCONV SV* Perl__add_range_to_invlist(pTHX_ SV* invlist, UV start, UV end)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT__ADD_RANGE_TO_INVLIST
diff --git a/regcomp.c b/regcomp.c
index 9af72eab51..a86a3b35e7 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -9032,23 +9032,6 @@ S__invlist_array_init(SV* const invlist, const bool will_have_0)
return zero_addr + *offset;
}
-PERL_STATIC_INLINE void
-S_invlist_set_len(pTHX_ SV* const invlist, const UV len, const bool offset)
-{
- /* Sets the current number of elements stored in the inversion list.
- * Updates SvCUR correspondingly */
- PERL_UNUSED_CONTEXT;
- PERL_ARGS_ASSERT_INVLIST_SET_LEN;
-
- assert(is_invlist(invlist));
-
- SvCUR_set(invlist,
- (len == 0)
- ? 0
- : TO_INTERNAL_SIZE(len + offset));
- assert(SvLEN(invlist) == 0 || SvCUR(invlist) <= SvLEN(invlist));
-}
-
STATIC void
S_invlist_replace_list_destroys_src(pTHX_ SV * dest, SV * src)
{
@@ -9280,20 +9263,6 @@ Perl__new_invlist_C_array(pTHX_ const UV* const list)
}
STATIC void
-S_invlist_extend(pTHX_ SV* const invlist, const UV new_max)
-{
- /* Grow the maximum size of an inversion list */
-
- PERL_ARGS_ASSERT_INVLIST_EXTEND;
-
- assert(is_invlist(invlist));
-
- /* Add one to account for the zero element at the beginning which may not
- * be counted by the calling parameters */
- SvGROW((SV *)invlist, TO_INTERNAL_SIZE(new_max + 1));
-}
-
-STATIC void
S__append_range_to_invlist(pTHX_ SV* const invlist,
const UV start, const UV end)
{
@@ -10279,11 +10248,6 @@ Perl__setup_canned_invlist(pTHX_ const STRLEN size, const UV element0,
#endif
-PERL_STATIC_INLINE SV*
-S_add_cp_to_invlist(pTHX_ SV* invlist, const UV cp) {
- return _add_range_to_invlist(invlist, cp, cp);
-}
-
#ifndef PERL_IN_XSUB_RE
void
Perl__invlist_invert(pTHX_ SV* const invlist)
@@ -10334,108 +10298,6 @@ Perl_invlist_clone(pTHX_ SV* const invlist, SV* new_invlist)
#endif
-PERL_STATIC_INLINE STRLEN*
-S_get_invlist_iter_addr(SV* invlist)
-{
- /* Return the address of the UV that contains the current iteration
- * position */
-
- PERL_ARGS_ASSERT_GET_INVLIST_ITER_ADDR;
-
- assert(is_invlist(invlist));
-
- return &(((XINVLIST*) SvANY(invlist))->iterator);
-}
-
-PERL_STATIC_INLINE void
-S_invlist_iterinit(SV* invlist) /* Initialize iterator for invlist */
-{
- PERL_ARGS_ASSERT_INVLIST_ITERINIT;
-
- *get_invlist_iter_addr(invlist) = 0;
-}
-
-PERL_STATIC_INLINE void
-S_invlist_iterfinish(SV* invlist)
-{
- /* Terminate iterator for invlist. This is to catch development errors.
- * Any iteration that is interrupted before completed should call this
- * function. Functions that add code points anywhere else but to the end
- * of an inversion list assert that they are not in the middle of an
- * iteration. If they were, the addition would make the iteration
- * problematical: if the iteration hadn't reached the place where things
- * were being added, it would be ok */
-
- PERL_ARGS_ASSERT_INVLIST_ITERFINISH;
-
- *get_invlist_iter_addr(invlist) = (STRLEN) UV_MAX;
-}
-
-STATIC bool
-S_invlist_iternext(SV* invlist, UV* start, UV* end)
-{
- /* An C<invlist_iterinit> call on <invlist> must be used to set this up.
- * This call sets in <*start> and <*end>, the next range in <invlist>.
- * Returns <TRUE> if successful and the next call will return the next
- * range; <FALSE> if was already at the end of the list. If the latter,
- * <*start> and <*end> are unchanged, and the next call to this function
- * will start over at the beginning of the list */
-
- STRLEN* pos = get_invlist_iter_addr(invlist);
- UV len = _invlist_len(invlist);
- UV *array;
-
- PERL_ARGS_ASSERT_INVLIST_ITERNEXT;
-
- if (*pos >= len) {
- *pos = (STRLEN) UV_MAX; /* Force iterinit() to be required next time */
- return FALSE;
- }
-
- array = invlist_array(invlist);
-
- *start = array[(*pos)++];
-
- if (*pos >= len) {
- *end = UV_MAX;
- }
- else {
- *end = array[(*pos)++] - 1;
- }
-
- return TRUE;
-}
-
-PERL_STATIC_INLINE UV
-S_invlist_highest(SV* const invlist)
-{
- /* Returns the highest code point that matches an inversion list. This API
- * has an ambiguity, as it returns 0 under either the highest is actually
- * 0, or if the list is empty. If this distinction matters to you, check
- * for emptiness before calling this function */
-
- UV len = _invlist_len(invlist);
- UV *array;
-
- PERL_ARGS_ASSERT_INVLIST_HIGHEST;
-
- if (len == 0) {
- return 0;
- }
-
- array = invlist_array(invlist);
-
- /* The last element in the array in the inversion list always starts a
- * range that goes to infinity. That range may be for code points that are
- * matched in the inversion list, or it may be for ones that aren't
- * matched. In the latter case, the highest code point in the set is one
- * less than the beginning of this range; otherwise it is the final element
- * of this range: infinity */
- return (ELEMENT_RANGE_MATCHES_INVLIST(len - 1))
- ? UV_MAX
- : array[len - 1] - 1;
-}
-
STATIC SV *
S_invlist_contents(pTHX_ SV* const invlist, const bool traditional_style)
{