-/* PSPP - computes sample statistics.
+/* PSPP - a program for statistical analysis.
Copyright (C) 1997-9, 2000 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 <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <language/dictionary/split-file.h>
#include <language/lexer/lexer.h>
#include <language/lexer/variable-parser.h>
-#include <libpspp/alloc.h>
#include <libpspp/array.h>
#include <libpspp/compiler.h>
-#include <libpspp/magic.h>
#include <libpspp/message.h>
#include <libpspp/assertion.h>
#include <math/moments.h>
#include <output/manager.h>
#include <output/table.h>
+#include "xalloc.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
struct dsc_var
{
const struct variable *v; /* Variable to calculate on. */
- char z_name[LONG_NAME_LEN + 1]; /* Name for z-score variable. */
+ char z_name[VAR_NAME_LEN + 1]; /* Name for z-score variable. */
double valid, missing; /* Valid, missing counts. */
struct moments *moments; /* Moments. */
double min, max; /* Maximum and mimimum values. */
for (i = 0; i < dsc->var_cnt; i++)
dsc->vars[i].moments = moments_create (dsc->max_moment);
- /* Data pass. FIXME: error handling. */
+ /* Data pass. */
grouper = casegrouper_create_splits (proc_open (ds), dict);
while (casegrouper_get_next_group (grouper, &group))
calc_descriptives (dsc, group, ds);
generate_z_varname (const struct dictionary *dict, struct dsc_proc *dsc, char *z_name,
const char *var_name, int *z_cnt)
{
- char name[LONG_NAME_LEN + 1];
+ char name[VAR_NAME_LEN + 1];
/* Try a name based on the original variable name. */
name[0] = 'Z';
size_t i;
if (!casereader_peek (group, 0, &c))
- return;
+ {
+ casereader_destroy (group);
+ return;
+ }
output_split_file_values (ds, &c);
case_destroy (&c);
group = casereader_create_filter_weight (group, dataset_dict (ds),
NULL, NULL);
- casereader_split (group, &pass1, &pass2);
- if (dsc->max_moment <= MOMENT_MEAN)
- casereader_destroy (pass2);
+ pass1 = group;
+ pass2 = dsc->max_moment <= MOMENT_MEAN ? NULL : casereader_clone (pass1);
for (i = 0; i < dsc->var_cnt; i++)
{
}
}
if (!casereader_destroy (pass1))
- return;
+ {
+ casereader_destroy (pass2);
+ return;
+ }
/* Second pass for higher-order moments. */
if (dsc->max_moment > MOMENT_MEAN)