char *includename;
} ftepp_t;
-typedef struct {
- const char *name;
- char *(*func)(lex_file *);
-} predef_t;
-
/*
* Implement the predef subsystem now. We can do this safely with the
* help of lexer contexts.
return value;
}
-static const predef_t ftepp_predefs[] = {
+const ftepp_predef_t ftepp_predefs[FTEPP_PREDEF_COUNT] = {
{ "__LINE__", &ftepp_predef_line },
{ "__FILE__", &ftepp_predef_file },
{ "__COUNTER__", &ftepp_predef_counter },
/*===================================================================*/
/*====================== ftepp.c commandline ========================*/
/*===================================================================*/
+struct lex_file_s;
+typedef struct {
+ const char *name;
+ char *(*func)(struct lex_file_s *);
+} ftepp_predef_t;
+
+/*
+ * line, file, counter, counter_last, random, random_last, date, time
+ * increment when items are added
+ */
+#define FTEPP_PREDEF_COUNT 8
+
bool ftepp_init ();
bool ftepp_preprocess_file (const char *filename);
bool ftepp_preprocess_string(const char *name, const char *str);
void ftepp_add_define (const char *source, const char *name);
void ftepp_add_macro (const char *name, const char *value);
+extern const ftepp_predef_t ftepp_predefs[FTEPP_PREDEF_COUNT];
+
/*===================================================================*/
/*======================= main.c commandline ========================*/
/*===================================================================*/
int value;
} frame_macro;
-typedef struct {
+typedef struct lex_file_s {
FILE *file;
const char *open_string;
size_t open_string_length;
}
else
{
+ /*
+ * sometimes people use preprocessing predefs without enabling them
+ * i've done this thousands of times already myself. Lets check for
+ * it in the predef table. And diagnose it better :)
+ */
+ if (!OPTS_FLAG(FTEPP_PREDEFS)) {
+ size_t i;
+ for (i = 0; i < sizeof(ftepp_predefs)/sizeof(*ftepp_predefs); i++) {
+ if (!strcmp(ftepp_predefs[i].name, parser_tokval(parser))) {
+ parseerror(parser, "unexpected ident: %s (use -fftepp-predef to enable pre-defined macros)", parser_tokval(parser));
+ goto onerr;
+ }
+ }
+ }
+
parseerror(parser, "unexpected ident: %s", parser_tokval(parser));
goto onerr;
}