boolean operator NE (a, b) = a != b;
// String relational operators.
-boolean operator EQ_STRING (string a, string b) = compare_string (&a, &b) == 0;
-boolean operator GE_STRING (string a, string b) = compare_string (&a, &b) >= 0;
-boolean operator GT_STRING (string a, string b) = compare_string (&a, &b) > 0;
-boolean operator LE_STRING (string a, string b) = compare_string (&a, &b) <= 0;
-boolean operator LT_STRING (string a, string b) = compare_string (&a, &b) < 0;
-boolean operator NE_STRING (string a, string b) = compare_string (&a, &b) != 0;
+boolean operator EQ_STRING (string a, string b) = compare_string_3way (&a, &b) == 0;
+boolean operator GE_STRING (string a, string b) = compare_string_3way (&a, &b) >= 0;
+boolean operator GT_STRING (string a, string b) = compare_string_3way (&a, &b) > 0;
+boolean operator LE_STRING (string a, string b) = compare_string_3way (&a, &b) <= 0;
+boolean operator LT_STRING (string a, string b) = compare_string_3way (&a, &b) < 0;
+boolean operator NE_STRING (string a, string b) = compare_string_3way (&a, &b) != 0;
// Unary functions.
function ABS (x) = fabs (x);
size_t i;
for (i = 0; i < n; i++)
- if (!compare_string (&x, &a[i]))
+ if (!compare_string_3way (&x, &a[i]))
return 1.;
return 0.;
}
max = &a[0];
for (i = 1; i < n; i++)
- if (compare_string (&a[i], max) > 0)
+ if (compare_string_3way (&a[i], max) > 0)
max = &a[i];
return *max;
}
min = &a[0];
for (i = 1; i < n; i++)
- if (compare_string (&a[i], min) < 0)
+ if (compare_string_3way (&a[i], min) < 0)
min = &a[i];
return *min;
}
{
struct substring *w = &a[2 * i];
struct substring *y = &a[2 * i + 1];
- if (compare_string (w, &x) <= 0 && compare_string (&x, y) <= 0)
+ if (compare_string_3way (w, &x) <= 0 && compare_string_3way (&x, y) <= 0)
return 1.;
}
return 0.;
function NUMBER (string s, ni_format f)
{
union value out;
- data_in (ss_head (s, f->w), LEGACY_NATIVE, f->type, f->d, 0, 0, NULL, &out, 0);
+ char *error;
+
+ if (s.length > f->w)
+ s.length = f->w;
+ error = data_in (s, LEGACY_NATIVE, f->type, &out, 0, NULL);
+ if (error == NULL)
+ data_in_imply_decimals (s, LEGACY_NATIVE, f->type, f->d, &out);
+ else
+ {
+ msg (SE, "Cannot parse \"%.*s\" as format %s: %s",
+ (int) s.length, s.string, fmt_name (f->type), error);
+ free (error);
+ }
return out.f;
}
if (idx >= 1 && idx <= vector_get_var_cnt (v))
{
struct variable *var = vector_get_var (v, (size_t) idx - 1);
- return copy_string (e, case_str (c, var), var_get_width (var));
+ return copy_string (e, CHAR_CAST_BUG (char *, case_str (c, var)),
+ var_get_width (var));
}
else
{
{
const struct ccase *c = lagged_case (ds, n_before);
if (c != NULL)
- return copy_string (e, case_str (c, v), var_get_width (v));
+ return copy_string (e, CHAR_CAST_BUG (char *, case_str (c, v)),
+ var_get_width (v));
else
return empty_string;
}
{
const struct ccase *c = lagged_case (ds, 1);
if (c != NULL)
- return copy_string (e, case_str (c, v), var_get_width (v));
+ return copy_string (e, CHAR_CAST_BUG (char *, case_str (c, v)),
+ var_get_width (v));
else
return empty_string;
}