tests: fix skipif \!utsname.domainname
[m6w6/ext-psi] / src / calc.c
index efea9003af7093b5f867420afd9557be905bb953..0e21ec59bf041e15b343a865beb7421c04da4dcc 100644 (file)
@@ -1,9 +1,12 @@
 #ifdef HAVE_CONFIG_H
 # include "config.h"
+#else
+# include "php_config.h"
 #endif
 
 #include "php.h"
 #include "php_psi.h"
+#include "parser.h"
 #include "calc.h"
 
 static inline int psi_calc_num_exp_value(num_exp *exp, impl_val *strct, impl_val *res) {
@@ -39,10 +42,8 @@ static inline int psi_calc_num_exp_value(num_exp *exp, impl_val *strct, impl_val
        case PSI_T_NAME:
                if (strct) {
                        ref = struct_member_ref(exp->u.dvar->arg, strct, &tmp);
-               } else if (exp->u.dvar->arg->let) {
-                       ref = exp->u.dvar->arg->let->ptr;
                } else {
-                       ref = exp->u.dvar->arg->ptr;
+                       ref = exp->u.dvar->arg->let;
                }
                switch (real_decl_type(exp->u.dvar->arg->type)->type) {
                case PSI_T_INT8:
@@ -98,12 +99,12 @@ int psi_calc_num_exp(num_exp *exp, impl_val *strct, impl_val *res) {
 #define PSI_CALC_OP(var) do { \
        const char *fmt = "calc %" PRI##var ", %" PRI##var ": %" PRI##var "\n"; \
        res->var = PSI_CALC(v1->var, v2->var); \
-       if (!res->var) fprintf(stderr, fmt, v1->var, v2->var, res->var); \
+       if (!res->var && (v1->var || v2->var)) fprintf(stderr, fmt, v1->var, v2->var, res->var); \
 } while (0)
 #define PSI_CALC_OP2(vres, var1, var2) do { \
        const char *fmt = "calc %" PRI##var1 ", %" PRI##var2 ": %" PRI##vres "\n"; \
        res->vres = PSI_CALC(v1->var1, v2->var2); \
-       if (!res->vres) fprintf(stderr, fmt, v1->var1, v2->var2, res->vres); \
+       if (!res->vres && (v1->var1 || v2->var2)) fprintf(stderr, fmt, v1->var1, v2->var2, res->vres); \
 } while(0)
 
 #ifdef HAVE_LONG_DOUBLE