Skip to content

Commit 4f5164a

Browse files
committed
Convert all core uses of _ASSERT__() to assert()
The former symbol is undefined behavior in C and C++.
1 parent a45f656 commit 4f5164a

File tree

11 files changed

+63
-63
lines changed

11 files changed

+63
-63
lines changed

av.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ If all you need is to look up an array element, then prefer C<av_fetch>.
122122
* SvGETMAGIC(av); IV x = av_tindex_nomg(av);
123123
*/
124124
# define av_top_index_skip_len_mg(av) \
125-
(__ASSERT_(SvTYPE(av) == SVt_PVAV) AvFILLp(av))
125+
(assert(SvTYPE(av) == SVt_PVAV), AvFILLp(av))
126126
# define av_tindex_skip_len_mg(av) av_top_index_skip_len_mg(av)
127127

128128
#define NEGATIVE_INDICES_VAR "NEGATIVE_INDICES"

handy.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ or casts
14141414
*
14151415
* NOT suitable for void*
14161416
*/
1417-
#define ASSERT_IS_PTR(x) (__ASSERT_(sizeof(*(x))) (x))
1417+
#define ASSERT_IS_PTR(x) (assert(sizeof(*(x))), (x))
14181418

14191419
/* FITS_IN_8_BITS(c) returns true if c doesn't have a bit set other than in
14201420
* the lower 8. It is designed to be hopefully bomb-proof, making sure that no
@@ -1439,8 +1439,8 @@ or casts
14391439
* needed. (The NV casts stop any warnings about comparison always being true
14401440
* if called with an unsigned. The cast preserves the sign, which is all we
14411441
* care about.) */
1442-
#define withinCOUNT(c, l, n) (__ASSERT_((NV) (l) >= 0) \
1443-
__ASSERT_((NV) (n) >= 0) \
1442+
#define withinCOUNT(c, l, n) (assert((NV) (l) >= 0), \
1443+
assert((NV) (n) >= 0), \
14441444
withinCOUNT_KNOWN_VALID_((c), (l), (n)))
14451445

14461446
/* For internal use only, this can be used in places where it is known that the
@@ -1455,11 +1455,11 @@ or casts
14551455
/* Returns true if c is in the range l..u, where 'l' is non-negative
14561456
* Written this way so that after optimization, only one conditional test is
14571457
* needed. */
1458-
#define inRANGE(c, l, u) (__ASSERT_((NV) (l) >= 0) __ASSERT_((u) >= (l)) \
1458+
#define inRANGE(c, l, u) (assert((NV) (l) >= 0), assert((u) >= (l)), \
14591459
( (sizeof(c) == sizeof(U8)) ? inRANGE_helper_(U8, (c), (l), ((u))) \
14601460
: (sizeof(c) == sizeof(U16)) ? inRANGE_helper_(U16,(c), (l), ((u))) \
14611461
: (sizeof(c) == sizeof(U32)) ? inRANGE_helper_(U32,(c), (l), ((u))) \
1462-
: (__ASSERT_(sizeof(c) == sizeof(WIDEST_UTYPE)) \
1462+
: (assert(sizeof(c) == sizeof(WIDEST_UTYPE)), \
14631463
inRANGE_helper_(WIDEST_UTYPE,(c), (l), ((u))))))
14641464

14651465
/* For internal use, this is used by machine-generated code which generates
@@ -2098,7 +2098,7 @@ END_EXTERN_C
20982098
: ((UNLIKELY(((U8) (c)) == LATIN_SMALL_LETTER_Y_WITH_DIAERESIS) \
20992099
? LATIN_CAPITAL_LETTER_Y_WITH_DIAERESIS \
21002100
: (UNLIKELY(((U8)(c)) == LATIN_SMALL_LETTER_SHARP_S) \
2101-
? (__ASSERT_(0) (c)) /* Fail on Sharp S in DEBUGGING */ \
2101+
? (assert(0), (c)) /* Fail on Sharp S in DEBUGGING */ \
21022102
: PL_mod_latin1_uc[ (U8) (c) ]))))))
21032103

21042104
/* In this macro, note that the result can be larger than a byte in a UTF-8
@@ -2110,8 +2110,8 @@ END_EXTERN_C
21102110
# define toFOLD_LC(c) \
21112111
((UNLIKELY((c) == MICRO_SIGN) && IN_UTF8_CTYPE_LOCALE) \
21122112
? GREEK_SMALL_LETTER_MU \
2113-
: (__ASSERT_( ! IN_UTF8_CTYPE_LOCALE \
2114-
|| LIKELY((c) != LATIN_SMALL_LETTER_SHARP_S)) \
2113+
: (assert( ! IN_UTF8_CTYPE_LOCALE \
2114+
|| LIKELY((c) != LATIN_SMALL_LETTER_SHARP_S)), \
21152115
toLOWER_LC(c)))
21162116
#endif
21172117

@@ -2286,7 +2286,7 @@ END_EXTERN_C
22862286
* class is TRUE for. Hence it can skip the tests for this range.
22872287
* 'above_latin1' should include its arguments */
22882288
#define generic_utf8_safe_no_upper_latin1_(classnum, p, e, above_latin1) \
2289-
(__ASSERT_(utf8_safe_assert_(p, e)) \
2289+
(assert(utf8_safe_assert_(p, e)), \
22902290
(isASCII(*(p))) \
22912291
? generic_isCC_(*(p), classnum) \
22922292
: (UTF8_IS_DOWNGRADEABLE_START(*(p))) \
@@ -2504,9 +2504,9 @@ END_EXTERN_C
25042504
* The conversion works both ways, so toCTRL('D') is 4, and toCTRL(4) is D,
25052505
* etc. */
25062506
#ifndef EBCDIC
2507-
# define toCTRL(c) (__ASSERT_(FITS_IN_8_BITS(c)) toUPPER(((U8)(c))) ^ 64)
2507+
# define toCTRL(c) (assert(FITS_IN_8_BITS(c)), toUPPER(((U8)(c))) ^ 64)
25082508
#else
2509-
# define toCTRL(c) (__ASSERT_(FITS_IN_8_BITS(c)) \
2509+
# define toCTRL(c) (assert(FITS_IN_8_BITS(c)), \
25102510
((isPRINT_A(c)) \
25112511
? (UNLIKELY((c) == '?') \
25122512
? QUESTION_MARK_CTRL \
@@ -2550,7 +2550,7 @@ typedef U32 line_t;
25502550
* position, and then to the eights position. Both are added together to form
25512551
* 0 if the input is '0'-'9' and to form 9 if alpha. This is added to the
25522552
* final four bits of the input to form the correct value. */
2553-
#define XDIGIT_VALUE(c) (__ASSERT_(isXDIGIT(c)) \
2553+
#define XDIGIT_VALUE(c) (assert(isXDIGIT(c)), \
25542554
((NATIVE_TO_LATIN1(c) >> 6) & 1) /* 1 if alpha; 0 if not */ \
25552555
+ ((NATIVE_TO_LATIN1(c) >> 3) & 8) /* 8 if alpha; 0 if not */ \
25562556
+ ((c) & 0xF)) /* 0-9 if input valid hex digit */
@@ -2561,7 +2561,7 @@ typedef U32 line_t;
25612561
/* Converts a character known to represent an octal digit (0-7) to its numeric
25622562
* value. The input is validated only by an assert() in DEBUGGING builds. In
25632563
* both ASCII and EBCDIC the last 3 bits of the octal digits range from 0-7. */
2564-
#define OCTAL_VALUE(c) (__ASSERT_(isOCTAL(c)) (7 & (c)))
2564+
#define OCTAL_VALUE(c) (assert(isOCTAL(c)), (7 & (c)))
25652565

25662566
/* Efficiently returns a boolean as to if two native characters are equivalent
25672567
* case-insensitively. At least one of the characters must be one of [A-Za-z];
@@ -2578,7 +2578,7 @@ typedef U32 line_t;
25782578
* just a single 0, in the bit position where the upper- and lowercase differ.
25792579
* */
25802580
#define isALPHA_FOLD_EQ(c1, c2) \
2581-
(__ASSERT_(isALPHA_A(c1) || isALPHA_A(c2)) \
2581+
(assert(isALPHA_A(c1) || isALPHA_A(c2)), \
25822582
((c1) & ~('A' ^ 'a')) == ((c2) & ~('A' ^ 'a')))
25832583
#define isALPHA_FOLD_NE(c1, c2) (! isALPHA_FOLD_EQ((c1), (c2)))
25842584

locale.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,11 +2776,11 @@ S_bool_setlocale_2008_i(pTHX_
27762776
* calculate_LC_ALL_string() for that. */
27772777
#ifdef USE_LOCALE_NUMERIC
27782778
# define query_nominal_locale_i(i) \
2779-
(__ASSERT_(i != LC_ALL_INDEX_) \
2779+
(assert(i != LC_ALL_INDEX_), \
27802780
((i == LC_NUMERIC_INDEX_) ? PL_numeric_name : querylocale_i(i)))
27812781
#elif defined(USE_LOCALE)
27822782
# define query_nominal_locale_i(i) \
2783-
(__ASSERT_(i != LC_ALL_INDEX_) querylocale_i(i))
2783+
(assert(i != LC_ALL_INDEX_), querylocale_i(i))
27842784
#else
27852785
# define query_nominal_locale_i(i) "C"
27862786
#endif

regcomp.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ struct regnode_ssc {
488488
#define FLAGS(p) ((p)->head.data.u_8.flags) /* Caution: Doesn't apply to all \
489489
regnode types. For some, it's the \
490490
character set of the regnode */
491-
#define STR_LENs(p) (__ASSERT_(OP(p) != LEXACT && OP(p) != LEXACT_REQ8) \
491+
#define STR_LENs(p) (assert(OP(p) != LEXACT && OP(p) != LEXACT_REQ8), \
492492
STR_LEN_U8((struct regnode_string *)p))
493-
#define STRINGs(p) (__ASSERT_(OP(p) != LEXACT && OP(p) != LEXACT_REQ8) \
493+
#define STRINGs(p) (assert(OP(p) != LEXACT && OP(p) != LEXACT_REQ8), \
494494
((struct regnode_string *)p)->string)
495495
#define OPERANDs(p) STRINGs(p)
496496

@@ -510,9 +510,9 @@ struct regnode_ssc {
510510
* node to be an ARG2L, using the second 32 bit field for the length, and not
511511
* using the flags nor next_off fields at all. One could have an llstring node
512512
* and even an lllstring type. */
513-
#define STR_LENl(p) (__ASSERT_(OP(p) == LEXACT || OP(p) == LEXACT_REQ8) \
513+
#define STR_LENl(p) (assert(OP(p) == LEXACT || OP(p) == LEXACT_REQ8), \
514514
(((struct regnode_lstring *)p)->str_len_u32))
515-
#define STRINGl(p) (__ASSERT_(OP(p) == LEXACT || OP(p) == LEXACT_REQ8) \
515+
#define STRINGl(p) (assert(OP(p) == LEXACT || OP(p) == LEXACT_REQ8), \
516516
(((struct regnode_lstring *)p)->string))
517517
#define OPERANDl(p) STRINGl(p)
518518

regcomp_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ static const scan_data_t zero_scan_data = {
11001100
/* Convert between a pointer to a node and its offset from the beginning of the
11011101
* program */
11021102
#define REGNODE_p(offset) (RExC_emit_start + (offset))
1103-
#define REGNODE_OFFSET(node) (__ASSERT_((node) >= RExC_emit_start) \
1103+
#define REGNODE_OFFSET(node) (assert((node) >= RExC_emit_start), \
11041104
(SSize_t) ((node) - RExC_emit_start))
11051105

11061106
#define ProgLen(ri) ri->proglen

regen/regcomp.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ sub print_process_EXACTish {
302302
print $out <<EOP,
303303
304304
/* Is 'op', known to be of type EXACT, folding? */
305-
#define isEXACTFish(op) (__ASSERT_(REGNODE_TYPE(op) == EXACT) (PL_EXACTFish_bitmask & (1U << (op - EXACT))))
305+
#define isEXACTFish(op) (assert(REGNODE_TYPE(op) == EXACT), (PL_EXACTFish_bitmask & (1U << (op - EXACT))))
306306
307307
/* Do only UTF-8 target strings match 'op', known to be of type EXACT? */
308-
#define isEXACT_REQ8(op) (__ASSERT_(REGNODE_TYPE(op) == EXACT) (PL_EXACT_REQ8_bitmask & (1U << (op - EXACT))))
308+
#define isEXACT_REQ8(op) (assert(REGNODE_TYPE(op) == EXACT), (PL_EXACT_REQ8_bitmask & (1U << (op - EXACT))))
309309
310310
#ifndef DOINIT
311311
EXTCONST U32 PL_EXACTFish_bitmask;

regexec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,7 @@ S_get_break_val_cp_checked(SV* const invlist, const UV cp_in) {
22112211
* And it takes the particular macro name that finds the desired value given a
22122212
* code point. Merely convert the UTF-8 to code point and call the cp macro */
22132213
#define generic_GET_BREAK_VAL_UTF8_(cp_macro, pos, strend) \
2214-
(__ASSERT_(pos < strend) \
2214+
(assert(pos < strend), \
22152215
/* Note assumes is valid UTF-8 */ \
22162216
(cp_macro(utf8_to_uv_or_die((pos), (strend), NULL))))
22172217

regnodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,10 +2962,10 @@ EXTCONST U8 PL_simple_bitmask[] = {
29622962
#endif /* DOINIT */
29632963

29642964
/* Is 'op', known to be of type EXACT, folding? */
2965-
#define isEXACTFish(op) (__ASSERT_(REGNODE_TYPE(op) == EXACT) (PL_EXACTFish_bitmask & (1U << (op - EXACT))))
2965+
#define isEXACTFish(op) (assert(REGNODE_TYPE(op) == EXACT), (PL_EXACTFish_bitmask & (1U << (op - EXACT))))
29662966

29672967
/* Do only UTF-8 target strings match 'op', known to be of type EXACT? */
2968-
#define isEXACT_REQ8(op) (__ASSERT_(REGNODE_TYPE(op) == EXACT) (PL_EXACT_REQ8_bitmask & (1U << (op - EXACT))))
2968+
#define isEXACT_REQ8(op) (assert(REGNODE_TYPE(op) == EXACT), (PL_EXACT_REQ8_bitmask & (1U << (op - EXACT))))
29692969

29702970
#ifndef DOINIT
29712971
EXTCONST U32 PL_EXACTFish_bitmask;

0 commit comments

Comments
 (0)