Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / data / variable.c
index f703722c3f39ec1e02a0691d2b96609fbced4123..2ceeb0d0e9610a6396d58246db942ed8c0302ac1 100644 (file)
@@ -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
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
-#include "variable.h"
+
+#include "data/variable.h"
 
 #include <stdlib.h>
 
-#include <data/attributes.h>
-#include <data/data-out.h>
-#include <data/format.h>
-#include <data/dictionary.h>
-#include <data/identifier.h>
-#include <data/missing-values.h>
-#include <data/value-labels.h>
-#include <data/vardict.h>
-
-#include <libpspp/misc.h>
-#include <libpspp/assertion.h>
-#include <libpspp/compiler.h>
-#include <libpspp/hash-functions.h>
-#include <libpspp/message.h>
-#include <libpspp/str.h>
-
-#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)