Minor fixes of lwre
@@ -689,7 +689,7 @@ void re_release(struct re *re)
{
if (re->matches) RE_FREE(re, re->matches);
if (re->code.first) re_program_free(re, &re->code);
- memset(re, 0, sizeof(re));
+ memset(re, 0, sizeof(*re));
}
void re_reset(struct re *re, char *expression)
@@ -708,11 +708,14 @@ void re_free(struct re *re)
static int re_digit(int c, int base)
{
- switch (c) {
- case '0'...'9': c -= '0'; break;
- case 'A'...'Z': c -= ('A' - 10); break;
- case 'a'...'z': c -= ('a' - 10); break;
- default: return -1;
+ if (c >= '0' && c <= '9') {
+ c -= '0';
+ } else if (c >= 'A' && c <= 'Z') {
+ c -= ('A' - 10);
+ } else if (c >= 'a' && c <= 'z') {
+ c -= ('a' - 10);
+ } else {
+ return -1;
}
if (c >= base) return -1;
return c;
