moving ftepp_out further up, using it in ftepp_macro_call, generating output of parameter-less macros

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-11-16 20:49:37 +01:00
parent 5f287fc476
commit 6c0b4a46fe

29
ftepp.c
View file

@ -147,6 +147,16 @@ void ftepp_delete(ftepp_t *self)
mem_d(self);
}
static void ftepp_out(ftepp_t *ftepp, const char *str, bool ignore_cond)
{
if (ignore_cond ||
!vec_size(ftepp->conditions) ||
vec_last(ftepp->conditions).on)
{
printf("%s", str);
}
}
ppmacro* ftepp_macro_find(ftepp_t *ftepp, const char *name)
{
size_t i;
@ -280,7 +290,16 @@ static bool ftepp_define(ftepp_t *ftepp)
static bool ftepp_macro_call(ftepp_t *ftepp, ppmacro *macro)
{
size_t o;
ftepp_next(ftepp);
if (!macro->has_params) {
for (o = 0; o < vec_size(macro->output); ++o) {
ftepp_out(ftepp, macro->output[o]->value, false);
}
return true;
}
if (!ftepp_skipallwhite(ftepp))
return false;
return true;
@ -611,16 +630,6 @@ static bool ftepp_hash(ftepp_t *ftepp)
return true;
}
static void ftepp_out(ftepp_t *ftepp, const char *str, bool ignore_cond)
{
if (ignore_cond ||
!vec_size(ftepp->conditions) ||
vec_last(ftepp->conditions).on)
{
printf("%s", str);
}
}
static bool ftepp_preprocess(ftepp_t *ftepp)
{
ppmacro *macro;