X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Ftypes%2Fcpp_exp.c;h=6f0fff04d74c748e6f1d08c80f7795e226c9d867;hb=c0873cbbe9e5a83305adbc2bbd94aede5437f33d;hp=2371ae25f1047fabd6f260b97de3e522688ebc49;hpb=ba906e039ffe9e57842ce5135aa43efa00b8a4c6;p=m6w6%2Fext-psi diff --git a/src/types/cpp_exp.c b/src/types/cpp_exp.c index 2371ae2..6f0fff0 100644 --- a/src/types/cpp_exp.c +++ b/src/types/cpp_exp.c @@ -54,7 +54,7 @@ struct psi_cpp_exp *psi_cpp_exp_init(token_t type, void *data) break; case PSI_T_ENDIF: case PSI_T_ELSE: - case PSI_T_ONCE: + case PSI_T_PRAGMA_ONCE: break; default: assert(0); @@ -73,18 +73,13 @@ void psi_cpp_exp_free(struct psi_cpp_exp **exp_ptr) switch (exp->type) { case PSI_T_WARNING: case PSI_T_ERROR: - if (!exp->data.tok) { - break; - } - /* no break */ case PSI_T_UNDEF: case PSI_T_IFDEF: case PSI_T_IFNDEF: case PSI_T_IMPORT: case PSI_T_INCLUDE: case PSI_T_INCLUDE_NEXT: - free(exp->data.tok); - exp->data.tok = NULL; + psi_token_free(&exp->data.tok); break; case PSI_T_DEFINE: psi_cpp_macro_decl_free(&exp->data.decl); @@ -95,22 +90,20 @@ void psi_cpp_exp_free(struct psi_cpp_exp **exp_ptr) break; case PSI_T_ENDIF: case PSI_T_ELSE: - case PSI_T_ONCE: + case PSI_T_PRAGMA_ONCE: break; default: assert(0); break; } - if (exp->token) { - free(exp->token); - } + psi_token_free(&exp->token); free(exp); } } void psi_cpp_exp_dump(int fd, struct psi_cpp_exp *exp) { - dprintf(fd, "#%s ", exp->token->text); + dprintf(fd, "#%s ", exp->token->text->val); switch (exp->type) { case PSI_T_WARNING: case PSI_T_ERROR: @@ -121,10 +114,16 @@ void psi_cpp_exp_dump(int fd, struct psi_cpp_exp *exp) case PSI_T_UNDEF: case PSI_T_IFDEF: case PSI_T_IFNDEF: + dprintf(fd, "%s", exp->data.tok->text->val); + break; case PSI_T_IMPORT: case PSI_T_INCLUDE: case PSI_T_INCLUDE_NEXT: - dprintf(fd, "%s", exp->data.tok->text); + if (exp->data.tok->type == PSI_T_CPP_HEADER) { + dprintf(fd, "<%s>", exp->data.tok->text->val); + } else { + dprintf(fd, "\"%s\"", exp->data.tok->text->val); + } break; case PSI_T_DEFINE: psi_cpp_macro_decl_dump(fd, exp->data.decl); @@ -135,7 +134,7 @@ void psi_cpp_exp_dump(int fd, struct psi_cpp_exp *exp) break; case PSI_T_ENDIF: case PSI_T_ELSE: - case PSI_T_ONCE: + case PSI_T_PRAGMA_ONCE: break; default: assert(0); @@ -182,9 +181,11 @@ static inline void psi_cpp_level_unmask(struct psi_cpp *cpp) void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_data *D) { PSI_DEBUG_PRINT(D, "PSI: CPP EVAL < %s (level=%u, skip=%u)\n", - exp->token->text, cpp->level, cpp->skip); + 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); #endif @@ -192,13 +193,13 @@ void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d case PSI_T_ERROR: if (!cpp->skip) { D->error(D, exp->token, PSI_ERROR, "%s", - exp->data.tok ? exp->data.tok->text : ""); + exp->data.tok ? exp->data.tok->text->val : ""); } break; case PSI_T_WARNING: if (!cpp->skip) { D->error(D, exp->token, PSI_WARNING, "%s", - exp->data.tok ? exp->data.tok->text : ""); + exp->data.tok ? exp->data.tok->text->val : ""); } break; case PSI_T_UNDEF: @@ -296,27 +297,28 @@ void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d break; case PSI_T_INCLUDE: if (!cpp->skip) { - if (!psi_cpp_include(cpp, exp->data.tok->text, PSI_CPP_INCLUDE)) { - D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text); + 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); } } break; case PSI_T_INCLUDE_NEXT: if (!cpp->skip) { - if (!psi_cpp_include(cpp, exp->data.tok->text, PSI_CPP_INCLUDE_NEXT)) { - D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text); + 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); } } break; case PSI_T_IMPORT: if (!cpp->skip) { - if (!psi_cpp_include(cpp, exp->data.tok->text, PSI_CPP_INCLUDE_ONCE)) { - D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text); + 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); } } - case PSI_T_ONCE: + break; + case PSI_T_PRAGMA_ONCE: if (!cpp->skip) { - zend_hash_str_add_empty_element(&cpp->once, exp->token->file, strlen(exp->token->file)); + zend_hash_add_empty_element(&cpp->once, exp->token->file); } break; default: @@ -325,5 +327,5 @@ void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d } PSI_DEBUG_PRINT(D, "PSI: CPP EVAL > %s (level=%u, skip=%u)\n", - exp->token->text, cpp->level, cpp->skip); + exp->token->text->val, cpp->level, cpp->skip); }