[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] regex: omit needless signed-pointer casts
From: |
Paul Eggert |
Subject: |
[PATCH 2/2] regex: omit needless signed-pointer casts |
Date: |
Tue, 01 Jan 2013 16:38:06 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
* lib/regcomp.c (build_charclass, build_charclass_op):
Use char *, not unsigned char *, for class name and extra.
The char values are always nonnegative so there's no need to
insist on unsigned char * here, and using char * removes the need
for casts. Reported by Aharon Robbins in
<http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html>.
---
ChangeLog | 8 ++++++++
lib/regcomp.c | 26 +++++++++++++-------------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cbbc5b4..db79efc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2013-01-01 Paul Eggert <address@hidden>
+ regex: omit needless signed-pointer casts
+ * lib/regcomp.c (build_charclass, build_charclass_op):
+ Use char *, not unsigned char *, for class name and extra.
+ The char values are always nonnegative so there's no need to
+ insist on unsigned char * here, and using char * removes the need
+ for casts. Reported by Aharon Robbins in
+ <http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html>.
+
regex: support Gawk, which never uses alloca
* lib/regex_internal.h [!_LIBC && !HAVE_ALLOCA]:
Do not include in this case. Gawk doesn't supply a substitute
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 6d32726..0fdc3bc 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -94,20 +94,20 @@ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE
trans,
bitset_t sbcset,
re_charset_t *mbcset,
Idx *char_class_alloc,
- const unsigned char *class_name,
+ const char *class_name,
reg_syntax_t syntax);
#else /* not RE_ENABLE_I18N */
static reg_errcode_t build_equiv_class (bitset_t sbcset,
const unsigned char *name);
static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
bitset_t sbcset,
- const unsigned char *class_name,
+ const char *class_name,
reg_syntax_t syntax);
#endif /* not RE_ENABLE_I18N */
static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
RE_TRANSLATE_TYPE trans,
- const unsigned char *class_name,
- const unsigned char *extra,
+ const char *class_name,
+ const char *extra,
bool non_match, reg_errcode_t *err);
static bin_tree_t *create_tree (re_dfa_t *dfa,
bin_tree_t *left, bin_tree_t *right,
@@ -2422,8 +2422,8 @@ parse_expression (re_string_t *regexp, regex_t *preg,
re_token_t *token,
case OP_WORD:
case OP_NOTWORD:
tree = build_charclass_op (dfa, regexp->trans,
- (const unsigned char *) "alnum",
- (const unsigned char *) "_",
+ "alnum",
+ "_",
token->type == OP_NOTWORD, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
@@ -2431,8 +2431,8 @@ parse_expression (re_string_t *regexp, regex_t *preg,
re_token_t *token,
case OP_SPACE:
case OP_NOTSPACE:
tree = build_charclass_op (dfa, regexp->trans,
- (const unsigned char *) "space",
- (const unsigned char *) "",
+ "space",
+ "",
token->type == OP_NOTSPACE, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
@@ -3571,14 +3571,14 @@ static reg_errcode_t
#ifdef RE_ENABLE_I18N
build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
re_charset_t *mbcset, Idx *char_class_alloc,
- const unsigned char *class_name, reg_syntax_t syntax)
+ const char *class_name, reg_syntax_t syntax)
#else /* not RE_ENABLE_I18N */
build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
- const unsigned char *class_name, reg_syntax_t syntax)
+ const char *class_name, reg_syntax_t syntax)
#endif /* not RE_ENABLE_I18N */
{
int i;
- const char *name = (const char *) class_name;
+ const char *name = class_name;
/* In case of REG_ICASE "upper" and "lower" match the both of
upper and lower cases. */
@@ -3652,8 +3652,8 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
static bin_tree_t *
build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
- const unsigned char *class_name,
- const unsigned char *extra, bool non_match,
+ const char *class_name,
+ const char *extra, bool non_match,
reg_errcode_t *err)
{
re_bitset_ptr_t sbcset;
--
1.7.11.7