From: Ben Pfaff Date: Sat, 23 Apr 2011 19:01:35 +0000 (-0700) Subject: dictionary: Set encoding early when cloning a dictionary. X-Git-Tag: v0.7.8~41 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7731fa51f095e615975cd53d35ba3cb681b82df1;p=pspp-builds.git 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. --- 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++)