expressions: Fix coercion of numbers to booleans at top level.
[pspp] / src / language / expressions / parse.c
index 32c2e6152917f721f2a50fc1d569720e8ad9386b..24380e28192f3c22274522db12db8f5d401ea32a 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -262,8 +262,9 @@ type_check (struct expression *e,
                atom_type_name (actual_type));
          return false;
        }
-      if (actual_type == OP_number && expected_type == OP_boolean)
-       *n = expr_allocate_unary (e, OP_NUM_TO_BOOLEAN, *n);
+      if (actual_type == OP_number && expected_type == EXPR_BOOLEAN)
+        *n = expr_allocate_binary (e, OP_NUM_TO_BOOLEAN, *n,
+                                   expr_allocate_string (e, ss_empty ()));
       break;
 
     case EXPR_STRING:
@@ -897,8 +898,8 @@ parse_primary (struct lexer *lexer, struct expression *e)
         dict_encoding = (e->ds != NULL
                          ? dict_get_encoding (dataset_dict (e->ds))
                          : "UTF-8");
-        s = recode_string (dict_encoding, "UTF-8", lex_tokcstr (lexer),
-                           ss_length (lex_tokss (lexer)));
+        s = recode_string_pool (dict_encoding, "UTF-8", lex_tokcstr (lexer),
+                           ss_length (lex_tokss (lexer)), e->expr_pool);
         node = expr_allocate_string (e, ss_cstr (s));
 
        lex_get (lexer);
@@ -1268,7 +1269,7 @@ parse_function (struct lexer *lexer, struct expression *e)
           break;
         else if (!lex_match (lexer, T_COMMA))
           {
-            lex_error_expecting (lexer, ",", ")", NULL_SENTINEL);
+            lex_error_expecting (lexer, "`,'", "`)'", NULL_SENTINEL);
             goto fail;
           }
       }