X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fexpressions%2Fevaluate.c;h=dea521a8fa25554638644866a915c5804720c937;hb=3bbb4370239deb29ebbf813d258aef6249e2a431;hp=ec12452a18788a7ac85bc39166c518323b10a821;hpb=f5c108becd49d78f4898cab11352291f5689d24e;p=pspp-builds.git
diff --git a/src/language/expressions/evaluate.c b/src/language/expressions/evaluate.c
index ec12452a..dea521a8 100644
--- a/src/language/expressions/evaluate.c
+++ b/src/language/expressions/evaluate.c
@@ -1,32 +1,32 @@
-/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc.
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 1997-9, 2000, 2006, 2007, 2009 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 the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ along with this program. If not, see . */
#include
-#include "private.h"
+#include "evaluate.h"
#include
-#include
#include
#include
-#include "helpers.h"
-#include "evaluate.h"
+#include
+#include
+#include
#include
+#include "xalloc.h"
+
static void
expr_evaluate (struct expression *e, const struct ccase *c, int case_idx,
void *result)
@@ -64,7 +64,7 @@ expr_evaluate (struct expression *e, const struct ccase *c, int case_idx,
break;
case OP_return_number:
- *(double *) result = finite (ns[-1]) ? ns[-1] : SYSMIS;
+ *(double *) result = isfinite (ns[-1]) ? ns[-1] : SYSMIS;
return;
case OP_return_string:
@@ -99,7 +99,7 @@ expr_evaluate_str (struct expression *e, const struct ccase *c, int case_idx,
assert ((dst == NULL) == (dst_size == 0));
expr_evaluate (e, c, case_idx, &s);
- buf_copy_rpad (dst, dst_size, s.string, s.length);
+ buf_copy_rpad (dst, dst_size, s.string, s.length, ' ');
}
#include
@@ -127,7 +127,7 @@ cmd_debug_evaluate (struct lexer *lexer, struct dataset *dsother UNUSED)
dump_postfix = 1;
else if (lex_match (lexer, '('))
{
- char name[LONG_NAME_LEN + 1];
+ char name[VAR_NAME_LEN + 1];
struct variable *v;
size_t old_value_cnt;
int width;
@@ -158,7 +158,7 @@ cmd_debug_evaluate (struct lexer *lexer, struct dataset *dsother UNUSED)
if ( ds == NULL )
{
- ds = create_dataset (NULL, NULL);
+ ds = create_dataset ();
d = dataset_dict (ds);
}
@@ -171,19 +171,12 @@ cmd_debug_evaluate (struct lexer *lexer, struct dataset *dsother UNUSED)
}
if (c == NULL)
- {
- c = xmalloc (sizeof *c);
- case_create (c, dict_get_next_value_idx (d));
- }
+ c = case_create (dict_get_proto (d));
else
- case_resize (c, dict_get_next_value_idx (d));
+ c = case_unshare_and_resize (c, dict_get_proto (d));
- if (lex_is_number (lexer))
- case_data_rw (c, v)->f = lex_tokval (lexer);
- else
- memcpy (case_data_rw (c, v)->s, ds_data (lex_tokstr (lexer)),
- var_get_width (v));
- lex_get (lexer);
+ if (!parse_value (lexer, case_data_rw (c, v), var_get_width (v)))
+ NOT_REACHED ();
if (!lex_force_match (lexer, ')'))
goto done;
@@ -256,11 +249,7 @@ cmd_debug_evaluate (struct lexer *lexer, struct dataset *dsother UNUSED)
if (ds)
destroy_dataset (ds);
- if (c != NULL)
- {
- case_destroy (c);
- free (c);
- }
+ case_unref (c);
return retval;
}