/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009, 2010, 2012, 2013 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009, 2010, 2012, 2013, 2014 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
#include <config.h>
+#include <float.h>
#include <stdlib.h>
#include "data/case.h"
struct casereader *input;
struct ccase *c;
- size_t i;
bool ok;
/* Create procedure. */
if (!parse_variables_const (lexer, dict, &src_vars, &n_srcs,
PV_NO_DUPLICATE | PV_NO_SCRATCH))
goto error;
+ lex_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "INTO"))
goto error;
lex_match (lexer, T_EQUALS);
goto error;
}
- for (i = 0; i < n_dsts; i++)
+ for (size_t i = 0; i < n_dsts; i++)
{
const char *name = dst_names[i];
arc->blank_valid = false;
}
else
- goto error;
+ {
+ lex_error_expecting (lexer, "VALID", "MISSING");
+ goto error;
+ }
}
else
- goto error;
+ {
+ lex_error_expecting (lexer, "DESCENDING", "PRINT", "GROUP", "BLANK");
+ goto error;
+ }
}
if (lex_token (lexer) != T_ENDCMD)
arc->n_specs = n_dsts;
- for (i = 0; i < n_dsts; i++)
+ for (size_t i = 0; i < n_dsts; i++)
{
struct arc_spec *spec = &arc->specs[i];
/* Execute procedure. */
input = proc_open (ds);
for (; (c = casereader_read (input)) != NULL; case_unref (c))
- for (i = 0; i < arc->n_specs; i++)
+ for (size_t i = 0; i < arc->n_specs; i++)
{
struct arc_spec *spec = &arc->specs[i];
int width = spec->width;
item = find_arc_item (spec, value, hash);
if ( (item == NULL)
- &&
+ &&
( arc->blank_valid
|| val_type_from_width (spec->width) == VAL_NUMERIC
|| ! value_is_blank (value, width, dict))
dict = dataset_dict (ds);
/* Create transformation. */
- for (i = 0; i < arc->n_specs; i++)
+ for (size_t i = 0; i < arc->n_specs; i++)
{
struct arc_spec *spec = &arc->specs[i];
struct arc_item **items;
value_init (&to_val, 0);
items[j]->to = direction == ASCENDING ? j + 1 : n_items - j;
-
+
to_val.f = items[j]->to;
/* Add value labels to the destination variable which indicate
str, src_width);
}
else
- recoded_value = c_xasprintf ("%g", from->f);
-
+ recoded_value = c_xasprintf ("%.*g", DBL_DIG + 1, from->f);
+
/* Remove trailing whitespace */
len = strlen (recoded_value);
while (len > 0 && recoded_value[len - 1] == ' ')
}
add_transformation (ds, autorecode_trns_proc, autorecode_trns_free, arc);
- for (i = 0; i < n_dsts; i++)
+ for (size_t i = 0; i < n_dsts; i++)
free (dst_names[i]);
free (dst_names);
free (src_vars);
return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE;
error:
- for (i = 0; i < n_dsts; i++)
+ for (size_t i = 0; i < n_dsts; i++)
free (dst_names[i]);
free (dst_names);
free (src_vars);
{
if (arc != NULL)
{
- size_t i;
-
- for (i = 0; i < arc->n_specs; i++)
+ for (size_t i = 0; i < arc->n_specs; i++)
{
struct arc_spec *spec = &arc->specs[i];
struct arc_item *item, *next;
}
}
- for (i = 0; i < arc->n_specs; i++)
+ for (size_t i = 0; i < arc->n_specs; i++)
{
struct arc_spec *spec = &arc->specs[i];
-
+
if (--spec->items->refcnt == 0)
{
hmap_destroy (&spec->items->ht);
hmap_destroy (&arc->global_items->ht);
free (arc->global_items);
}
-
+
free (arc->specs);
free (arc);
}
casenumber case_idx UNUSED)
{
struct autorecode_pgm *arc = arc_;
- size_t i;
*c = case_unshare (*c);
- for (i = 0; i < arc->n_specs; i++)
+ for (size_t i = 0; i < arc->n_specs; i++)
{
const struct arc_spec *spec = &arc->specs[i];
const union value *value = case_data_idx (*c, spec->src_idx);