Implemented long variable names a la spss V12.
[pspp-builds.git] / src / pfm-read.c
index 50b15c5433be2f78b64f20e9b625294fd0a26312..d55f2f6e8c2174b8bd52a7222f82626ef1293a46 100644 (file)
@@ -497,7 +497,7 @@ read_variables (struct pfm_reader *r, struct dictionary *dict)
   if (match (r, '6'))
     {
       weight_name = read_pool_string (r);
-      if (strlen (weight_name) > 8
+      if (strlen (weight_name) > SHORT_NAME_LEN
         error (r, _("Weight variable name (%s) truncated."), weight_name);
     }
   
@@ -520,7 +520,29 @@ read_variables (struct pfm_reader *r, struct dictionary *dict)
       read_string (r, name);
       for (j = 0; j < 6; j++)
         fmt[j] = read_int (r);
+#if 0 
+        /* Weirdly enough, there is no # character in the SPSS portable
+        character set, so we can't check for it. */
+      if (strlen (name) > SHORT_NAME_LEN)
+       lose ((r, _("position %d: Variable name has %u characters."),
+              i, strlen (name)));
+      if ((name[0] < 74 /* A */ || name[0] > 125 /* Z */)
+         && name[0] != 152 /* @ */)
+       lose ((r, _("position %d: Variable name begins with invalid "
+                   "character."), i));
+      if (name[0] >= 100 /* a */ && name[0] <= 125 /* z */)
+       {
+         corrupt_msg (r, _("position %d: Variable name begins with "
+                           "lowercase letter %c."),
+                      i, name[0] - 100 + 'a');
+         name[0] -= 26 /* a - A */;
+       }
 
+      /* Verify remaining characters of variable name. */
+      for (j = 1; j < (int) strlen (name); j++)
+       {
+         int c = name[j];
+#endif
       if (!var_is_valid_name (name, false) || *name == '#') 
         error (r, _("position %d: Invalid variable name `%s'."), name);
       st_uppercase (name);