X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Ftypes%2Fcpp_exp.c;h=68fec6ec48d3138a21ee131650580e6b1854a67c;hb=HEAD;hp=bfff0d197d443a8a2a6c721b6bd4868b5524f1b3;hpb=a7ac1c0a3c855321f21682c127a4b707de33a303;p=m6w6%2Fext-psi diff --git a/src/types/cpp_exp.c b/src/types/cpp_exp.c index bfff0d1..68fec6e 100644 --- a/src/types/cpp_exp.c +++ b/src/types/cpp_exp.c @@ -23,12 +23,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ -#include "php_psi_stdinc.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#else +# include "php_config.h" +#endif #include #include "data.h" #include "cpp.h" +#include "debug.h" struct psi_cpp_exp *psi_cpp_exp_init(token_t type, void *data) { @@ -46,6 +51,7 @@ struct psi_cpp_exp *psi_cpp_exp_init(token_t type, void *data) exp->data.tok = data; break; case PSI_T_DEFINE: + case PSI_T_PRAGMA: exp->data.decl = data; break; case PSI_T_IF: @@ -54,7 +60,6 @@ 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_PRAGMA_ONCE: break; default: assert(0); @@ -82,6 +87,7 @@ void psi_cpp_exp_free(struct psi_cpp_exp **exp_ptr) psi_token_free(&exp->data.tok); break; case PSI_T_DEFINE: + case PSI_T_PRAGMA: psi_cpp_macro_decl_free(&exp->data.decl); break; case PSI_T_IF: @@ -90,7 +96,6 @@ void psi_cpp_exp_free(struct psi_cpp_exp **exp_ptr) break; case PSI_T_ENDIF: case PSI_T_ELSE: - case PSI_T_PRAGMA_ONCE: break; default: assert(0); @@ -101,9 +106,9 @@ void psi_cpp_exp_free(struct psi_cpp_exp **exp_ptr) } } -void psi_cpp_exp_dump(int fd, struct psi_cpp_exp *exp) +void psi_cpp_exp_dump(struct psi_dump *dump, struct psi_cpp_exp *exp) { - dprintf(fd, "#%s ", exp->token->text->val); + PSI_DUMP(dump, "#%s ", exp->token->text->val); switch (exp->type) { case PSI_T_WARNING: case PSI_T_ERROR: @@ -114,33 +119,33 @@ 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); + PSI_DUMP(dump, "%s", exp->data.tok->text->val); break; case PSI_T_IMPORT: case PSI_T_INCLUDE: case PSI_T_INCLUDE_NEXT: if (exp->data.tok->type == PSI_T_CPP_HEADER) { - dprintf(fd, "<%s>", exp->data.tok->text->val); + PSI_DUMP(dump, "<%s>", exp->data.tok->text->val); } else { - dprintf(fd, "\"%s\"", exp->data.tok->text->val); + PSI_DUMP(dump, "\"%s\"", exp->data.tok->text->val); } break; case PSI_T_DEFINE: - psi_cpp_macro_decl_dump(fd, exp->data.decl); + case PSI_T_PRAGMA: + psi_cpp_macro_decl_dump(dump, exp->data.decl); break; case PSI_T_IF: case PSI_T_ELIF: - psi_num_exp_dump(fd, exp->data.num); + psi_num_exp_dump(dump, exp->data.num); break; case PSI_T_ENDIF: case PSI_T_ELSE: - case PSI_T_PRAGMA_ONCE: break; default: assert(0); break; } - dprintf(fd, "\n"); + PSI_DUMP(dump, "\n"); } @@ -213,6 +218,11 @@ void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d exp->data.decl = NULL; } break; + case PSI_T_PRAGMA: + if (!cpp->skip) { + psi_cpp_pragma(cpp, exp->data.decl); + } + break; case PSI_T_IFDEF: ++cpp->level; if (!cpp->skip) { @@ -318,11 +328,6 @@ void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d } } break; - case PSI_T_PRAGMA_ONCE: - if (!cpp->skip) { - zend_hash_add_empty_element(&cpp->once, exp->token->file); - } - break; default: assert(0); break;