+
+/* Sets V's short name to BASE, followed by a suffix of the form
+ _A, _B, _C, ..., _AA, _AB, etc. according to the value of
+ SUFFIX_NUMBER. Truncates BASE as necessary to fit. */
+static void
+set_var_short_name_suffix (struct variable *v, const char *base,
+ int suffix_number)
+{
+ char suffix[SHORT_NAME_LEN + 1];
+ char short_name[SHORT_NAME_LEN + 1];
+ char *start, *end;
+ int len, ofs;
+
+ assert (v != NULL);
+ assert (suffix_number >= 0);
+
+ /* Set base name. */
+ var_set_short_name (v, base);
+
+ /* Compose suffix. */
+ start = end = suffix + sizeof suffix - 1;
+ *end = '\0';
+ do
+ {
+ *--start = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[suffix_number % 26];
+ if (start <= suffix + 1)
+ msg (SE, _("Variable suffix too large."));
+ suffix_number /= 26;
+ }
+ while (suffix_number > 0);
+ *--start = '_';
+
+ /* Append suffix to V's short name. */
+ str_copy_trunc (short_name, sizeof short_name, base);
+ len = end - start;
+ if (len + strlen (short_name) > SHORT_NAME_LEN)
+ ofs = SHORT_NAME_LEN - len;
+ else
+ ofs = strlen (short_name);
+ strcpy (short_name + ofs, start);
+
+ /* Set name. */
+ var_set_short_name (v, short_name);
+}
+