Most uses of VAR_NAME_LEN within PSPP are wrong due to encoding issues:
the limit applies to variable names in the encoding used by the data
set, but most uses of VAR_NAME_LEN actually limit the length of a name
in UTF-8. The UTF-8 representation of a name can be longer or shorter
than its representation in the data set encoding, so it seems best to
eliminate references to VAR_NAME_LEN entirely.
/* PSPP - a program for statistical analysis.
/* 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
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
struct variable
{
/* Dictionary information. */
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. */
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 = xmalloc (sizeof *v);
v->vardict = NULL;
var_set_name (v, name);
v->width = width;
mv_init (&v->miss, width);
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);
var_clear_aux (v);
val_labs_destroy (v->val_labs);
var_clear_label (v);
assert (!var_has_vardict (v));
assert (var_is_plausible_name (name, false));
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);