// -*- c -*-
//
// PSPP - a program for statistical analysis.
-// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 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
{
if (x == 0. || x == 1. || x == SYSMIS)
return x;
+
+ if (!ss_is_empty (op_name))
+ msg (SE, _("An operand of the %.*s operator was found to have a value "
+ "other than 0 (false), 1 (true), or the system-missing "
+ "value. The result was forced to 0."),
+ (int) op_name.length, op_name.string);
else
- {
- msg (SE, _("An operand of the %.*s operator was found to have a value "
- "other than 0 (false), 1 (true), or the system-missing "
- "value. The result was forced to 0."),
- (int) op_name.length, op_name.string);
- return 0.;
- }
+ msg (SE, _("A logical expression was found to have a value other than 0 "
+ "(false), 1 (true), or the system-missing value. The result "
+ "was forced to 0."));
+ return 0.;
}
operator BOOLEAN_TO_NUM (boolean x) = x;
/* 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
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:
parse.sps:11: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
])
AT_CLEANUP
+
+AT_SETUP([parse expression with invalid logical expression])
+AT_DATA([parse.sps], [dnl
+INPUT PROGRAM.
+LOOP c=1 to 10.
+COMPUTE var1=NORMAL(100).
+END CASE.
+END LOOP.
+END FILE.
+END INPUT PROGRAM.
+
+SELECT IF 2.
+])
+AT_CHECK([pspp -O format=csv parse.sps], [1], [dnl
+"parse.sps:9: error: SELECT IF: A logical expression was found to have a value other than 0 (false), 1 (true), or the system-missing value. The result was forced to 0."
+])
+AT_CLEANUP