From: Ben Pfaff Date: Thu, 7 Jun 2007 05:45:30 +0000 (+0000) Subject: * value.h (value_cnt_from_width): New function. X-Git-Tag: v0.6.0~442 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e21ed65bab28549cd4bb5e8761e5632567ac4cb2;p=pspp-builds.git * value.h (value_cnt_from_width): New function. * variable.c (var_get_value_cnt): Use new function. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index a74549fb..56976e37 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,9 @@ +2007-06-06 Ben Pfaff + + * value.h (value_cnt_from_width): New function. + + * variable.c (var_get_value_cnt): Use new function. + 2007-06-06 Ben Pfaff Add casegrouper, to allow cases read from a given casereader to be diff --git a/src/data/value.h b/src/data/value.h index e3e3f0de..9e771b73 100644 --- a/src/data/value.h +++ b/src/data/value.h @@ -38,6 +38,14 @@ #define LOWEST second_lowest_value #define HIGHEST DBL_MAX +/* Number of "union value"s required for a variable of the given + WIDTH. */ +static inline size_t +value_cnt_from_width (int width) +{ + return width == 0 ? 1 : DIV_RND_UP (width, MAX_SHORT_STRING); +} + /* A numeric or short string value. Multiple consecutive values represent a long string. */ union value diff --git a/src/data/variable.c b/src/data/variable.c index f890746a..768aa477 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -423,7 +423,7 @@ var_is_long_string (const struct variable *v) size_t var_get_value_cnt (const struct variable *v) { - return v->width == 0 ? 1 : DIV_RND_UP (v->width, MAX_SHORT_STRING); + return value_cnt_from_width (v->width); } /* Returns variable V's missing values. */