bool
var_is_valid_name (const char *name, bool issue_error)
{
+ bool plausible;
size_t length, i;
assert (name != NULL);
CHARACTERS */
length = strlen (name);
- bool plausible = var_is_plausible_name(name, issue_error);
+ plausible = var_is_plausible_name(name, issue_error);
if ( ! plausible )
return false;
abort ();
}
}
+
+/* Return the number of bytes used when writing case_data for a variable
+ of WIDTH */
+int
+width_to_bytes(int width)
+{
+ const int chunks = width / EFFECTIVE_LONG_STRING_LENGTH ;
+ const int remainder = width - (chunks * EFFECTIVE_LONG_STRING_LENGTH) ;
+ int bytes, mod8;
+
+ assert (width >= 0);
+
+ if ( width == 0 )
+ return MAX_SHORT_STRING ;
+
+ if ( width <= MAX_LONG_STRING)
+ return MAX_SHORT_STRING * DIV_RND_UP(width, MAX_SHORT_STRING);
+
+
+ bytes = remainder + (chunks * (MAX_LONG_STRING + 1) );
+
+ /* Round up to the nearest 8 */
+ mod8 = bytes % MAX_SHORT_STRING;
+
+ if ( mod8 )
+ bytes += MAX_SHORT_STRING - mod8;
+
+ assert( bytes % MAX_SHORT_STRING == 0 );
+
+ return bytes;
+}
+
+