Skip to content

Commit e5c1651

Browse files
committed
regcomp(_internal).c: Avoid some casts in prints
We have modifiers like %z and %t to portably print items of the given type. This converts to use those in these files, removing casts that were previously used.
1 parent 76a273b commit e5c1651

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

regcomp.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
18951895

18961896
DEBUG_PARSE_r({
18971897
Perl_re_printf( aTHX_
1898-
"Required size %" IVdf " nodes\n", (IV)RExC_size);
1898+
"Required size %zd nodes\n", RExC_size);
18991899
RExC_lastnum = 0;
19001900
RExC_lastparse = NULL;
19011901
});
@@ -2095,13 +2095,11 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
20952095
/* search for "restudy" in this file for a detailed explanation */
20962096
DEBUG_PARSE_r(
20972097
if (!restudied)
2098-
Perl_re_printf( aTHX_ "first at %" IVdf "\n",
2099-
(IV)(first - scan + 1))
2098+
Perl_re_printf( aTHX_ "first at %td\n", first - scan + 1)
21002099
);
21012100
#else
21022101
DEBUG_PARSE_r(
2103-
Perl_re_printf( aTHX_ "first at %" IVdf "\n",
2104-
(IV)(first - scan + 1))
2102+
Perl_re_printf( aTHX_ "first at %td\n", first - scan + 1)
21052103
);
21062104
#endif
21072105

@@ -2325,8 +2323,8 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
23252323
/* Guard against an embedded (?=) or (?<=) with a longer minlen than
23262324
the "real" pattern. */
23272325
DEBUG_OPTIMISE_r({
2328-
Perl_re_printf( aTHX_ "minlen: %" IVdf " RExC_rx->minlen:%" IVdf " maxlen:%" IVdf "\n",
2329-
(IV)minlen, (IV)RExC_rx->minlen, (IV)RExC_maxlen);
2326+
Perl_re_printf( aTHX_ "minlen: %zd RExC_rx->minlen:%zd maxlen:%zd\n",
2327+
minlen, RExC_rx->minlen, RExC_maxlen);
23302328
});
23312329
RExC_rx->minlenret = minlen;
23322330
if (RExC_rx->minlen < minlen)
@@ -4386,12 +4384,12 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth)
43864384
DEBUG_PARSE_MSG("lsbr");
43874385
regprop(RExC_rx, RExC_mysv1, REGNODE_p(lastbr), NULL, pRExC_state);
43884386
regprop(RExC_rx, RExC_mysv2, REGNODE_p(ender), NULL, pRExC_state);
4389-
Perl_re_printf( aTHX_ "~ tying lastbr %s (%" IVdf ") to ender %s (%" IVdf ") offset %" IVdf "\n",
4387+
Perl_re_printf( aTHX_ "~ tying lastbr %s (%zd) to ender %s (%zd) offset %zd\n",
43904388
SvPV_nolen_const(RExC_mysv1),
4391-
(IV)lastbr,
4389+
lastbr,
43924390
SvPV_nolen_const(RExC_mysv2),
4393-
(IV)ender,
4394-
(IV)(ender - lastbr)
4391+
ender,
4392+
(ender - lastbr)
43954393
);
43964394
});
43974395
if (OP(REGNODE_p(lastbr)) == BRANCH) {
@@ -4450,12 +4448,12 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth)
44504448
NULL, pRExC_state);
44514449
regprop(RExC_rx, RExC_mysv2, REGNODE_p(ender),
44524450
NULL, pRExC_state);
4453-
Perl_re_printf( aTHX_ "~ converting ret %s (%" IVdf ") to ender %s (%" IVdf ") offset %" IVdf "\n",
4451+
Perl_re_printf( aTHX_ "~ converting ret %s (%" IVdf ") to ender %s (%zd) offset %zd\n",
44544452
SvPV_nolen_const(RExC_mysv1),
44554453
(IV)REG_NODE_NUM(ret_as_regnode),
44564454
SvPV_nolen_const(RExC_mysv2),
4457-
(IV)ender,
4458-
(IV)(ender - ret)
4455+
ender,
4456+
(ender - ret)
44594457
);
44604458
});
44614459
OP(br)= NOTHING;
@@ -7437,8 +7435,8 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
74377435
if (need_to_fold_loc) {
74387436
upper_fill = loc_correspondence[s - s_start];
74397437
if (upper_fill == 0) {
7440-
FAIL2("panic: loc_correspondence[%d] is 0",
7441-
(int) (s - s_start));
7438+
FAIL2("panic: loc_correspondence[%td] is 0",
7439+
(s - s_start));
74427440
}
74437441
Safefree(locfold_buf);
74447442
Safefree(loc_correspondence);
@@ -13149,10 +13147,10 @@ S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode_offset p,
1314913147
DEBUG_PARSE_MSG("");
1315013148
regprop(RExC_rx, RExC_mysv, REGNODE_p(val), NULL, pRExC_state);
1315113149
Perl_re_printf( aTHX_
13152-
"~ attach to %s (%" IVdf ") offset to %" IVdf "\n",
13150+
"~ attach to %s (%zd) offset to %zd\n",
1315313151
SvPV_nolen_const(RExC_mysv),
13154-
(IV)val,
13155-
(IV)(val - scan)
13152+
val,
13153+
(val - scan)
1315613154
);
1315713155
});
1315813156
if (REGNODE_OFF_BY_ARG(OP(REGNODE_p(scan)))) {
@@ -13915,7 +13913,7 @@ Perl_save_re_context(pTHX)
1391513913
for (i = 1; i <= nparens; i++) {
1391613914
char digits[TYPE_CHARS(long)];
1391713915
const STRLEN len = my_snprintf(digits, sizeof(digits),
13918-
"%lu", (long)i);
13916+
"%" I32df, i);
1391913917
GV *const *const gvp
1392013918
= (GV**)hv_fetch(PL_defstash, digits, len, 0);
1392113919

@@ -13927,7 +13925,6 @@ Perl_save_re_context(pTHX)
1392713925
}
1392813926
}
1392913927
#endif
13930-
1393113928
#ifndef PERL_IN_XSUB_RE
1393213929

1393313930
# include "uni_keywords.h"

regcomp_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,10 +864,10 @@ static const scan_data_t zero_scan_data = {
864864
? eI - sI /* Length before the <--HERE */ \
865865
: ((xI_offset(xC) >= 0) \
866866
? xI_offset(xC) \
867-
: (croak("panic: %s: %d: negative offset: %" \
868-
IVdf " trying to output message for " \
867+
: (croak("panic: %s: %d: negative offset: " \
868+
" %td trying to output message for " \
869869
" pattern %.*s", \
870-
__FILE__, __LINE__, (IV) xI_offset(xC), \
870+
__FILE__, __LINE__, xI_offset(xC), \
871871
((int) (eC - sC)), sC), 0)), \
872872
sI), /* The input pattern printed up to the <--HERE */ \
873873
UTF8fARG(UTF, \

0 commit comments

Comments
 (0)