expression is checked for well-formedness and collected until the next ']'
*/
struct URLPattern *pat;
- int rc;
char *pattern = *patternp;
char *c;
if(ISALPHA(*pattern)) {
/* character range detected */
- char min_c;
- char max_c;
- char end_c;
+ bool pmatch = FALSE;
+ char min_c = 0;
+ char max_c = 0;
+ char end_c = 0;
unsigned long step = 1;
pat->type = UPTCharRange;
- rc = sscanf(pattern, "%c-%c%c", &min_c, &max_c, &end_c);
+ if((pattern[1] == '-') && pattern[2] && pattern[3]) {
+ min_c = pattern[0];
+ max_c = pattern[2];
+ end_c = pattern[3];
+ pmatch = TRUE;
- if(rc == 3) {
if(end_c == ':') {
char *endp;
errno = 0;
}
else if(end_c != ']')
/* then this is wrong */
- rc = 0;
+ pmatch = FALSE;
else
/* end_c == ']' */
pattern += 4;
*posp += (pattern - *patternp);
- if(rc != 3 || !step || step > (unsigned)INT_MAX ||
+ if(!pmatch || !step || step > (unsigned)INT_MAX ||
(min_c == max_c && step != 1) ||
(min_c != max_c && (min_c > max_c || step > (unsigned)(max_c - min_c) ||
(max_c - min_c) > ('z' - 'a'))))