travis: update
[m6w6/ext-psi] / src / types / num_exp.c
index 9388ad3dcc2d12d4365cf9575951c0bb5b94ce79..7d168c1a9782569cf80512ab397eaf712f5c4850 100644 (file)
  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 <assert.h>
 
@@ -31,6 +35,7 @@
 #include "context.h"
 #include "call.h"
 #include "calc.h"
+#include "debug.h"
 
 struct psi_num_exp *psi_num_exp_init_ternary(token_t op,
                struct psi_num_exp *cond, struct psi_num_exp *truthy,
@@ -369,7 +374,6 @@ struct psi_plist *psi_num_exp_tokens(struct psi_num_exp *exp,
                psi_plist_top(list, &ntoken);
                ntoken = psi_token_init(PSI_T_COLON, ":", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
                list = psi_plist_add(list, &ntoken);
-               list = psi_plist_add(list, &ntoken);
                list = psi_num_exp_tokens(exp->data.t.falsy, list);
                break;
 
@@ -391,6 +395,7 @@ void psi_num_exp_dump(struct psi_dump *dump, struct psi_num_exp *exp)
                PSI_DUMP(dump, "(");
                psi_decl_type_dump(dump, exp->data.c.typ, 0);
                PSI_DUMP(dump, ")");
+               psi_num_exp_dump(dump, exp->data.c.num);
                break;
 
        case PSI_T_NOT:
@@ -535,7 +540,19 @@ bool psi_num_exp_validate(struct psi_data *data, struct psi_num_exp *exp,
 
        switch (exp->op) {
        case PSI_T_NUMBER:
-               return psi_number_validate(data, exp->data.n, scope);
+               if (!psi_number_validate(data, exp->data.n, scope)) {
+                       smart_str str = {0};
+                       struct psi_dump dump = {{.hn = &str},
+                                       .fun = (psi_dump_cb) psi_smart_str_printf};
+
+                       psi_num_exp_dump(&dump, exp);
+                       smart_str_0(&str);
+                       data->error(data, exp->token, PSI_WARNING,
+                                       "Invalid numeric expression: '%s'",
+                                       str.s->val);
+                       return false;
+               }
+               return true;
 
        case PSI_T_CAST:
                return psi_num_exp_validate(data, exp->data.c.num, scope)