X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvariable.c;h=2ceeb0d0e9610a6396d58246db942ed8c0302ac1;hb=81579d9e9f994fb2908f50af41c3eb033d216e58;hp=f703722c3f39ec1e02a0691d2b96609fbced4123;hpb=6d53d2b45f5385271dd21e8df1b5ac23d20be9fb;p=pspp-builds.git
diff --git a/src/data/variable.c b/src/data/variable.c
index f703722c..2ceeb0d0 100644
--- a/src/data/variable.c
+++ b/src/data/variable.c
@@ -1,5 +1,5 @@
/* 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
@@ -15,28 +15,28 @@
along with this program. If not, see . */
#include
-#include "variable.h"
+
+#include "data/variable.h"
#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "minmax.h"
-#include "xalloc.h"
+#include "data/attributes.h"
+#include "data/data-out.h"
+#include "data/dictionary.h"
+#include "data/format.h"
+#include "data/identifier.h"
+#include "data/missing-values.h"
+#include "data/value-labels.h"
+#include "data/vardict.h"
+#include "libpspp/assertion.h"
+#include "libpspp/compiler.h"
+#include "libpspp/hash-functions.h"
+#include "libpspp/message.h"
+#include "libpspp/misc.h"
+#include "libpspp/str.h"
+
+#include "gl/minmax.h"
+#include "gl/xalloc.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
@@ -45,7 +45,7 @@
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. */
@@ -91,6 +91,7 @@ var_create (const char *name, int width)
v = xmalloc (sizeof *v);
v->vardict = NULL;
+ v->name = NULL;
var_set_name (v, name);
v->width = width;
mv_init (&v->miss, width);
@@ -155,6 +156,7 @@ var_destroy (struct variable *v)
var_clear_aux (v);
val_labs_destroy (v->val_labs);
var_clear_label (v);
+ free (v->name);
free (v);
}
}
@@ -177,7 +179,8 @@ var_set_name (struct variable *v, const char *name)
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);
}
@@ -506,8 +509,8 @@ alloc_value_labels (struct variable *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)
@@ -518,7 +521,7 @@ var_add_value_label (struct variable *v,
/* 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)