+ : hsh_hash_bytes (v->s, width));
+}
+
+
+/* Copies SRC to DST, given that they both contain data of the
+ given WIDTH. */
+void
+value_copy (union value *dst, const union value *src, int width)
+{
+ if (width == 0)
+ dst->f = src->f;
+ else
+ memcpy (dst->s, src->s, width);
+}
+
+/* Sets V to the system-missing value for data of the given
+ WIDTH. */
+void
+value_set_missing (union value *v, int width)
+{
+ if (width == 0)
+ v->f = SYSMIS;
+ else
+ memset (v->s, ' ', width);
+}
+
+/* Tests whether VALUE may be resized from OLD_WIDTH to
+ NEW_WIDTH, using the following rules that match those for
+ resizing missing values and value labels. First, OLD_WIDTH
+ and NEW_WIDTH must be both numeric or both string. Second, if
+ NEW_WIDTH is less than OLD_WIDTH, then the bytes that would be
+ trimmed off the right end of VALUE must be all spaces. */
+bool
+value_is_resizable (const union value *value, int old_width, int new_width)
+{
+ int i;
+
+ if (val_type_from_width (old_width) != val_type_from_width (new_width))
+ return false;
+ for (i = new_width; i < old_width; i++)
+ if (value->s[i] != ' ')
+ return false;
+ return true;
+}
+
+/* Resizes VALUE from OLD_WIDTH to NEW_WIDTH. The arguments must
+ satisfy the rules specified above for value_is_resizable. */
+void
+value_resize (union value *value, int old_width, int new_width)
+{
+ assert (value_is_resizable (value, old_width, new_width));
+ if (new_width > old_width)
+ memset (&value->s[old_width], ' ', new_width - old_width);
+}
+
+/* Compares A and B, which both have the given WIDTH, and returns
+ a strcmp()-type result. */
+int
+value_compare_3way (const union value *a, const union value *b, int width)
+{
+ return (width == 0
+ ? (a->f < b->f ? -1 : a->f > b->f)
+ : memcmp (a->s, b->s, width));