Skip to content

Commit 3ca8d66

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 69734ba commit 3ca8d66

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

regcomp.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,13 +2093,11 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
20932093
/* search for "restudy" in this file for a detailed explanation */
20942094
DEBUG_PARSE_r(
20952095
if (!restudied)
2096-
Perl_re_printf( aTHX_ "first at %" IVdf "\n",
2097-
(IV)(first - scan + 1))
2096+
Perl_re_printf( aTHX_ "first at %td\n", first - scan + 1)
20982097
);
20992098
#else
21002099
DEBUG_PARSE_r(
2101-
Perl_re_printf( aTHX_ "first at %" IVdf "\n",
2102-
(IV)(first - scan + 1))
2100+
Perl_re_printf( aTHX_ "first at %td\n", first - scan + 1)
21032101
);
21042102
#endif
21052103

@@ -4384,12 +4382,12 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth)
43844382
DEBUG_PARSE_MSG("lsbr");
43854383
regprop(RExC_rx, RExC_mysv1, REGNODE_p(lastbr), NULL, pRExC_state);
43864384
regprop(RExC_rx, RExC_mysv2, REGNODE_p(ender), NULL, pRExC_state);
4387-
Perl_re_printf( aTHX_ "~ tying lastbr %s (%" IVdf ") to ender %s (%" IVdf ") offset %" IVdf "\n",
4385+
Perl_re_printf( aTHX_ "~ tying lastbr %s (%" IVdf ") to ender %s (%" IVdf ") offset %td\n",
43884386
SvPV_nolen_const(RExC_mysv1),
43894387
(IV)lastbr,
43904388
SvPV_nolen_const(RExC_mysv2),
43914389
(IV)ender,
4392-
(IV)(ender - lastbr)
4390+
(ender - lastbr)
43934391
);
43944392
});
43954393
if (OP(REGNODE_p(lastbr)) == BRANCH) {
@@ -4448,12 +4446,12 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth)
44484446
NULL, pRExC_state);
44494447
regprop(RExC_rx, RExC_mysv2, REGNODE_p(ender),
44504448
NULL, pRExC_state);
4451-
Perl_re_printf( aTHX_ "~ converting ret %s (%" IVdf ") to ender %s (%" IVdf ") offset %" IVdf "\n",
4449+
Perl_re_printf( aTHX_ "~ converting ret %s (%" IVdf ") to ender %s (%" IVdf ") offset %td\n",
44524450
SvPV_nolen_const(RExC_mysv1),
44534451
(IV)REG_NODE_NUM(ret_as_regnode),
44544452
SvPV_nolen_const(RExC_mysv2),
44554453
(IV)ender,
4456-
(IV)(ender - ret)
4454+
(ender - ret)
44574455
);
44584456
});
44594457
OP(br)= NOTHING;
@@ -7435,8 +7433,8 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
74357433
if (need_to_fold_loc) {
74367434
upper_fill = loc_correspondence[s - s_start];
74377435
if (upper_fill == 0) {
7438-
FAIL2("panic: loc_correspondence[%d] is 0",
7439-
(int) (s - s_start));
7436+
FAIL2("panic: loc_correspondence[%td] is 0",
7437+
(s - s_start));
74407438
}
74417439
Safefree(locfold_buf);
74427440
Safefree(loc_correspondence);
@@ -13147,10 +13145,10 @@ S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode_offset p,
1314713145
DEBUG_PARSE_MSG("");
1314813146
regprop(RExC_rx, RExC_mysv, REGNODE_p(val), NULL, pRExC_state);
1314913147
Perl_re_printf( aTHX_
13150-
"~ attach to %s (%" IVdf ") offset to %" IVdf "\n",
13148+
"~ attach to %s (%zd) offset to %td\n",
1315113149
SvPV_nolen_const(RExC_mysv),
1315213150
(IV)val,
13153-
(IV)(val - scan)
13151+
(val - scan)
1315413152
);
1315513153
});
1315613154
if (REGNODE_OFF_BY_ARG(OP(REGNODE_p(scan)))) {
@@ -13913,7 +13911,7 @@ Perl_save_re_context(pTHX)
1391313911
for (i = 1; i <= nparens; i++) {
1391413912
char digits[TYPE_CHARS(long)];
1391513913
const STRLEN len = my_snprintf(digits, sizeof(digits),
13916-
"%lu", (long)i);
13914+
"%" I32df, i);
1391713915
GV *const *const gvp
1391813916
= (GV**)hv_fetch(PL_defstash, digits, len, 0);
1391913917

@@ -13925,7 +13923,6 @@ Perl_save_re_context(pTHX)
1392513923
}
1392613924
}
1392713925
#endif
13928-
1392913926
#ifndef PERL_IN_XSUB_RE
1393013927

1393113928
# include "uni_keywords.h"
@@ -16329,7 +16326,7 @@ S_handle_names_wildcard(pTHX_ const char * wname, /* wildcard name to match */
1632916326
* were returned to us in the array 'algorithmic_names' from data in
1633016327
* lib/unicore/Name.pm. 'code_point' in the name is expressed in hex. */
1633116328
for (i = 0; i <= av_top_index((AV *) algorithmic_names); i++) {
16332-
IV j;
16329+
SSize_t j;
1633316330

1633416331
/* Each element of the array is a hash, giving the details for the
1633516332
* series of names it covers. There is the base name of the characters
@@ -16360,8 +16357,7 @@ S_handle_names_wildcard(pTHX_ const char * wname, /* wildcard name to match */
1636016357
for (j = low; j <= high; j++) { /* For each code point in the series */
1636116358

1636216359
/* Get its name, and see if it matches the subpattern */
16363-
sv_setpvf(algo_name, "%s-%X", SvPVX(prefix),
16364-
(unsigned) j);
16360+
sv_setpvf(algo_name, "%s-%zX", SvPVX(prefix), j);
1636516361

1636616362
if (execute_wildcard(subpattern_re,
1636716363
SvPVX(algo_name),

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)