projects
/
pspp-builds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
66b8883
)
Avoid forcing an int into a void *
author
John Darrington
<john@darrington.wattle.id.au>
Fri, 26 Sep 2008 10:44:02 +0000
(18:44 +0800)
committer
John Darrington
<john@darrington.wattle.id.au>
Fri, 26 Sep 2008 10:44:02 +0000
(18:44 +0800)
13 files changed:
src/data/category.c
patch
|
blob
|
history
src/data/value.c
patch
|
blob
|
history
src/data/value.h
patch
|
blob
|
history
src/language/stats/binomial.c
patch
|
blob
|
history
src/language/stats/examine.q
patch
|
blob
|
history
src/language/stats/freq.c
patch
|
blob
|
history
src/language/stats/oneway.q
patch
|
blob
|
history
src/language/stats/t-test.q
patch
|
blob
|
history
src/math/coefficient.c
patch
|
blob
|
history
src/math/covariance-matrix.c
patch
|
blob
|
history
src/math/group.c
patch
|
blob
|
history
src/math/group.h
patch
|
blob
|
history
src/ui/gui/find-dialog.c
patch
|
blob
|
history
diff --git
a/src/data/category.c
b/src/data/category.c
index 1620bc7f7f9b3c27bbde71737eeb860d5c4f7cf0..7190418c266f2d31083f12bb3717f4a61b370155 100644
(file)
--- a/
src/data/category.c
+++ b/
src/data/category.c
@@
-108,7
+108,7
@@
cat_value_find (const struct variable *v, const union value *val)
{
candidate = obs_vals->vals + i;
assert (candidate != NULL);
{
candidate = obs_vals->vals + i;
assert (candidate != NULL);
- if (!compare_values (candidate, val, v
ar_get_width (v)
))
+ if (!compare_values (candidate, val, v))
{
return i;
}
{
return i;
}
diff --git
a/src/data/value.c
b/src/data/value.c
index 49555d9a4ea3b11ce15149ebdca388722af6dcb4..9fcf1cbb9b8fa0a97cb4e75544a9a6892879ab68 100644
(file)
--- a/
src/data/value.c
+++ b/
src/data/value.c
@@
-20,6
+20,7
@@
#include <data/val-type.h>
#include <libpspp/hash.h>
#include <libpspp/str.h>
#include <data/val-type.h>
#include <libpspp/hash.h>
#include <libpspp/str.h>
+#include "variable.h"
#include "xalloc.h"
#include "xalloc.h"
@@
-46,8
+47,12
@@
value_create (int width)
Only the short string portion of longer strings are
compared. */
int
Only the short string portion of longer strings are
compared. */
int
-compare_values (const
union value *a, const union value *b, int width
)
+compare_values (const
void *a_, const void *b_, const void *var_
)
{
{
+ const union value *a = a_;
+ const union value *b = b_;
+ const struct variable *var = var_;
+ int width = var_get_width (var);
return (width == 0
? (a->f < b->f ? -1 : a->f > b->f)
: memcmp (a->s, b->s, MIN (MAX_SHORT_STRING, width)));
return (width == 0
? (a->f < b->f ? -1 : a->f > b->f)
: memcmp (a->s, b->s, MIN (MAX_SHORT_STRING, width)));
@@
-56,24
+61,14
@@
compare_values (const union value *a, const union value *b, int width)
/* Create a hash of V, which has the given WIDTH.
Only the short string portion of a longer string is hashed. */
unsigned
/* Create a hash of V, which has the given WIDTH.
Only the short string portion of a longer string is hashed. */
unsigned
-hash_value (const
union value *v, int width
)
+hash_value (const
void *v_, const void *var_
)
{
{
+ const union value *v = v_;
+ const struct variable *var = var_;
+ int width = var_get_width (var);
return (width == 0
? hsh_hash_double (v->f)
return (width == 0
? hsh_hash_double (v->f)
- : hsh_hash_bytes (v->s, MIN (MAX_SHORT_STRING, width)));
-}
-
-
-int
-compare_ptr_values (const union value **v1, const union value **v2, int width)
-{
- return compare_values (*v1, *v2, width);
-}
-
-unsigned
-hash_ptr_value (const union value **v, int width)
-{
- return hash_value (*v, width);
+ : hsh_hash_bytes (v->s, width));
}
}
diff --git
a/src/data/value.h
b/src/data/value.h
index 4554a36617eb589153dc7244f19b3edf74c0bbd7..9103c6b317fe8f1939767a78236a83f94924c148 100644
(file)
--- a/
src/data/value.h
+++ b/
src/data/value.h
@@
-39,12
+39,8
@@
union value
union value *value_dup (const union value *, int width);
union value *value_create (int width);
union value *value_dup (const union value *, int width);
union value *value_create (int width);
-int compare_values (const union value *, const union value *, int width);
-unsigned hash_value (const union value *, int width);
-
-int compare_ptr_values (const union value **, const union value **, int width);
-unsigned hash_ptr_value (const union value **, int width);
-
+int compare_values (const void *, const void *, const void *var);
+unsigned hash_value (const void *, const void *var);
static inline size_t value_cnt_from_width (int width);
void value_copy (union value *, const union value *, int width);
static inline size_t value_cnt_from_width (int width);
void value_copy (union value *, const union value *, int width);
diff --git
a/src/language/stats/binomial.c
b/src/language/stats/binomial.c
index f543505166f6129f53eb8b3db032ce53145950ab..5022cebddd35dbe98994ff193e878e6dcb87d4dd 100644
(file)
--- a/
src/language/stats/binomial.c
+++ b/
src/language/stats/binomial.c
@@
-119,14
+119,14
@@
do_binomial (const struct dictionary *dict,
cat1[v].value = value_dup (value, width);
cat1[v].count = w;
}
cat1[v].value = value_dup (value, width);
cat1[v].count = w;
}
- else if ( 0 == compare_values (cat1[v].value, value,
width
))
+ else if ( 0 == compare_values (cat1[v].value, value,
var
))
cat1[v].count += w;
else if ( NULL == cat2[v].value )
{
cat2[v].value = value_dup (value, width);
cat2[v].count = w;
}
cat1[v].count += w;
else if ( NULL == cat2[v].value )
{
cat2[v].value = value_dup (value, width);
cat2[v].count = w;
}
- else if ( 0 == compare_values (cat2[v].value, value,
width
))
+ else if ( 0 == compare_values (cat2[v].value, value,
var
))
cat2[v].count += w;
else if ( bst->category1 == SYSMIS)
msg (ME, _("Variable %s is not dichotomous"), var_get_name (var));
cat2[v].count += w;
else if ( bst->category1 == SYSMIS)
msg (ME, _("Variable %s is not dichotomous"), var_get_name (var));
diff --git
a/src/language/stats/examine.q
b/src/language/stats/examine.q
index 7f197ec37b57818767188fce9c1b2ab9a57e956c..e341b18a352f294298a4fbb004eb9c2672412fd6 100644
(file)
--- a/
src/language/stats/examine.q
+++ b/
src/language/stats/examine.q
@@
-1338,7
+1338,7
@@
show_summary (const struct variable **dependent_var, int n_dep_var,
if ( last_value == NULL ||
compare_values (last_value, result->value[0],
if ( last_value == NULL ||
compare_values (last_value, result->value[0],
-
var_get_width(fctr->indep_var[0])
))
+
fctr->indep_var[0]
))
{
struct string str;
{
struct string str;
diff --git
a/src/language/stats/freq.c
b/src/language/stats/freq.c
index f2054380b8807fff50107d3a5b8902a484a6e742..afad84ee4bcdc6f0a93c83a6f71c71494cb03895 100644
(file)
--- a/
src/language/stats/freq.c
+++ b/
src/language/stats/freq.c
@@
-30,16
+30,15
@@
compare_freq ( const void *_f1, const void *_f2, const void *_var)
const struct freq *f2 = _f2;
const struct variable *var = _var;
const struct freq *f2 = _f2;
const struct variable *var = _var;
- return compare_values (f1->value, f2->value, var
_get_width (var)
);
+ return compare_values (f1->value, f2->value, var );
}
unsigned int
}
unsigned int
-hash_freq (const void *_f, const void *
_
var)
+hash_freq (const void *_f, const void *var)
{
const struct freq *f = _f;
{
const struct freq *f = _f;
- const struct variable *var = _var;
- return hash_value (f->value, var
_get_width (var)
);
+ return hash_value (f->value, var);
}
/* Free function to be used on FR whose value parameter has been copied */
}
/* Free function to be used on FR whose value parameter has been copied */
diff --git
a/src/language/stats/oneway.q
b/src/language/stats/oneway.q
index 46cdd56649773d6b5166d79aa358bcc77f609eca..8c5d0c9966c01c09780af115e57c353a435d53e6 100644
(file)
--- a/
src/language/stats/oneway.q
+++ b/
src/language/stats/oneway.q
@@
-873,13
+873,9
@@
precalc ( struct cmd_oneway *cmd UNUSED )
The hash contains a group_statistics structure,
and is keyed by value of the independent variable */
The hash contains a group_statistics structure,
and is keyed by value of the independent variable */
- gp->group_hash =
- hsh_create(4,
- (hsh_compare_func *) compare_group,
- (hsh_hash_func *) hash_group,
- (hsh_free_func *) free_group,
- (void *) var_get_width (indep_var) );
-
+ gp->group_hash = hsh_create(4, compare_group, hash_group,
+ (hsh_free_func *) free_group,
+ indep_var);
totals->sum=0;
totals->n=0;
totals->sum=0;
totals->n=0;
@@
-919,10
+915,10
@@
run_oneway (struct cmd_oneway *cmd,
taint = taint_clone (casereader_get_taint (input));
global_group_hash = hsh_create(4,
taint = taint_clone (casereader_get_taint (input));
global_group_hash = hsh_create(4,
-
(hsh_compare_func *)
compare_values,
-
(hsh_hash_func *)
hash_value,
+ compare_values,
+ hash_value,
free_value,
free_value,
-
(void *) var_get_width (indep_var)
);
+
indep_var
);
precalc(cmd);
precalc(cmd);
@@
-957,7
+953,7
@@
run_oneway (struct cmd_oneway *cmd,
struct group_statistics *gs;
struct group_statistics *gs;
- gs = hsh_find
(group_hash, (void *)
indep_val );
+ gs = hsh_find
(group_hash,
indep_val );
if ( ! gs )
{
if ( ! gs )
{
@@
-970,7
+966,7
@@
run_oneway (struct cmd_oneway *cmd,
gs->minimum = DBL_MAX;
gs->maximum = -DBL_MAX;
gs->minimum = DBL_MAX;
gs->maximum = -DBL_MAX;
- hsh_insert ( group_hash,
(void *)
gs );
+ hsh_insert ( group_hash, gs );
}
if (!var_is_value_missing (v, val, exclude))
}
if (!var_is_value_missing (v, val, exclude))
diff --git
a/src/language/stats/t-test.q
b/src/language/stats/t-test.q
index 116f04b40403cd27dc09afd201cba76781181c22..3d27874362050247f3ab55f534312d4bdfc217ee 100644
(file)
--- a/
src/language/stats/t-test.q
+++ b/
src/language/stats/t-test.q
@@
-80,8
+80,8
@@
struct group_properties
/* The comparison criterion */
enum comparison criterion;
/* The comparison criterion */
enum comparison criterion;
- /* The
width of the
independent variable */
-
int indep_width
;
+ /* The independent variable */
+
struct variable *indep_var
;
union {
/* The value of the independent variable at which groups are determined to
union {
/* The value of the independent variable at which groups are determined to
@@
-1676,7
+1676,7
@@
group_precalc (struct cmd_t_test *cmd )
/* There's always 2 groups for a T - TEST */
ttpr->n_groups = 2;
/* There's always 2 groups for a T - TEST */
ttpr->n_groups = 2;
- gp.indep_
width = var_get_width (indep_var)
;
+ gp.indep_
var = indep_var
;
ttpr->group_hash = hsh_create (2,
(hsh_compare_func *) compare_group_binary,
ttpr->group_hash = hsh_create (2,
(hsh_compare_func *) compare_group_binary,
@@
-1888,10
+1888,6
@@
compare_group_binary (const struct group_statistics *a,
if ( p->criterion == CMP_LE )
{
if ( p->criterion == CMP_LE )
{
- /* less-than comparision is not meaningfull for
- alpha variables, so we shouldn't ever arrive here */
- assert (p->indep_width == 0 ) ;
-
flag_a = ( a->id.f < p->v.critical_value ) ;
flag_b = ( b->id.f < p->v.critical_value ) ;
}
flag_a = ( a->id.f < p->v.critical_value ) ;
flag_b = ( b->id.f < p->v.critical_value ) ;
}
@@
-1918,8
+1914,6
@@
hash_group_binary (const struct group_statistics *g,
if ( p->criterion == CMP_LE )
{
if ( p->criterion == CMP_LE )
{
- /* Not meaningfull to do a less than compare for alpha values ? */
- assert (p->indep_width == 0 ) ;
flag = ( g->id.f < p->v.critical_value ) ;
}
else if ( p->criterion == CMP_EQ)
flag = ( g->id.f < p->v.critical_value ) ;
}
else if ( p->criterion == CMP_EQ)
@@
-1939,10
+1933,10
@@
short
which_group (const struct group_statistics *g,
const struct group_properties *p)
{
which_group (const struct group_statistics *g,
const struct group_properties *p)
{
- if ( 0 == compare_values (&g->id, &p->v.g_value[0], p->indep_
width
))
+ if ( 0 == compare_values (&g->id, &p->v.g_value[0], p->indep_
var
))
return 0;
return 0;
- if ( 0 == compare_values (&g->id, &p->v.g_value[1], p->indep_
width
))
+ if ( 0 == compare_values (&g->id, &p->v.g_value[1], p->indep_
var
))
return 1;
return 2;
return 1;
return 2;
diff --git
a/src/math/coefficient.c
b/src/math/coefficient.c
index 2feeedbaa8f2aff28ace93a23cd0a72fd0d43436..f738c783f241fedd1137d3100a372c5664b8341b 100644
(file)
--- a/
src/math/coefficient.c
+++ b/
src/math/coefficient.c
@@
-160,7
+160,7
@@
pspp_coeff_var_to_coeff (const struct variable *v, struct pspp_coeff **coefs,
size_t i = 0;
size_t j = 0;
size_t v_idx;
size_t i = 0;
size_t j = 0;
size_t v_idx;
- int found = 0;
+
struct pspp_coeff *result = NULL;
if (v != NULL)
struct pspp_coeff *result = NULL;
if (v != NULL)
@@
-187,7
+187,7
@@
pspp_coeff_var_to_coeff (const struct variable *v, struct pspp_coeff **coefs,
{
j = i;
while (j < n_coef && compare_values (pspp_coeff_get_value (coefs[j], v),
{
j = i;
while (j < n_coef && compare_values (pspp_coeff_get_value (coefs[j], v),
- val, v
ar_get_width (v)
) != 0)
+ val, v) != 0)
{
j++;
}
{
j++;
}
diff --git
a/src/math/covariance-matrix.c
b/src/math/covariance-matrix.c
index 5414379119d1cecba94bf342c877209f58fc9b2f..f929a370cf5470456ba0c33018a7f292d2e4e3a4 100644
(file)
--- a/
src/math/covariance-matrix.c
+++ b/
src/math/covariance-matrix.c
@@
-74,7
+74,7
@@
column_iterate (struct design_matrix *cov, const struct variable *v,
col += i;
y = -1.0 * cat_get_category_count (i, v) / ssize;
tmp_val = cat_subscript_to_value (i, v);
col += i;
y = -1.0 * cat_get_category_count (i, v) / ssize;
tmp_val = cat_subscript_to_value (i, v);
- if (compare_values (tmp_val, val1, v
ar_get_width (v)
))
+ if (compare_values (tmp_val, val1, v))
{
y += -1.0;
}
{
y += -1.0;
}
@@
-106,7
+106,7
@@
void covariance_pass_two (struct design_matrix *cov, double mean1, double mean2,
row += i;
x = -1.0 * cat_get_category_count (i, v1) / ssize;
tmp_val = cat_subscript_to_value (i, v1);
row += i;
x = -1.0 * cat_get_category_count (i, v1) / ssize;
tmp_val = cat_subscript_to_value (i, v1);
- if (compare_values (tmp_val, val1, v
ar_get_width (v1)
))
+ if (compare_values (tmp_val, val1, v
1
))
{
x += 1.0;
}
{
x += 1.0;
}
diff --git
a/src/math/group.c
b/src/math/group.c
index 29c5ab23db4b7bde28a7c7f2657dba7ede4e8533..6101c350e483457f372a6f6ca7ae3d1aec16a385 100644
(file)
--- a/
src/math/group.c
+++ b/
src/math/group.c
@@
-29,21
+29,24
@@
/* Return -1 if the id of a is less than b; +1 if greater than and
0 if equal */
int
/* Return -1 if the id of a is less than b; +1 if greater than and
0 if equal */
int
-compare_group (const
struct group_statistics *a
,
- const
struct group_statistics *b
,
-
int width
)
+compare_group (const
void *a_
,
+ const
void *b_
,
+
const void *var
)
{
{
- return compare_values(&a->id, &b->id, width);
+ const struct group_statistics *a = a_;
+ const struct group_statistics *b = b_;
+ return compare_values(&a->id, &b->id, var);
}
}
-unsigned
-hash_group (const
struct group_statistics *g, int width
)
+unsigned
int
+hash_group (const
void *g_, const void *var
)
{
unsigned id_hash;
{
unsigned id_hash;
+ const struct group_statistics *g = g_;;
- id_hash = hash_value(&g->id,
width
);
+ id_hash = hash_value(&g->id,
var
);
return id_hash;
}
return id_hash;
}
diff --git
a/src/math/group.h
b/src/math/group.h
index bc82c8ab8234424853cf2672764277145a22d90b..c5470b2578f2a1948e66a1ca6e6ae220d1616ecb 100644
(file)
--- a/
src/math/group.h
+++ b/
src/math/group.h
@@
-18,10
+18,8
@@
#ifndef GROUP_H
#define GROUP_H
#ifndef GROUP_H
#define GROUP_H
-
#include <data/value.h>
#include <data/value.h>
-
/* Statistics for grouped data */
struct group_statistics
{
/* Statistics for grouped data */
struct group_statistics
{
@@
-67,17
+65,17
@@
struct group_statistics
};
};
-
+struct variable ;
/* These funcs are useful for hash tables */
/* Return -1 if the id of a is less than b; +1 if greater than and
0 if equal */
/* These funcs are useful for hash tables */
/* Return -1 if the id of a is less than b; +1 if greater than and
0 if equal */
-int compare_group (const
struct group_statistics
*a,
- const
struct group_statistics
*b,
-
int width
);
+int compare_group (const
void
*a,
+ const
void
*b,
+
const void *var
);
-unsigned
hash_group (const struct group_statistics *g, int width
);
+unsigned
int hash_group (const void *g, const void *var
);
void free_group (struct group_statistics *v, void *aux);
void free_group (struct group_statistics *v, void *aux);
diff --git
a/src/ui/gui/find-dialog.c
b/src/ui/gui/find-dialog.c
index 5d98b4ac91ccc0f22a783643825cc2a66bc444e4..7764d04a9633b2cac6aed1decddbd858e45bd830 100644
(file)
--- a/
src/ui/gui/find-dialog.c
+++ b/
src/ui/gui/find-dialog.c
@@
-464,7
+464,7
@@
value_compare (const struct comparator *cmptr,
const union value *v)
{
const struct value_comparator *vc = (const struct value_comparator *) cmptr;
const union value *v)
{
const struct value_comparator *vc = (const struct value_comparator *) cmptr;
- return 0 == compare_values (v, vc->pattern,
var_get_width (cmptr->var)
);
+ return 0 == compare_values (v, vc->pattern,
cmptr->var
);
}
}