2025-04-13 Paul Eggert <eggert@cs.ucla.edu>
+ regex: pacify gcc -Wcalloc-transposed-args
+ * lib/regcomp.c (init_dfa, parse_bracket_exp)
+ (build_charclass_op):
+ * lib/regex_internal.c (create_ci_newstate, create_cd_newstate):
+ * lib/regexec.c (get_subexp, build_trtable):
+ When calling calloc, put size argument last.
+
regex: match current Emacs behavior
* config/srclist.txt: Comment out regex.h, since we now
disagree with glibc.
if (table_size > pat_len)
break;
- dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
+ dfa->state_table = calloc (table_size, sizeof (struct re_state_table_entry));
dfa->state_hash_mask = table_size - 1;
dfa->mb_cur_max = MB_CUR_MAX;
{
int i, j, ch;
- dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+ dfa->sb_char = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
if (__glibc_unlikely (dfa->sb_char == NULL))
return REG_ESPACE;
_NL_COLLATE_SYMB_EXTRAMB);
}
#endif
- sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
- mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+ sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
+ mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
{
re_free (sbcset);
reg_errcode_t ret;
bin_tree_t *tree;
- sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+ sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
if (__glibc_unlikely (sbcset == NULL))
{
*err = REG_ESPACE;
return NULL;
}
- mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+ mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
if (__glibc_unlikely (mbcset == NULL))
{
re_free (sbcset);
reg_errcode_t err;
re_dfastate_t *newstate;
- newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+ newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
if (__glibc_unlikely (newstate == NULL))
return NULL;
err = re_node_set_init_copy (&newstate->nodes, nodes);
reg_errcode_t err;
re_dfastate_t *newstate;
- newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+ newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
if (__glibc_unlikely (newstate == NULL))
return NULL;
err = re_node_set_init_copy (&newstate->nodes, nodes);
continue; /* No. */
if (sub_top->path == NULL)
{
- sub_top->path = calloc (sizeof (state_array_t),
- sl_str - sub_top->str_idx + 1);
+ sub_top->path = calloc (sl_str - sub_top->str_idx + 1,
+ sizeof (state_array_t));
if (sub_top->path == NULL)
return REG_ESPACE;
}
if (ndests == 0)
{
state->trtable = (re_dfastate_t **)
- calloc (sizeof (re_dfastate_t *), SBC_MAX);
+ calloc (SBC_MAX, sizeof (re_dfastate_t *));
if (__glibc_unlikely (state->trtable == NULL))
return false;
return true;
discern by looking at the character code: allocate a
256-entry transition table. */
trtable = state->trtable =
- (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
+ (re_dfastate_t **) calloc (SBC_MAX, sizeof (re_dfastate_t *));
if (__glibc_unlikely (trtable == NULL))
goto out_free;
transition tables, one starting at trtable[0] and one
starting at trtable[SBC_MAX]. */
trtable = state->word_trtable =
- (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
+ (re_dfastate_t **) calloc (2 * SBC_MAX, sizeof (re_dfastate_t *));
if (__glibc_unlikely (trtable == NULL))
goto out_free;