}
*cp = '\0';
+ if (strlen (name) == 0)
+ {
+ free (name);
+ name = xstrdup ("v");
+ }
+
/* Use the mangled name, if it is available, or add numeric
extensions until we find one that is. */
- if (!dict_create_var (dict, name, 0))
+ if (!id_is_plausible (name, false) || !dict_create_var (dict, name, 0))
{
int len = strlen (name);
int i;
strncpy (n, name, ofs);
sprintf (&n[ofs], "%d", i);
- if (dict_create_var (dict, n, 0))
+ if (id_is_plausible (n, false) && dict_create_var (dict, n, 0))
break;
}
}
AT_CHECK([pspp -O format=csv flip.sps], [1], [ignore])
AT_CLEANUP
+
+
+
+AT_SETUP([FLIP with invalid variable names])
+
+AT_DATA([flip.sps], [dnl
+data list notable list /N (a3) a b c d *.
+begin data.
+"" 1 2 3 4
+BY 1 2 3 4
+end data.
+
+flip newnames=n.
+
+list.
+])
+
+AT_CHECK([pspp -O format=csv flip.sps], [0], [dnl
+Table: Data List
+CASE_LBL,v,BY1
+a ,1.00,1.00
+b ,2.00,2.00
+c ,3.00,3.00
+d ,4.00,4.00
+])
+
+AT_CLEANUP