#include <config.h>
#include "variable.h"
+#include <libpspp/assertion.h>
#include <libpspp/message.h>
#include <stdlib.h>
#include <libpspp/alloc.h>
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;
case DC_SCRATCH:
return _("scratch");
default:
- assert (0);
- abort ();
+ NOT_REACHED ();
}
}
+
+/* Return the number of bytes used when writing case_data for a variable
+ of WIDTH */
+int
+width_to_bytes(int width)
+{
+ assert (width >= 0);
+
+ if ( width == 0 )
+ return MAX_SHORT_STRING ;
+ else if (width <= MAX_LONG_STRING)
+ return ROUND_UP (width, MAX_SHORT_STRING);
+ else
+ {
+ int chunks = width / EFFECTIVE_LONG_STRING_LENGTH ;
+ int remainder = width % EFFECTIVE_LONG_STRING_LENGTH ;
+ int bytes = remainder + (chunks * (MAX_LONG_STRING + 1) );
+ return ROUND_UP (bytes, MAX_SHORT_STRING);
+ }
+}
+
+