projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change "union value" to dynamically allocate long strings.
[pspp-builds.git]
/
src
/
data
/
variable.c
diff --git
a/src/data/variable.c
b/src/data/variable.c
index 30cf03b134666cf8f6db1f457c8e3733b0b311e9..730317b7d26599215b4a18e24a24769d10b74304 100644
(file)
--- a/
src/data/variable.c
+++ b/
src/data/variable.c
@@
-36,6
+36,7
@@
#include <libpspp/message.h>
#include <libpspp/str.h>
#include <libpspp/message.h>
#include <libpspp/str.h>
+#include "minmax.h"
#include "xalloc.h"
#include "gettext.h"
#include "xalloc.h"
#include "gettext.h"
@@
-323,7
+324,7
@@
hash_var_by_name (const void *v_, const void *aux UNUSED)
{
const struct variable *v = v_;
{
const struct variable *v = v_;
- return h
sh_hash_case_string (v->name
);
+ return h
ash_case_string (v->name, 0
);
}
/* A hsh_compare_func that orders pointers to variables A and B
}
/* A hsh_compare_func that orders pointers to variables A and B
@@
-359,7
+360,7
@@
hash_var_ptr_by_name (const void *v_, const void *aux UNUSED)
{
struct variable *const *v = v_;
{
struct variable *const *v = v_;
- return h
sh_hash_case_string (var_get_name (*v)
);
+ return h
ash_case_string (var_get_name (*v), 0
);
}
\f
/* Returns the type of variable V. */
}
\f
/* Returns the type of variable V. */
@@
-383,6
+384,9
@@
var_set_width (struct variable *v, int new_width)
{
const int old_width = v->width;
{
const int old_width = v->width;
+ if (old_width == new_width)
+ return;
+
if (mv_is_resizable (&v->miss, new_width))
mv_resize (&v->miss, new_width);
else
if (mv_is_resizable (&v->miss, new_width))
mv_resize (&v->miss, new_width);
else
@@
-403,15
+407,7
@@
var_set_width (struct variable *v, int new_width)
fmt_resize (&v->write, new_width);
v->width = new_width;
fmt_resize (&v->write, new_width);
v->width = new_width;
-
- {
- const int old_val_count = value_cnt_from_width (old_width);
- const int new_val_count = value_cnt_from_width (new_width);
-
- if ( old_val_count != new_val_count)
- dict_var_resized (v, new_val_count - old_val_count);
- }
-
+ dict_var_resized (v, old_width);
dict_var_changed (v);
}
dict_var_changed (v);
}
@@
-445,14
+441,6
@@
var_is_long_string (const struct variable *v)
{
return v->width > MAX_SHORT_STRING;
}
{
return v->width > MAX_SHORT_STRING;
}
-
-/* Returns the number of "union value"s need to store a value of
- variable V. */
-size_t
-var_get_value_cnt (const struct variable *v)
-{
- return value_cnt_from_width (v->width);
-}
\f
/* Returns variable V's missing values. */
const struct missing_values *
\f
/* Returns variable V's missing values. */
const struct missing_values *
@@
-575,7
+563,7
@@
var_add_value_label (struct variable *v,
const union value *value, const char *label)
{
alloc_value_labels (v);
const union value *value, const char *label)
{
alloc_value_labels (v);
- return val_labs_add (v->val_labs,
*
value, label);
+ return val_labs_add (v->val_labs, value, label);
}
/* Adds or replaces a value label with the given VALUE and LABEL
}
/* Adds or replaces a value label with the given VALUE and LABEL
@@
-586,7
+574,7
@@
var_replace_value_label (struct variable *v,
const union value *value, const char *label)
{
alloc_value_labels (v);
const union value *value, const char *label)
{
alloc_value_labels (v);
- val_labs_replace (v->val_labs,
*
value, label);
+ val_labs_replace (v->val_labs, value, label);
}
/* Removes V's value labels, if any. */
}
/* Removes V's value labels, if any. */
@@
-601,7
+589,7
@@
var_clear_value_labels (struct variable *v)
const char *
var_lookup_value_label (const struct variable *v, const union value *value)
{
const char *
var_lookup_value_label (const struct variable *v, const union value *value)
{
- return val_labs_find (v->val_labs,
*
value);
+ return val_labs_find (v->val_labs, value);
}
/* Append STR with a string representing VALUE for variable V.
}
/* Append STR with a string representing VALUE for variable V.
@@
-720,8
+708,8
@@
var_set_label (struct variable *v, const char *label)
ss_truncate (&s, 255);
if (!ss_is_empty (s))
v->label = ss_xstrdup (s);
ss_truncate (&s, 255);
if (!ss_is_empty (s))
v->label = ss_xstrdup (s);
- dict_var_changed (v);
}
}
+ dict_var_changed (v);
}
/* Removes any variable label from V. */
}
/* Removes any variable label from V. */