Skip to content

Commit

Permalink
Whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
katef committed May 30, 2024
1 parent 49ea1aa commit 5592b40
Showing 1 changed file with 42 additions and 27 deletions.
69 changes: 42 additions & 27 deletions src/libre/re.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,41 +123,56 @@ re_parse(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque,

/* Do a complete pass over the AST, filling in other details. */
res = ast_analysis(ast, flags);

if (res < 0) {
ast_free(ast);
if (err != NULL) {
if (res == AST_ANALYSIS_ERROR_UNSUPPORTED) {
err->e = RE_EUNSUPPORTED;

/*
* We can't tag AST nodes with re_pos, because it's
* also possible to construct an AST from an .fsm file.
* We detect RE_EUNSUPPORTED from annotations (e.g. nullable)
* on arbitary nodes. So at best we could tag an expr.
* But since in general we'd need to fabricate a pos anyway,
* I'm blaming the entire expression here.
*/
err->start.byte = 0;
err->end.byte = end.byte;
} else if (res == AST_ANALYSIS_ERROR_MEMORY) {
/* This case comes up during fuzzing. */
if (err->e == RE_ESUCCESS) {
err->e = RE_EERRNO;
errno = ENOMEM;
}
} else if (err->e == RE_ESUCCESS) {
err->e = RE_EERRNO;
}
}
return NULL;
goto error;
}

if (unsatisfiable != NULL) {
*unsatisfiable = (res == AST_ANALYSIS_UNSATISFIABLE);
}

return ast;

error:

ast_free(ast);

if (err == NULL) {
return NULL;
}

switch (res) {
case AST_ANALYSIS_ERROR_MEMORY:
/* This case comes up during fuzzing. */
if (err->e == RE_ESUCCESS) {
err->e = RE_EERRNO;
errno = ENOMEM;
}
break;

case AST_ANALYSIS_ERROR_UNSUPPORTED:
err->e = RE_EUNSUPPORTED;

/*
* We can't tag AST nodes with re_pos, because it's
* also possible to construct an AST from an .fsm file.
* We detect RE_EUNSUPPORTED from annotations (e.g. nullable)
* on arbitary nodes. So at best we could tag an expr.
* But since in general we'd need to fabricate a pos anyway,
* I'm blaming the entire expression here.
*/
err->start.byte = 0;
err->end.byte = end.byte;
break;

default:
if (err->e == RE_ESUCCESS) {
err->e = RE_EERRNO;
}
break;
}

return NULL;
}

struct fsm *
Expand Down

0 comments on commit 5592b40

Please sign in to comment.