comparison lib/regcomp.c @ 17258:28b073aabf32

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>.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2013 16:27:46 -0800
parents e542fd46ad6f
children 7be3e941fb5b
comparison
equal deleted inserted replaced
17257:83362ee4d224 17258:28b073aabf32
92 const unsigned char *name); 92 const unsigned char *name);
93 static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, 93 static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
94 bitset_t sbcset, 94 bitset_t sbcset,
95 re_charset_t *mbcset, 95 re_charset_t *mbcset,
96 Idx *char_class_alloc, 96 Idx *char_class_alloc,
97 const unsigned char *class_name, 97 const char *class_name,
98 reg_syntax_t syntax); 98 reg_syntax_t syntax);
99 #else /* not RE_ENABLE_I18N */ 99 #else /* not RE_ENABLE_I18N */
100 static reg_errcode_t build_equiv_class (bitset_t sbcset, 100 static reg_errcode_t build_equiv_class (bitset_t sbcset,
101 const unsigned char *name); 101 const unsigned char *name);
102 static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, 102 static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
103 bitset_t sbcset, 103 bitset_t sbcset,
104 const unsigned char *class_name, 104 const char *class_name,
105 reg_syntax_t syntax); 105 reg_syntax_t syntax);
106 #endif /* not RE_ENABLE_I18N */ 106 #endif /* not RE_ENABLE_I18N */
107 static bin_tree_t *build_charclass_op (re_dfa_t *dfa, 107 static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
108 RE_TRANSLATE_TYPE trans, 108 RE_TRANSLATE_TYPE trans,
109 const unsigned char *class_name, 109 const char *class_name,
110 const unsigned char *extra, 110 const char *extra,
111 bool non_match, reg_errcode_t *err); 111 bool non_match, reg_errcode_t *err);
112 static bin_tree_t *create_tree (re_dfa_t *dfa, 112 static bin_tree_t *create_tree (re_dfa_t *dfa,
113 bin_tree_t *left, bin_tree_t *right, 113 bin_tree_t *left, bin_tree_t *right,
114 re_token_type_t type); 114 re_token_type_t type);
115 static bin_tree_t *create_token_tree (re_dfa_t *dfa, 115 static bin_tree_t *create_token_tree (re_dfa_t *dfa,
2420 dfa->has_mb_node = 1; 2420 dfa->has_mb_node = 1;
2421 break; 2421 break;
2422 case OP_WORD: 2422 case OP_WORD:
2423 case OP_NOTWORD: 2423 case OP_NOTWORD:
2424 tree = build_charclass_op (dfa, regexp->trans, 2424 tree = build_charclass_op (dfa, regexp->trans,
2425 (const unsigned char *) "alnum", 2425 "alnum",
2426 (const unsigned char *) "_", 2426 "_",
2427 token->type == OP_NOTWORD, err); 2427 token->type == OP_NOTWORD, err);
2428 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2428 if (BE (*err != REG_NOERROR && tree == NULL, 0))
2429 return NULL; 2429 return NULL;
2430 break; 2430 break;
2431 case OP_SPACE: 2431 case OP_SPACE:
2432 case OP_NOTSPACE: 2432 case OP_NOTSPACE:
2433 tree = build_charclass_op (dfa, regexp->trans, 2433 tree = build_charclass_op (dfa, regexp->trans,
2434 (const unsigned char *) "space", 2434 "space",
2435 (const unsigned char *) "", 2435 "",
2436 token->type == OP_NOTSPACE, err); 2436 token->type == OP_NOTSPACE, err);
2437 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2437 if (BE (*err != REG_NOERROR && tree == NULL, 0))
2438 return NULL; 2438 return NULL;
2439 break; 2439 break;
2440 case OP_ALT: 2440 case OP_ALT:
3569 3569
3570 static reg_errcode_t 3570 static reg_errcode_t
3571 #ifdef RE_ENABLE_I18N 3571 #ifdef RE_ENABLE_I18N
3572 build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, 3572 build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3573 re_charset_t *mbcset, Idx *char_class_alloc, 3573 re_charset_t *mbcset, Idx *char_class_alloc,
3574 const unsigned char *class_name, reg_syntax_t syntax) 3574 const char *class_name, reg_syntax_t syntax)
3575 #else /* not RE_ENABLE_I18N */ 3575 #else /* not RE_ENABLE_I18N */
3576 build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, 3576 build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3577 const unsigned char *class_name, reg_syntax_t syntax) 3577 const char *class_name, reg_syntax_t syntax)
3578 #endif /* not RE_ENABLE_I18N */ 3578 #endif /* not RE_ENABLE_I18N */
3579 { 3579 {
3580 int i; 3580 int i;
3581 const char *name = (const char *) class_name; 3581 const char *name = class_name;
3582 3582
3583 /* In case of REG_ICASE "upper" and "lower" match the both of 3583 /* In case of REG_ICASE "upper" and "lower" match the both of
3584 upper and lower cases. */ 3584 upper and lower cases. */
3585 if ((syntax & RE_ICASE) 3585 if ((syntax & RE_ICASE)
3586 && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0)) 3586 && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
3650 return REG_NOERROR; 3650 return REG_NOERROR;
3651 } 3651 }
3652 3652
3653 static bin_tree_t * 3653 static bin_tree_t *
3654 build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, 3654 build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3655 const unsigned char *class_name, 3655 const char *class_name,
3656 const unsigned char *extra, bool non_match, 3656 const char *extra, bool non_match,
3657 reg_errcode_t *err) 3657 reg_errcode_t *err)
3658 { 3658 {
3659 re_bitset_ptr_t sbcset; 3659 re_bitset_ptr_t sbcset;
3660 #ifdef RE_ENABLE_I18N 3660 #ifdef RE_ENABLE_I18N
3661 re_charset_t *mbcset; 3661 re_charset_t *mbcset;