From 7731fa51f095e615975cd53d35ba3cb681b82df1 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 23 Apr 2011 12:01:35 -0700 Subject: [PATCH] dictionary: Set encoding early when cloning a dictionary. Many operations that involve the names of variables and other entities in a dictionary depend on the dictionary's encoding, so it is potentially important to have the encoding set properly when adding other entities to the dictionary. I did not check that this fixes an actual bug. --- src/data/dictionary.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/data/dictionary.c b/src/data/dictionary.c index c00bd4fa..7d67defb 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -198,6 +198,11 @@ dict_clone (const struct dictionary *s) d = dict_create (); + /* 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; @@ -235,9 +240,6 @@ dict_clone (const struct dictionary *s) for (i = 0; i < s->vector_cnt; i++) d->vector[i] = vector_clone (s->vector[i], s, d); - if ( s->encoding) - d->encoding = xstrdup (s->encoding); - dict_set_attributes (d, dict_get_attributes (s)); for (i = 0; i < s->n_mrsets; i++) -- 2.30.2