projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added the ability to resize string variables from the GUI. Thanks to
[pspp-builds.git]
/
src
/
data
/
variable.c
diff --git
a/src/data/variable.c
b/src/data/variable.c
index aa65606f02652d826b976a7f0a423cfb3b16b3f9..a10a8adea7ec03cbf60fd7cde4633f8fa5c7c167 100644
(file)
--- a/
src/data/variable.c
+++ b/
src/data/variable.c
@@
-29,6
+29,7
@@
#include "value-labels.h"
#include "vardict.h"
#include "value-labels.h"
#include "vardict.h"
+#include <libpspp/misc.h>
#include <libpspp/alloc.h>
#include <libpspp/assertion.h>
#include <libpspp/compiler.h>
#include <libpspp/alloc.h>
#include <libpspp/assertion.h>
#include <libpspp/compiler.h>
@@
-349,6
+350,7
@@
var_get_width (const struct variable *v)
void
var_set_width (struct variable *v, int new_width)
{
void
var_set_width (struct variable *v, int new_width)
{
+ const int old_width = v->width;
enum var_type new_type = var_type_from_width (new_width);
if (mv_is_resizable (&v->miss, new_width))
enum var_type new_type = var_type_from_width (new_width);
if (mv_is_resizable (&v->miss, new_width))
@@
-382,6
+384,14
@@
var_set_width (struct variable *v, int new_width)
v->width = 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_changed (v);
}
dict_var_changed (v);
}