Fix problems with uniqueness of short names in system files with very
[pspp-builds.git] / src / data / sys-file-private.c
index f544a810580e2c07cd454c1b47d4df2556856283..da485f5acf8c29acbba279704568f188081dd71e 100644 (file)
@@ -40,4 +40,16 @@ sfm_width_to_bytes (int width)
     }
 }
 
+/* Returns the number of "segments" used for writing case data
+   for a variable of the given WIDTH.  A segment is a physical
+   variable in the system file that represents some piece of a
+   logical variable as seen by a PSPP user.  Only very long
+   string variables have more than one segment. */
+int
+sfm_width_to_segments (int width)
+{
+  assert (width >= 0);
 
+  return (width < MIN_VERY_LONG_STRING ? 1
+          : DIV_RND_UP (width, EFFECTIVE_LONG_STRING_LENGTH));
+}