Skip to content

Commit

Permalink
Make #include callbacks optional.
Browse files Browse the repository at this point in the history
Now fails at runtime if we hit an #include without callbacks defined. If
we never need the callbacks, it's silly to assert they must exist.

--HG--
branch : calculator-experiment
  • Loading branch information
icculus committed Feb 8, 2010
1 parent e7818ac commit 699bb51
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mojoshader_preprocessor.c
Expand Up @@ -656,8 +656,6 @@ Preprocessor *preprocessor_start(const char *fname, const char *source,
// the preprocessor is internal-only, so we verify all these are != NULL.
assert(m != NULL);
assert(f != NULL);
assert(open_callback != NULL);
assert(close_callback != NULL);

Context *ctx = (Context *) m(sizeof (Context), d);
if (ctx == NULL)
Expand Down Expand Up @@ -837,6 +835,12 @@ static void handle_pp_include(Context *ctx)

const char *newdata = NULL;
unsigned int newbytes = 0;
if ((ctx->open_callback == NULL) || (ctx->close_callback == NULL))
{
fail(ctx, "Saw #include, but no include callbacks defined");
return;
} // if

if (!ctx->open_callback(incltype, filename, state->source_base,
&newdata, &newbytes, ctx->malloc,
ctx->free, ctx->malloc_data))
Expand Down

0 comments on commit 699bb51

Please sign in to comment.