char *ftepp_predef_file(lex_file *context) {
size_t length = strlen(context->name) + 3; /* two quotes and a terminator */
char *value = (char*)mem_a(length);
- memset (value, 0, length);
sprintf(value, "\"%s\"", context->name);
return value;
ftepp->token = old;
}
}
- else
- {
+ else if (macro->variadic && !strcmp(ftepp_tokval(ftepp), "__VA_COUNT__")) {
+ ftepp->token = TOKEN_VA_COUNT;
+ ptok = pptoken_make(ftepp);
+ vec_push(macro->output, ptok);
+ ftepp_next(ftepp);
+ } else {
ptok = pptoken_make(ftepp);
vec_push(macro->output, ptok);
ftepp_next(ftepp);
static bool ftepp_preprocess(ftepp_t *ftepp);
static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params, bool resetline)
{
+ char *buffer = NULL;
char *old_string = ftepp->output_string;
char *inner_string;
lex_file *old_lexer = ftepp->lex;
ftepp_param_out(ftepp, ¶ms[out->constval.i + vararg_start]);
break;
+ case TOKEN_VA_COUNT:
+ util_asprintf(&buffer, "%d", varargs);
+ ftepp_out(ftepp, buffer, false);
+ mem_d(buffer);
+ break;
+
case TOKEN_IDENT:
case TOKEN_TYPENAME:
case TOKEN_KEYWORD:
memcpy(vec_add(filename, len+1), file, len);
vec_last(filename) = 0;
- fp = file_open(filename, "rb");
+ fp = fs_file_open(filename, "rb");
if (fp) {
- file_close(fp);
+ fs_file_close(fp);
return filename;
}
vec_free(filename);