projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed instances of 'signal' to 'signals', to avoid conflicts
[pspp]
/
src
/
data
/
case.c
diff --git
a/src/data/case.c
b/src/data/case.c
index 6e65af975a1d77150c7cbaaeb49d6d278457c433..8c92bbe31d8d92958c5e2e19594fbb76687655cb 100644
(file)
--- 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.
/* PSPP - computes sample statistics.
Copyright (C) 2004 Free Software Foundation, Inc.
- Written by Ben Pfaff <blp@gnu.org>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@
-45,9
+44,6
@@
case_unshare (struct ccase *c)
{
struct case_data *cd;
{
struct case_data *cd;
- assert (c != NULL);
- assert (c->this == c);
- assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 1);
cd = c->case_data;
assert (c->case_data->ref_cnt > 1);
cd = c->case_data;
@@
-72,7
+68,6
@@
void
case_nullify (struct ccase *c)
{
c->case_data = NULL;
case_nullify (struct ccase *c)
{
c->case_data = NULL;
- c->this = c;
}
#endif /* DEBUGGING */
}
#endif /* DEBUGGING */
@@
-100,17
+95,10
@@
case_create (struct ccase *c, size_t value_cnt)
void
case_clone (struct ccase *clone, const struct ccase *orig)
{
void
case_clone (struct ccase *clone, const struct ccase *orig)
{
- assert (orig != NULL);
- assert (orig->this == orig);
- assert (orig->case_data != NULL);
assert (orig->case_data->ref_cnt > 0);
assert (orig->case_data->ref_cnt > 0);
- assert (clone != NULL);
if (clone != orig)
if (clone != orig)
- {
- *clone = *orig;
- clone->this = clone;
- }
+ *clone = *orig;
orig->case_data->ref_cnt++;
}
#endif /* DEBUGGING */
orig->case_data->ref_cnt++;
}
#endif /* DEBUGGING */
@@
-121,16
+109,11
@@
case_clone (struct ccase *clone, const struct ccase *orig)
void
case_move (struct ccase *dst, struct ccase *src)
{
void
case_move (struct ccase *dst, struct ccase *src)
{
- assert (src != NULL);
- assert (src->this == src);
- assert (src->case_data != NULL);
assert (src->case_data->ref_cnt > 0);
assert (src->case_data->ref_cnt > 0);
- assert (dst != NULL);
if (dst != src)
{
*dst = *src;
if (dst != src)
{
*dst = *src;
- dst->this = dst;
case_nullify (src);
}
}
case_nullify (src);
}
}
@@
-144,7
+127,6
@@
case_destroy (struct ccase *c)
struct case_data *cd;
assert (c != NULL);
struct case_data *cd;
assert (c != NULL);
- assert (c->this == c);
cd = c->case_data;
if (cd != NULL && --cd->ref_cnt == 0)
cd = c->case_data;
if (cd != NULL && --cd->ref_cnt == 0)
@@
-178,33
+160,30
@@
case_swap (struct ccase *a, struct ccase *b)
}
/* Attempts to create C as a new case that holds VALUE_CNT
}
/* 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. */
allocation failed. */
-int
+bool
case_try_create (struct ccase *c, size_t value_cnt)
{
case_try_create (struct ccase *c, size_t value_cnt)
{
-#ifdef DEBUGGING
- c->this = c;
-#endif
c->case_data = malloc (case_size (value_cnt));
if (c->case_data != NULL)
{
c->case_data->value_cnt = value_cnt;
c->case_data->ref_cnt = 1;
c->case_data = malloc (case_size (value_cnt));
if (c->case_data != NULL)
{
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.
}
/* 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. */
failed. */
-int
+bool
case_try_clone (struct ccase *clone, const struct ccase *orig)
{
case_clone (clone, orig);
case_try_clone (struct ccase *clone, const struct ccase *orig)
{
case_clone (clone, orig);
- return
1
;
+ return
true
;
}
#ifdef DEBUGGING
}
#ifdef DEBUGGING
@@
-215,17
+194,11
@@
case_copy (struct ccase *dst, size_t dst_idx,
const struct ccase *src, size_t src_idx,
size_t value_cnt)
{
const struct ccase *src, size_t src_idx,
size_t value_cnt)
{
- assert (dst != NULL);
- assert (dst->this == dst);
- assert (dst->case_data != NULL);
assert (dst->case_data->ref_cnt > 0);
assert (dst_idx + value_cnt <= dst->case_data->value_cnt);
assert (dst->case_data->ref_cnt > 0);
assert (dst_idx + value_cnt <= dst->case_data->value_cnt);
- assert (src != NULL);
- assert (src->this == src);
- assert (src->case_data != NULL);
assert (src->case_data->ref_cnt > 0);
assert (src->case_data->ref_cnt > 0);
- assert (src_idx + value_cnt <=
dst
->case_data->value_cnt);
+ assert (src_idx + value_cnt <=
src
->case_data->value_cnt);
if (dst->case_data != src->case_data || dst_idx != src_idx)
{
if (dst->case_data != src->case_data || dst_idx != src_idx)
{
@@
-246,9
+219,6
@@
void
case_to_values (const struct ccase *c, union value *output,
size_t output_size UNUSED)
{
case_to_values (const struct ccase *c, union value *output,
size_t output_size UNUSED)
{
- assert (c != NULL);
- assert (c->this == c);
- assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (output_size == c->case_data->value_cnt);
assert (output != NULL || output_size == 0);
assert (c->case_data->ref_cnt > 0);
assert (output_size == c->case_data->value_cnt);
assert (output != NULL || output_size == 0);
@@
-267,7
+237,6
@@
case_from_values (struct ccase *c, const union value *input,
size_t input_size UNUSED)
{
assert (c != NULL);
size_t input_size UNUSED)
{
assert (c != NULL);
- assert (c->this == c);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (input_size == c->case_data->value_cnt);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (input_size == c->case_data->value_cnt);
@@
-285,10
+254,9
@@
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 *
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 != NULL);
- assert (c->this == c);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (idx < c->case_data->value_cnt);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (idx < c->case_data->value_cnt);
@@
-301,10
+269,9
@@
case_data (const struct ccase *c, size_t idx)
/* Returns the numeric value of the `union value' in C numbered
IDX. */
double
/* 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 != NULL);
- assert (c->this == c);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (idx < c->case_data->value_cnt);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (idx < c->case_data->value_cnt);
@@
-319,10
+286,9
@@
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 *
(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 != NULL);
- assert (c->this == c);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (idx < c->case_data->value_cnt);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (idx < c->case_data->value_cnt);
@@
-336,10
+302,9
@@
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 *
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 != NULL);
- assert (c->this == c);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (idx < c->case_data->value_cnt);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (idx < c->case_data->value_cnt);
@@
-372,22
+337,21
@@
case_compare_2dict (const struct ccase *ca, const struct ccase *cb,
const struct variable *va = *vap;
const struct variable *vb = *vbp;
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 (va
r_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
{
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, va
r_get_width (va)
);
if (cmp != 0)
return cmp;
if (cmp != 0)
return cmp;
@@
-405,7
+369,6
@@
const union value *
case_data_all (const struct ccase *c)
{
assert (c != NULL);
case_data_all (const struct ccase *c)
{
assert (c != NULL);
- assert (c->this == c);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
@@
-421,7
+384,6
@@
union value *
case_data_all_rw (struct ccase *c)
{
assert (c != NULL);
case_data_all_rw (struct ccase *c)
{
assert (c != NULL);
- assert (c->this == c);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);
assert (c->case_data != NULL);
assert (c->case_data->ref_cnt > 0);