Jérémie Courrèges-Anglas: > If no one chimes in, ok to delete it. This being said, here's a > compile-tested (and may^Wprobably incomplete) attempt to convert it to > regex(3).
> +@@ -392,7 +392,7 @@ static void build_ts(char *gi, char* cp) > + tok = Split(cp, &i, S_STRDUP); > + T.var_RE_name = tok[0]; > + ExpandVariables(tok[1], buf, 0); > +- if (!(T.var_RE_value=regcomp(buf))) { > ++ if (regcomp(&T.var_RE_value, buf, REG_BASIC|REG_NOSUB)) { > + fprintf(stderr, "Regex error in VarREValue Content: %s\n", > + tok[1]); > + } We need REG_EXTENDED. There is a subtle problem in the error case: var_RE_value will have an undefined value. However, over in translate.c, regexec() is blindly called with whatever regcomp() returned. > +@@ -415,11 +415,23 @@ FindTrans( > + if (!QRelation(e, t->parent, REL_Parent)) continue; > + > + if (t->context) { /* no context specified -> a match */ > ++ char *cp; > ++ int do_regex = 0; > ++ > ++ for (do_regex=0,cp=t->context; *cp; cp++) { > ++ if (!isalnum(*cp) && *cp != '-' && *cp != '.' && *cp != ' > ') { > ++ do_regex = 1; > ++ break; > ++ } > ++ } > ++ Ewww. > + FindContext(e, t->depth, context); > + > + /* If reg expr set, do regex compare; else just string compare. */ > +- if (t->context_re) { > +- if (! regexec(t->context_re, context)) continue; > ++ if (do_regex) { > ++ if (regexec(&t->context_re, context, 0, NULL, > ++ REG_NOTBOL|REG_NOTEOL) != 0) > ++ continue; > + } Why REG_NOTBOL|REG_NOTEOL? I don't think this matches the v8_regexec() semantics. My current thinking is to use wrappers, something along these lines: regex_t *v8regcomp(...) { regex_t *re; if (!(re = malloc(...))) return NULL; if (regcomp(re, ...)) { free(re); return NULL; } return re; } int v8regexec(regex_t re, ...) { if (!re) return 0; return !regexec(re, ...); } This would allow us to preserve (regex_t *)NULL to stand for a nonexistent/invalid regular expression. -- Christian "naddy" Weisgerber na...@mips.inka.de