1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2025-04-21 12:27:27 +03:00

b2/: add regular expression conversion debugging (option -R)

This commit is contained in:
Werner Almesberger
2012-06-03 10:10:47 -03:00
parent 12b21f032c
commit da1010f92a
4 changed files with 22 additions and 4 deletions

View File

@@ -113,7 +113,7 @@ static char *prepare_re(const char *re, char *units)
}
struct subst *subst_match(const char *src, const char *re)
struct subst *subst_match(const char *src, const char *re, char **res)
{
char error[1000];
struct subst *sub;
@@ -124,7 +124,10 @@ struct subst *subst_match(const char *src, const char *re)
sub->u.match.src = src;
tmp = prepare_re(re, sub->u.match.units);
err = regcomp(&sub->u.match.re, tmp, REG_EXTENDED);
free(tmp);
if (res)
*res = tmp;
else
free(tmp);
if (err) {
regerror(err, &sub->u.match.re, error, sizeof(error));
yyerrorf("%s", error);