projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
module: depend on ext/standard for more basic constants like INF/NAN
[m6w6/ext-psi]
/
src
/
module.c
diff --git
a/src/module.c
b/src/module.c
index 98b1a8d9d97a720f9ab69fe758e47f0ee8df3350..338f9451f0104981f6b616898b1d3519cba51cae 100644
(file)
--- a/
src/module.c
+++ b/
src/module.c
@@
-186,6
+186,7
@@
static PHP_FUNCTION(psi_dump)
ZEND_BEGIN_ARG_INFO_EX(ai_psi_validate, 0, 0, 1)
ZEND_ARG_INFO(0, file)
ZEND_ARG_INFO(0, flags)
ZEND_BEGIN_ARG_INFO_EX(ai_psi_validate, 0, 0, 1)
ZEND_ARG_INFO(0, file)
ZEND_ARG_INFO(0, flags)
+ ZEND_ARG_INFO(1, errcnt)
ZEND_END_ARG_INFO();
static PHP_FUNCTION(psi_validate)
{
ZEND_END_ARG_INFO();
static PHP_FUNCTION(psi_validate)
{
@@
-195,6
+196,7
@@
static PHP_FUNCTION(psi_validate)
struct psi_data D = {0};
struct psi_validate_scope S = {0};
zend_long flags = 0;
struct psi_data D = {0};
struct psi_validate_scope S = {0};
zend_long flags = 0;
+ zval *errcnt = NULL;
#if PHP_DEBUG
if (psi_check_env("PSI_DEBUG")) {
#if PHP_DEBUG
if (psi_check_env("PSI_DEBUG")) {
@@
-202,7
+204,7
@@
static PHP_FUNCTION(psi_validate)
}
#endif
}
#endif
- if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "P|l
", &file, &flags
)) {
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "P|l
z", &file, &flags, &errcnt
)) {
return;
}
return;
}
@@
-218,7
+220,15
@@
static PHP_FUNCTION(psi_validate)
psi_data_ctor(&D, P.error, P.flags);
psi_validate_scope_ctor(&S);
S.defs = &P.preproc->defs;
psi_data_ctor(&D, P.error, P.flags);
psi_validate_scope_ctor(&S);
S.defs = &P.preproc->defs;
- RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)) && !P.errors);
+
+ RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)));
+
+ if (errcnt) {
+ ZVAL_DEREF(errcnt);
+ convert_to_long(errcnt);
+ ZVAL_LONG(errcnt, P.errors);
+ }
+
psi_validate_scope_dtor(&S);
psi_data_dtor(&D);
psi_parser_dtor(&P);
psi_validate_scope_dtor(&S);
psi_data_dtor(&D);
psi_parser_dtor(&P);
@@
-227,6
+237,8
@@
static PHP_FUNCTION(psi_validate)
ZEND_BEGIN_ARG_INFO_EX(ai_psi_validate_string, 0, 0, 1)
ZEND_ARG_INFO(0, string)
ZEND_BEGIN_ARG_INFO_EX(ai_psi_validate_string, 0, 0, 1)
ZEND_ARG_INFO(0, string)
+ ZEND_ARG_INFO(0, flags)
+ ZEND_ARG_INFO(1, errcnt)
ZEND_END_ARG_INFO();
static PHP_FUNCTION(psi_validate_string)
{
ZEND_END_ARG_INFO();
static PHP_FUNCTION(psi_validate_string)
{
@@
-236,6
+248,7
@@
static PHP_FUNCTION(psi_validate_string)
struct psi_data D = {0};
struct psi_validate_scope S = {0};
zend_long flags = 0;
struct psi_data D = {0};
struct psi_validate_scope S = {0};
zend_long flags = 0;
+ zval *errcnt = NULL;
#if PHP_DEBUG
if (psi_check_env("PSI_DEBUG")) {
#if PHP_DEBUG
if (psi_check_env("PSI_DEBUG")) {
@@
-243,7
+256,7
@@
static PHP_FUNCTION(psi_validate_string)
}
#endif
}
#endif
- if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S|l
", &string, &flags
)) {
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S|l
z", &string, &flags, &errcnt
)) {
return;
}
return;
}
@@
-259,7
+272,15
@@
static PHP_FUNCTION(psi_validate_string)
psi_data_ctor(&D, P.error, P.flags);
psi_validate_scope_ctor(&S);
S.defs = &P.preproc->defs;
psi_data_ctor(&D, P.error, P.flags);
psi_validate_scope_ctor(&S);
S.defs = &P.preproc->defs;
- RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)) && !P.errors);
+
+ RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)));
+
+ if (errcnt) {
+ ZVAL_DEREF(errcnt);
+ convert_to_long(errcnt);
+ ZVAL_LONG(errcnt, P.errors);
+ }
+
psi_validate_scope_dtor(&S);
psi_data_dtor(&D);
psi_parser_dtor(&P);
psi_validate_scope_dtor(&S);
psi_data_dtor(&D);
psi_parser_dtor(&P);
@@
-457,8
+478,15
@@
static const zend_function_entry psi_functions[] = {
PHP_FE_END
};
PHP_FE_END
};
+static const zend_module_dep psi_deps[] = {
+ ZEND_MOD_REQUIRED("standard")
+ {0}
+};
+
zend_module_entry psi_module_entry = {
zend_module_entry psi_module_entry = {
- STANDARD_MODULE_HEADER,
+ STANDARD_MODULE_HEADER_EX,
+ NULL,
+ psi_deps,
"psi",
psi_functions,
PHP_MINIT(psi),
"psi",
psi_functions,
PHP_MINIT(psi),