- struct arc_item *item = pool_alloc (trns->pool, sizeof *item);
- union arc_value *vp = *p;
-
- if (arc->src_vars[i]->type == NUMERIC)
- item->from.f = vp->f;
- else
- item->from.c = pool_clone (trns->pool, vp->c,
- arc->src_vars[i]->width);
- item->to = arc->direction == ASCENDING ? j + 1 : count - j;
- hsh_force_insert (spec->items, item);
+ const union value *from = &items[j]->from;
+ size_t len;
+ char *recoded_value = NULL;
+ char *c;
+ const int src_width = items[j]->width;
+ union value to_val;
+ value_init (&to_val, 0);
+
+ items[j]->to = direction == ASCENDING ? j + 1 : n_items - j;
+
+ to_val.f = items[j]->to;
+
+ /* Add value labels to the destination variable which indicate
+ the source value from whence the new value comes. */
+ if (src_width > 0)
+ {
+ const char *str = CHAR_CAST_BUG (const char*, value_str (from, src_width));
+
+ recoded_value = recode_string (UTF8, dict_get_encoding (dict), str, src_width);
+ }
+ else
+ recoded_value = asnprintf (NULL, &len, "%g", from->f);
+
+ /* Remove trailing whitespace */
+ for (c = recoded_value; *c != '\0'; c++)
+ if ( *c == ' ')
+ {
+ *c = '\0';
+ break;
+ }
+
+ var_add_value_label (spec->dst, &to_val, recoded_value);
+ value_destroy (&to_val, 0);
+ free (recoded_value);