X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fcontext.c;h=161534e9f8aa03a180fc0866dec74d03e8bb7aba;hb=764f3f36f003401f6334ced63356451fb5c6c642;hp=f10f4c49e76e288c38c3c1384c99939231750a33;hpb=91f2f40eee4e1d1dd62ad5de06517f9b27b4aaee;p=m6w6%2Fext-psi diff --git a/src/context.c b/src/context.c index f10f4c4..161534e 100644 --- a/src/context.c +++ b/src/context.c @@ -240,6 +240,7 @@ void psi_context_build(struct psi_context *C, const char *paths) for (i = 0; i < n; ++i) { char psi[MAXPATHLEN]; struct psi_parser P; + struct psi_parser_input *I; if (MAXPATHLEN <= slprintf(psi, MAXPATHLEN, "%s/%s", ptr, entries[i]->d_name)) { C->error(PSI_DATA(C), NULL, PSI_WARNING, "Path to PSI file too long: %s/%s", @@ -250,22 +251,15 @@ void psi_context_build(struct psi_context *C, const char *paths) psi, strerror(errno)); continue; } - if (!psi_parser_open_file(&P, psi)) { + if (!(I = psi_parser_open_file(&P, psi, true))) { C->error(PSI_DATA(C), NULL, PSI_WARNING, "Failed to open PSI file (%s): %s", psi, strerror(errno)); continue; } - - while (0 < psi_parser_scan(&P)) { - psi_parser_parse(&P, psi_token_alloc(&P)); - if (P.num == PSI_T_EOF) { - break; - } - } - - psi_parser_parse(&P, NULL); + psi_parser_parse(&P, I); psi_context_add_data(C, PSI_DATA(&P)); psi_parser_dtor(&P); + free(I); } } @@ -341,7 +335,7 @@ zend_function_entry *psi_context_compile(struct psi_context *C) zend_string *name = strpprintf(0, "psi\\%s\\%s", e->name, item->name); zc.name = zend_string_dup(name, 1); - ZVAL_LONG(&zc.value, psi_long_num_exp(item->num, NULL)); + ZVAL_LONG(&zc.value, psi_long_num_exp(item->num, NULL, NULL)); zend_register_constant(&zc); zend_string_release(name); } @@ -373,7 +367,22 @@ ZEND_RESULT_CODE psi_context_call(struct psi_context *C, zend_execute_data *exec return FAILURE; } + if (SUCCESS != psi_call_frame_do_assert(frame, PSI_ASSERT_PRE)) { + psi_call_frame_do_return(frame, return_value); + psi_call_frame_free(frame); + + return FAILURE; + } + psi_call_frame_do_call(frame); + + if (SUCCESS != psi_call_frame_do_assert(frame, PSI_ASSERT_POST)) { + psi_call_frame_do_return(frame, return_value); + psi_call_frame_free(frame); + + return FAILURE; + } + psi_call_frame_do_return(frame, return_value); psi_call_frame_do_set(frame); psi_call_frame_do_free(frame);