Skip to content

Commit 541d899

Browse files
committed
embed.fnc: Add ptr assertions for apparently non-problematic
I went through the declarations in embed.fnc and added PTR constraints for all the ones that looked to have pointers to the beginning and end of a string. I then ran the test suite, and reverted any that had problems. Then I looked at the code for each one remaining to see if it was equipped to handle the case where the end == the beginning, and removed those. This is the result. Testing in the field may reveal others that the test suite missed; we can fix those as they occur. I removed now redundant asserts that were in the functions, and now are included in the ARGS_ASSERT macros
1 parent 6a8042c commit 541d899

File tree

3 files changed

+64
-67
lines changed

3 files changed

+64
-67
lines changed

embed.fnc

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,8 +1346,8 @@ Adpx |void |forbid_outofblock_ops \
13461346
|NN const char *blockname
13471347
p |void |force_locale_unlock
13481348
Cp |void |force_out_malformed_utf8_message_ \
1349-
|NN const U8 * const p \
1350-
|NN const U8 * const e \
1349+
|SPTR const U8 * const p \
1350+
|EPTR const U8 * const e \
13511351
|U32 flags \
13521352
|const bool die_here
13531353
Adfp |char * |form |NN const char *pat \
@@ -1811,12 +1811,12 @@ ARTdip |Size_t |isUTF8_CHAR_flags \
18111811
|NN const U8 * const e \
18121812
|const U32 flags
18131813
CPRTp |STRLEN |is_utf8_char_helper_ \
1814-
|NN const U8 * const s \
1815-
|NN const U8 *e \
1814+
|SPTR const U8 * const s \
1815+
|EPTR const U8 *e \
18161816
|const U32 flags
18171817
CPRTp |Size_t |is_utf8_FF_helper_ \
1818-
|NN const U8 * const s0 \
1819-
|NN const U8 * const e \
1818+
|SPTR const U8 * const s0 \
1819+
|EPTR const U8 * const e \
18201820
|const bool require_partial
18211821
ATdmp |bool |is_utf8_fixed_width_buf_flags \
18221822
|NN const U8 * const s \
@@ -1834,18 +1834,18 @@ ATdip |bool |is_utf8_fixed_width_buf_loclen_flags \
18341834
|NULLOK STRLEN *el \
18351835
|const U32 flags
18361836
CRp |Size_t |is_utf8_FOO_ |const U8 classnum \
1837-
|NN const U8 *p \
1838-
|NN const U8 * const e
1837+
|SPTR const U8 *p \
1838+
|EPTR const U8 * const e
18391839
ARTdip |bool |is_utf8_invariant_string_loc \
18401840
|NN const U8 * const s \
18411841
|STRLEN len \
18421842
|NULLOK const U8 **ep
18431843
CRp |Size_t |is_utf8_perl_idcont_ \
1844-
|NN const U8 *p \
1845-
|NN const U8 * const e
1844+
|SPTR const U8 *p \
1845+
|EPTR const U8 * const e
18461846
CRp |Size_t |is_utf8_perl_idstart_ \
1847-
|NN const U8 *p \
1848-
|NN const U8 * const e
1847+
|SPTR const U8 *p \
1848+
|EPTR const U8 * const e
18491849
ARTdmp |bool |is_utf8_string |NN const U8 *s \
18501850
|STRLEN len
18511851
ARTdip |bool |is_utf8_string_flags \
@@ -1873,11 +1873,11 @@ ATdip |bool |is_utf8_string_loclen_flags \
18731873
|NULLOK STRLEN *el \
18741874
|const U32 flags
18751875
APTdmp |bool |is_utf8_valid_partial_char \
1876-
|NN const U8 * const s0 \
1877-
|NN const U8 * const e
1876+
|SPTR const U8 * const s0 \
1877+
|EPTR const U8 * const e
18781878
ARTdip |bool |is_utf8_valid_partial_char_flags \
1879-
|NN const U8 * const s0 \
1880-
|NN const U8 * const e \
1879+
|SPTR const U8 * const s0 \
1880+
|EPTR const U8 * const e \
18811881
|const U32 flags
18821882

18831883
: Used in perly.y
@@ -3139,12 +3139,12 @@ Adp |const char *|scan_version \
31393139
|NN const char *s \
31403140
|NN SV *rv \
31413141
|bool qv
3142-
Adp |char * |scan_vstring |NN const char *s \
3143-
|NN const char * const e \
3142+
Adp |char * |scan_vstring |SPTR const char *s \
3143+
|EPTR const char * const e \
31443144
|NN SV *sv
31453145
EXpx |char * |scan_word |NN char *s \
3146-
|NN char *dest \
3147-
|NN char *dest_end \
3146+
|SPTR char *dest \
3147+
|EPTR char *dest_end \
31483148
|int allow_package \
31493149
|NN STRLEN *slp
31503150
Cp |U32 |seed
@@ -3758,27 +3758,27 @@ Cp |UV |to_uni_upper |UV c \
37583758
|NN U8 *p \
37593759
|NN STRLEN *lenp
37603760
Cp |UV |to_utf8_fold_flags_ \
3761-
|NN const U8 *p \
3762-
|NN const U8 *e \
3761+
|SPTR const U8 *p \
3762+
|EPTR const U8 *e \
37633763
|NN U8 *ustrp \
37643764
|NULLOK STRLEN *lenp \
37653765
|U8 flags
37663766

37673767
Cp |UV |to_utf8_lower_flags_ \
3768-
|NN const U8 *p \
3769-
|NN const U8 *e \
3768+
|SPTR const U8 *p \
3769+
|EPTR const U8 *e \
37703770
|NN U8 *ustrp \
37713771
|NULLOK STRLEN *lenp \
37723772
|bool flags
37733773
Cp |UV |to_utf8_title_flags_ \
3774-
|NN const U8 *p \
3775-
|NN const U8 *e \
3774+
|SPTR const U8 *p \
3775+
|EPTR const U8 *e \
37763776
|NN U8 *ustrp \
37773777
|NULLOK STRLEN *lenp \
37783778
|bool flags
37793779
Cp |UV |to_utf8_upper_flags_ \
3780-
|NN const U8 *p \
3781-
|NN const U8 *e \
3780+
|SPTR const U8 *p \
3781+
|EPTR const U8 *e \
37823782
|NN U8 *ustrp \
37833783
|NULLOK STRLEN *lenp \
37843784
|bool flags
@@ -5847,8 +5847,8 @@ Ei |I32 |foldEQ_latin1_s2_folded \
58475847
ERS |bool |isFOO_lc |const U8 classnum \
58485848
|const U8 character
58495849
ERS |bool |isFOO_utf8_lc |const U8 classnum \
5850-
|NN const U8 *character \
5851-
|NN const U8 *e
5850+
|SPTR const U8 *character \
5851+
|EPTR const U8 *e
58525852
ERS |bool |isGCB |const GCB_enum before \
58535853
|const GCB_enum after \
58545854
|NN const U8 * const strbeg \
@@ -5892,8 +5892,8 @@ ERST |U8 * |reghopmaybe3 |NN U8 *s \
58925892
|NN const U8 * const lim
58935893
ERS |bool |reginclass |NULLOK regexp * const prog \
58945894
|NN const regnode * const n \
5895-
|NN const U8 * const p \
5896-
|NN const U8 * const p_end \
5895+
|SPTR const U8 * const p \
5896+
|EPTR const U8 * const p_end \
58975897
|bool const utf8_target
58985898
ERS |SSize_t|regmatch |NN regmatch_info *reginfo \
58995899
|NN char *startpos \
@@ -6181,8 +6181,8 @@ RS |char * |scan_const |NN char *start
61816181
RS |char * |scan_formline |NN char *s
61826182
RS |char * |scan_heredoc |NN char *s
61836183
S |char * |scan_ident |NN char *s \
6184-
|NN char *dest \
6185-
|NN char *dest_end \
6184+
|SPTR char *dest \
6185+
|EPTR char *dest_end \
61866186
|bool chk_unary
61876187
RS |char * |scan_inputsymbol \
61886188
|NN char *start
@@ -6247,8 +6247,8 @@ RS |UV |check_locale_boundary_crossing \
62476247
|NN U8 * const ustrp \
62486248
|NN STRLEN *lenp
62496249
RTi |int |does_utf8_overflow \
6250-
|NN const U8 * const s \
6251-
|NN const U8 *e
6250+
|SPTR const U8 * const s \
6251+
|EPTR const U8 *e
62526252
RTi |int |isFF_overlong |NN const U8 * const s \
62536253
|const STRLEN len
62546254
RTi |SSize_t|is_utf8_overlong \
@@ -6278,16 +6278,16 @@ S |UV |to_utf8_case_ |const UV original \
62786278
|NULLOK const U32 * const * const aux_tables \
62796279
|NULLOK const U8 * const aux_table_lengths \
62806280
|NN const char * const normal
6281-
S |UV |turkic_fc |NN const U8 * const p \
6282-
|NN const U8 * const e \
6281+
S |UV |turkic_fc |SPTR const U8 * const p \
6282+
|EPTR const U8 * const e \
62836283
|NN U8 *ustrp \
62846284
|NN STRLEN *lenp
6285-
S |UV |turkic_lc |NN const U8 * const p0 \
6286-
|NN const U8 * const e \
6285+
S |UV |turkic_lc |SPTR const U8 * const p0 \
6286+
|EPTR const U8 * const e \
62876287
|NN U8 *ustrp \
62886288
|NN STRLEN *lenp
6289-
S |UV |turkic_uc |NN const U8 * const p \
6290-
|NN const U8 * const e \
6289+
S |UV |turkic_uc |SPTR const U8 * const p \
6290+
|EPTR const U8 * const e \
62916291
|NN U8 *ustrp \
62926292
|NN STRLEN *lenp
62936293
RS |char * |unexpected_non_continuation_text \

proto.h

Lines changed: 21 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

utf8.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ STRLEN
725725
Perl_is_utf8_char_helper_(const U8 * const s, const U8 * e, const U32 flags)
726726
{
727727
PERL_ARGS_ASSERT_IS_UTF8_CHAR_HELPER_;
728-
assert(e > s);
729728
assert(0 == (flags & ~UTF8_DISALLOW_ILLEGAL_INTERCHANGE));
730729

731730
SSize_t len, full_len;
@@ -755,6 +754,7 @@ Perl_is_utf8_char_helper_(const U8 * const s, const U8 * e, const U32 flags)
755754
* determined with just the first one or two bytes.
756755
*
757756
*/
757+
758758
full_len = UTF8SKIP(s);
759759

760760
len = e - s;
@@ -840,7 +840,6 @@ Perl_is_utf8_FF_helper_(const U8 * const s0, const U8 * const e,
840840
const bool require_partial)
841841
{
842842
PERL_ARGS_ASSERT_IS_UTF8_FF_HELPER_;
843-
assert(s0 < e);
844843
assert(*s0 == I8_TO_NATIVE_UTF8(0xFF));
845844

846845
/* This is called to determine if the UTF-8 sequence starting at s0 and
@@ -4245,7 +4244,6 @@ S_turkic_fc(pTHX_ const U8 * const p, const U8 * const e,
42454244
U8 * ustrp, STRLEN *lenp)
42464245
{
42474246
PERL_ARGS_ASSERT_TURKIC_FC;
4248-
assert(e > p);
42494247

42504248
/* Returns 0 if the foldcase of the input UTF-8 encoded sequence from
42514249
* p0..e-1 according to Turkic rules is the same as for non-Turkic.
@@ -4280,7 +4278,6 @@ S_turkic_lc(pTHX_ const U8 * const p0, const U8 * const e,
42804278
U8 * ustrp, STRLEN *lenp)
42814279
{
42824280
PERL_ARGS_ASSERT_TURKIC_LC;
4283-
assert(e > p0);
42844281

42854282
/* Returns 0 if the lowercase of the input UTF-8 encoded sequence from
42864283
* p0..e-1 according to Turkic rules is the same as for non-Turkic.
@@ -4326,7 +4323,6 @@ S_turkic_uc(pTHX_ const U8 * const p, const U8 * const e,
43264323
U8 * ustrp, STRLEN *lenp)
43274324
{
43284325
PERL_ARGS_ASSERT_TURKIC_UC;
4329-
assert(e > p);
43304326

43314327
/* Returns 0 if the upper or title-case of the input UTF-8 encoded sequence
43324328
* from p0..e-1 according to Turkic rules is the same as for non-Turkic.

0 commit comments

Comments
 (0)