#include <data/value-labels.h>
#include <data/format.h>
+#include <libpspp/misc.h>
+
#include "psppire-variable.h"
#include "psppire-dict.h"
fmt.w = width;
if ( pv->v->type == ALPHA )
+ {
+ gint old_var_cnt , new_var_cnt ;
+
+ if ( pv->v->width == 0 )
+ old_var_cnt = 1;
+ else
+ old_var_cnt = DIV_RND_UP(pv->v->width, MAX_SHORT_STRING);
+
+ new_var_cnt = DIV_RND_UP(width, MAX_SHORT_STRING);
pv->v->width = width;
+ psppire_dict_resize_variable(pv->dict, pv,
+ old_var_cnt, new_var_cnt);
+ }
+
return psppire_variable_set_format(pv, &fmt);
}
gboolean
psppire_variable_set_type(struct PsppireVariable *pv, int type)
{
+ gint old_var_cnt , new_var_cnt ;
+
g_return_val_if_fail(pv, FALSE);
g_return_val_if_fail(pv->dict, FALSE);
g_return_val_if_fail(pv->v, FALSE);
pv->v->type = type;
+ if ( pv->v->width == 0 )
+ old_var_cnt = 1;
+ else
+ old_var_cnt = DIV_RND_UP(pv->v->width, MAX_SHORT_STRING);
+
if ( type == NUMERIC )
pv->v->width = 0;
+ if ( pv->v->width == 0 )
+ new_var_cnt = 1;
+ else
+ new_var_cnt = DIV_RND_UP(pv->v->width, MAX_SHORT_STRING);
+
+ psppire_dict_resize_variable(pv->dict, pv,
+ old_var_cnt, new_var_cnt);
+
psppire_dict_var_changed(pv->dict, pv->v->index);
return TRUE;
}
}
-/* FIXME: This name is misleading */
gint
-psppire_variable_get_index(const struct PsppireVariable *pv)
+psppire_variable_get_fv(const struct PsppireVariable *pv)
{
g_return_val_if_fail(pv, -1);
g_return_val_if_fail(pv->v, -1);
return pv->v->fv;
}
+
+
+gint
+psppire_variable_get_index(const struct PsppireVariable *pv)
+{
+ g_return_val_if_fail(pv, -1);
+ g_return_val_if_fail(pv->v, -1);
+
+ return pv->v->index;
+}
+