struct matrix_reader
{
- const struct dictionary *dict;
const struct variable *varname;
const struct variable *rowtype;
struct casegrouper *grouper;
{
struct matrix_reader *mr = xzalloc (sizeof *mr);
- mr->dict = dict;
mr->varname = dict_lookup_var (dict, "varname_");
if (mr->varname == NULL)
{
return NULL;
}
+ if (!var_is_alpha (mr->varname))
+ {
+ msg (ME, _("Matrix dataset variable %s should be of string type."),
+ "VARNAME_");
+ free (mr);
+ return NULL;
+ }
+
mr->rowtype = dict_lookup_var (dict, "rowtype_");
if (mr->rowtype == NULL)
{
return NULL;
}
+ if (!var_is_alpha (mr->rowtype))
+ {
+ msg (ME, _("Matrix dataset variable %s should be of string type."),
+ "ROWTYPE_");
+ free (mr);
+ return NULL;
+ }
+
size_t dvarcnt;
const struct variable **dvars = NULL;
dict_get_vars (dict, &dvars, &dvarcnt, DC_SCRATCH);
for (i = 0; i < n_vars; ++i)
{
const int w = var_get_width (mr->varname);
- uint8_t s[w];
+ char s[w];
memset (s, 0, w);
const char *name = var_get_name (vars[i]);
- strcpy (s, name);
+ strncpy (s, name, w);
unsigned long h = hash_bytes (s, w, 0);
table[i] = h;
}
int col, row;
for (col = 0; col < n_vars; ++col)
{
- const struct variable *cv
- = vars ? vars[col] : dict_get_var (mr->dict, var_get_dict_index (mr->varname) + 1 + col);
+ const struct variable *cv = vars[col];
double x = case_data (c, cv)->f;
if (0 == strncasecmp ((char *)value_str (uv, 8), "N ", 8))
for (row = 0; row < n_vars; ++row)