[12/17] Regex: Minor miscellaneous cleanups.
Commit Message
This patch supplies small code cleanups that didn't fall together with
any of the other patches in this series.
2017-11-30 Arnold D. Robbins <arnold@skeeve.com>
Minor miscellaneous cleanups.
* posix/regcomp.c (re_compile_internal): Pass boolean to
re_string_construct instead of random non-zero value.
(build_equiv_class): Init char_buf[1] to '\0'.
(build_charclass_op): Initialize br_token to zero.
(create_tree): Initialize 't' to zero..
@@ -775,7 +775,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
__libc_lock_init (dfa->lock);
err = re_string_construct (®exp, pattern, length, preg->translate,
- syntax & RE_ICASE, dfa);
+ (syntax & RE_ICASE) != 0, dfa);
if (BE (err != REG_NOERROR, 0))
{
re_compile_internal_free_return:
@@ -3463,6 +3463,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
return REG_ECOLLATE;
/* Build single byte matching table for this equivalence class. */
+ char_buf[1] = (unsigned char) '\0';
len = weights[idx1 & 0xffffff];
for (ch = 0; ch < SBC_MAX; ++ch)
{
@@ -3681,6 +3682,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
#endif
/* Build a tree for simple bracket. */
+ memset(& br_token, 0, sizeof(br_token)); /* silence "not initialized" errors froms static checkers */
br_token.type = SIMPLE_BRACKET;
br_token.opr.sbcset = sbcset;
tree = create_token_tree (dfa, NULL, NULL, &br_token);
@@ -3771,6 +3773,7 @@ create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
re_token_type_t type)
{
re_token_t t;
+ memset(& t, 0, sizeof(t)); /* silence "not initialized" errors froms static checkers */
t.type = type;
return create_token_tree (dfa, left, right, &t);
}
@@ -630,7 +630,8 @@ re_search_internal (const regex_t *preg, const char *string, int length,
fl_longest_match = (nmatch != 0 || dfa->nbackref);
err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
- preg->translate, preg->syntax & RE_ICASE, dfa);
+ preg->translate, (preg->syntax & RE_ICASE) != 0,
+ dfa);
if (BE (err != REG_NOERROR, 0))
goto free_return;
mctx.input.stop = stop;