basic support for builtins
[m6w6/ext-psi] / src / types / cpp_exp.c
index 6f0fff04d74c748e6f1d08c80f7795e226c9d867..bfff0d197d443a8a2a6c721b6bd4868b5524f1b3 100644 (file)
@@ -32,7 +32,7 @@
 
 struct psi_cpp_exp *psi_cpp_exp_init(token_t type, void *data)
 {
-       struct psi_cpp_exp *exp = calloc(1, sizeof(*exp));
+       struct psi_cpp_exp *exp = pecalloc(1, sizeof(*exp), 1);
 
        switch ((exp->type = type)) {
        case PSI_T_WARNING:
@@ -184,9 +184,8 @@ void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d
                        exp->token->text->val, cpp->level, cpp->skip);
 
 #if PSI_CPP_DEBUG
-       fflush(stderr);
-       dprintf(2, "PSI: CPP exec -> ");
-       psi_cpp_exp_dump(2, exp);
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP exec -> ");
+       PSI_DEBUG_DUMP(cpp->parser, psi_cpp_exp_dump, exp);
 #endif
 
        switch (exp->type) {
@@ -298,21 +297,24 @@ void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d
        case PSI_T_INCLUDE:
                if (!cpp->skip) {
                        if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE)) {
-                               D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
+                               D->error(D, exp->token, PSI_WARNING, "Failed to include %s: %s",
+                                               exp->data.tok->text->val, strerror(errno));
                        }
                }
                break;
        case PSI_T_INCLUDE_NEXT:
                if (!cpp->skip) {
                        if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE_NEXT)) {
-                               D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
+                               D->error(D, exp->token, PSI_WARNING, "Failed to include next %s: %s",
+                                               exp->data.tok->text->val, strerror(errno));
                        }
                }
                break;
        case PSI_T_IMPORT:
                if (!cpp->skip) {
                        if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE_ONCE)) {
-                               D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
+                               D->error(D, exp->token, PSI_WARNING, "Failed to include once %s: %s",
+                                               exp->data.tok->text->val, strerror(errno));
                        }
                }
                break;