/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010, 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 <data/datasheet.h>
#include <ctype.h>
+#include <float.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <data/casereader-provider.h>
#include "error.h"
#include "minmax.h"
#include "progname.h"
-#include "xalloc.h"
/* lazy_casereader callback function to instantiate a casereader
from the datasheet. */
{
if (width == 0)
mc_error (mc, "element %zu,%zu (of %zu,%zu) differs: "
- "%g != %g",
+ "%.*g != %.*g",
row, col, n_rows, n_columns,
- case_num_idx (c, col), array[row][col].f);
+ DBL_DIG + 1, case_num_idx (c, col),
+ DBL_DIG + 1, array[row][col].f);
else
mc_error (mc, "element %zu,%zu (of %zu,%zu) differs: "
"'%.*s' != '%.*s'",
row, col, n_rows, n_columns,
width, case_str_idx (c, col),
- width, value_str (&array[row][col], width));
+ width, array[row][col].s);
}
}
{
if (width == 0)
mc_error (mc, "element %zu,%zu (of %zu,%zu) differs: "
- "%g != %g", row, col, n_rows, n_columns,
- v.f, av->f);
+ "%.*g != %.*g", row, col, n_rows, n_columns,
+ DBL_DIG + 1, v.f, DBL_DIG + 1, av->f);
else
mc_error (mc, "element %zu,%zu (of %zu,%zu) differs: "
"'%.*s' != '%.*s'",
row, col, n_rows, n_columns,
- width, value_str (&v, width),
- width, value_str (av, width));
+ width, v.s,
+ width, v.s);
difference = true;
}
value_destroy (&v, width);
if (width == 0)
ds_put_format (&s, " %g", v->f);
else
- ds_put_format (&s, " '%.*s'", width, value_str (v, width));
+ ds_put_format (&s, " '%.*s'", width, v->s);
}
mc_error (mc, "%s", ds_cstr (&s));
}
if (width == 0)
ds_put_format (&s, " %g", v.f);
else
- ds_put_format (&s, " '%.*s'",
- width, value_str (&v, width));
+ ds_put_format (&s, " '%.*s'", width, v.s);
}
mc_error (mc, "%s", ds_cstr (&s));
}
else
{
unsigned int hash = hash_int (idx, 0);
- char *string = value_str_rw (value, width);
int offset;
assert (width < 32);
for (offset = 0; offset < width; offset++)
- string[offset] = "ABCDEFGHIJ"[(hash >> offset) % 10];
+ value->s[offset] = "ABCDEFGHIJ"[(hash >> offset) % 10];
}
}
if (params->backing_rows == 0 && params->n_backing_cols == 0)
{
/* Create unbacked datasheet. */
+ struct caseproto *proto;
ds = datasheet_create (NULL);
mc_name_operation (mc, "empty datasheet");
- check_datasheet (mc, ds, NULL, 0, caseproto_create ());
+ proto = caseproto_create ();
+ check_datasheet (mc, ds, NULL, 0, proto);
+ caseproto_unref (proto);
}
else
{
};
static void
-resize_cb (const union value *old_value, union value *new_value, void *aux_)
+resize_cb (const union value *old_value, union value *new_value, const void *aux_)
{
- struct resize_cb_aux *aux = aux_;
+ const struct resize_cb_aux *aux = aux_;
value_from_param (new_value, aux->new_width,
value_hash (old_value, aux->old_width, 0));
N_DATASHEET_OPTIONS
};
-static struct argv_option datasheet_argv_options[N_DATASHEET_OPTIONS] =
+static const struct argv_option datasheet_argv_options[N_DATASHEET_OPTIONS] =
{
{"max-rows", 0, required_argument, OPT_MAX_ROWS},
{"max-columns", 0, required_argument, OPT_MAX_COLUMNS},
" other values are string widths (0,1,11)\n",
program_name, program_name);
mc_options_usage ();
- fputs ("\nOther options:\n"
- " --help Display this help message\n"
- "\nReport bugs to <bug-gnu-pspp@gnu.org>\n",
- stdout);
+ printf ("\nOther options:\n"
+ " --help Display this help message\n"
+ "\nReport bugs to <%s>\n", PACKAGE_BUGREPORT);
exit (0);
}
params.n_widths = 3;
params.next_value = 1;
- /* Parse comand line. */
+ /* Parse command line. */
parser = argv_parser_create ();
options = mc_options_create ();
mc_options_register_argv_parser (options, parser);