X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fcase.c;h=8c92bbe31d8d92958c5e2e19594fbb76687655cb;hb=13d1b533c6ce0545a4b06e5e30c73211591034c5;hp=98de9ec6a1eab70fdd6bd1f52d7558e9ffee842a;hpb=6492b3b49661963dc6d78201a1eb3927fdf54b68;p=pspp-builds.git diff --git a/src/data/case.c b/src/data/case.c index 98de9ec6..8c92bbe3 100644 --- a/src/data/case.c +++ b/src/data/case.c @@ -1,6 +1,5 @@ /* PSPP - computes sample statistics. Copyright (C) 2004 Free Software Foundation, Inc. - Written by Ben Pfaff . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -161,9 +160,9 @@ case_swap (struct ccase *a, struct ccase *b) } /* Attempts to create C as a new case that holds VALUE_CNT - values. Returns nonzero if successful, zero if memory + values. Returns true if successful, false if memory allocation failed. */ -int +bool case_try_create (struct ccase *c, size_t value_cnt) { c->case_data = malloc (case_size (value_cnt)); @@ -171,20 +170,20 @@ case_try_create (struct ccase *c, size_t value_cnt) { c->case_data->value_cnt = value_cnt; c->case_data->ref_cnt = 1; - return 1; + return true; } - else - return 0; + + return false; } /* Tries to initialize CLONE as a copy of ORIG. - Returns nonzero if successful, zero if memory allocation + Returns true if successful, false if memory allocation failed. */ -int +bool case_try_clone (struct ccase *clone, const struct ccase *orig) { case_clone (clone, orig); - return 1; + return true; } #ifdef DEBUGGING @@ -255,7 +254,7 @@ case_from_values (struct ccase *c, const union value *input, element of C numbered IDX. The caller must not modify the returned data. */ const union value * -case_data (const struct ccase *c, size_t idx) +case_data_idx (const struct ccase *c, size_t idx) { assert (c != NULL); assert (c->case_data != NULL); @@ -270,7 +269,7 @@ case_data (const struct ccase *c, size_t idx) /* Returns the numeric value of the `union value' in C numbered IDX. */ double -case_num (const struct ccase *c, size_t idx) +case_num_idx (const struct ccase *c, size_t idx) { assert (c != NULL); assert (c->case_data != NULL); @@ -287,7 +286,7 @@ case_num (const struct ccase *c, size_t idx) (Note that the value is not null-terminated.) The caller must not modify the return value. */ const char * -case_str (const struct ccase *c, size_t idx) +case_str_idx (const struct ccase *c, size_t idx) { assert (c != NULL); assert (c->case_data != NULL); @@ -303,7 +302,7 @@ case_str (const struct ccase *c, size_t idx) element of C numbered IDX. The caller is allowed to modify the returned data. */ union value * -case_data_rw (struct ccase *c, size_t idx) +case_data_rw_idx (struct ccase *c, size_t idx) { assert (c != NULL); assert (c->case_data != NULL); @@ -338,22 +337,21 @@ case_compare_2dict (const struct ccase *ca, const struct ccase *cb, const struct variable *va = *vap; const struct variable *vb = *vbp; - assert (va->type == vb->type); - assert (va->width == vb->width); + assert (var_get_width (va) == var_get_width (vb)); - if (va->width == 0) + if (var_get_width (va) == 0) { - double af = case_num (ca, va->fv); - double bf = case_num (cb, vb->fv); + double af = case_num (ca, va); + double bf = case_num (cb, vb); if (af != bf) return af > bf ? 1 : -1; } else { - const char *as = case_str (ca, va->fv); - const char *bs = case_str (cb, vb->fv); - int cmp = memcmp (as, bs, va->width); + const char *as = case_str (ca, va); + const char *bs = case_str (cb, vb); + int cmp = memcmp (as, bs, var_get_width (va)); if (cmp != 0) return cmp;