/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011, 2012 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
static void dict_unset_split_var (struct dictionary *, struct variable *);
static void dict_unset_mrset_var (struct dictionary *, struct variable *);
+/* Returns the encoding for data in dictionary D. The return value is a
+ nonnull string that contains an IANA character set name. */
const char *
dict_get_encoding (const struct dictionary *d)
{
d = dict_create (s->encoding);
- /* Set the new dictionary's encoding early so that string length limitations
- are interpreted correctly. */
- if ( s->encoding)
- d->encoding = xstrdup (s->encoding);
-
for (i = 0; i < s->var_cnt; i++)
{
struct variable *sv = s->var[i].var;
d->callbacks = NULL ;
dict_clear (d);
+ string_array_destroy (&d->documents);
hmap_destroy (&d->name_map);
attrset_destroy (&d->attributes);
dict_clear_mrsets (d);
{
int dict_index = var_get_dict_index (v);
const int case_index = var_get_case_index (v);
- const int width = var_get_width (v);
assert (dict_contains_var (d, v));
/* Free memory. */
var_clear_vardict (v);
- var_destroy (v);
if ( d->changed ) d->changed (d, d->changed_data);
invalidate_proto (d);
if (d->callbacks && d->callbacks->var_deleted )
- d->callbacks->var_deleted (d, dict_index, case_index, width, d->cb_data);
+ d->callbacks->var_deleted (d, v, dict_index, case_index, d->cb_data);
+
+ var_destroy (v);
}
/* Deletes the COUNT variables listed in VARS from D. This is
return d->label;
}
-/* Sets D's file label to LABEL, truncating it to a maximum of 60
- characters.
+/* Sets D's file label to LABEL, truncating it to at most 60 bytes in D's
+ encoding.
Removes D's label if LABEL is null or the empty string. */
void
dict_set_label (struct dictionary *d, const char *label)
{
free (d->label);
- d->label = label != NULL && label[0] != '\0' ? xstrndup (label, 60) : NULL;
+ if (label == NULL || label[0] == '\0')
+ d->label = NULL;
+ else
+ d->label = utf8_encoding_trunc (label, d->encoding, 60);
}
/* Returns the documents for D, as an UTF-8 encoded string_array. The