+/* Determines whether VLS's width can be changed to NEW_WIDTH.
+ Numeric widths cannot be changed at all.
+ Strings can be widened. They can be shortened only if the
+ characters that will be truncated are spaces. */
+bool
+val_labs_can_set_width (const struct val_labs *vls, int new_width)
+{
+ if ( var_type_from_width (new_width) != var_type_from_width (vls->width ))
+ return false;
+
+ if (vls->width == 0)
+ return new_width == 0;
+ else if (new_width < vls->width)
+ {
+ struct val_labs_iterator *i;
+ struct val_lab *lab;
+
+ for (lab = val_labs_first (vls, &i); lab != NULL;
+ lab = val_labs_next (vls, &i))
+ {
+ int j;
+
+ /* We can shorten the value labels only if all the
+ truncated characters are blanks. */
+ for (j = vls->width; j < new_width; j++)
+ if (lab->value.s[j] != ' ')
+ {
+ val_labs_done (&i);
+ return false;
+ }
+ }
+ return true;
+ }
+ else
+ return true;
+}
+