/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 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 <libpspp/misc.h>
#include <libpspp/assertion.h>
#include <libpspp/compiler.h>
-#include <libpspp/hash.h>
+#include <libpspp/hash-functions.h>
#include <libpspp/message.h>
#include <libpspp/str.h>
struct variable
{
/* Dictionary information. */
- char name[VAR_NAME_LEN + 1]; /* Variable name. Mixed case. */
+ char *name; /* Variable name. Mixed case. */
int width; /* 0 for numeric, otherwise string width. */
struct missing_values miss; /* Missing values. */
struct fmt_spec print; /* Default format for PRINT. */
v = xmalloc (sizeof *v);
v->vardict = NULL;
+ v->name = NULL;
var_set_name (v, name);
v->width = width;
mv_init (&v->miss, width);
var_clear_aux (v);
val_labs_destroy (v->val_labs);
var_clear_label (v);
+ free (v->name);
free (v);
}
}
assert (!var_has_vardict (v));
assert (var_is_plausible_name (name, false));
- str_copy_trunc (v->name, sizeof v->name, name);
+ free (v->name);
+ v->name = xstrdup (name);
dict_var_changed (v);
}
}
/* Attempts to add a value label with the given VALUE and LABEL
- to V. Returns true if successful, false if VALUE has an
- existing label or if V is a long string variable. */
+ to V. Returns true if successful, false otherwise (probably
+ due to an existing label). */
bool
var_add_value_label (struct variable *v,
const union value *value, const char *label)
/* Adds or replaces a value label with the given VALUE and LABEL
to V.
- Has no effect if V is a long string variable. */
+*/
void
var_replace_value_label (struct variable *v,
const union value *value, const char *label)