struct matrix_lvalue *lvalue = xzalloc (sizeof *lvalue);
if (!lex_force_id (s->lexer))
goto error;
+ int start_ofs = lex_ofs (s->lexer);
lvalue->var_location = lex_get_location (s->lexer, 0, 0);
lvalue->var = matrix_var_lookup (s, lex_tokss (s->lexer));
if (lex_next_token (s->lexer, 1) == T_LPAREN)
if (!lvalue->var)
{
msg (SE, _("Undefined variable %s."), lex_tokcstr (s->lexer));
- free (lvalue);
- return NULL;
+ goto error;
}
lex_get_n (s->lexer, 2);
if (!lex_force_match (s->lexer, T_RPAREN))
goto error;
- lvalue->index_location = msg_location_dup (lvalue->var_location);
- lex_extend_location (s->lexer, -1, lvalue->index_location);
+ lvalue->index_location = lex_ofs_location (s->lexer, start_ofs,
+ lex_ofs (s->lexer) - 1);
}
else
{
}
else if (dm->size1 == 0 || dm->size2 == 0)
{
- msg_at (SE, lvalue->var_location,
+ msg_at (SE, lvalue->index_location,
_("Cannot index %zu×%zu matrix."), dm->size1, dm->size2);
return false;
}
{
if (!is_vector (dm))
{
- msg_at (SE, lvalue->var_location,
+ msg_at (SE, lvalue->index_location,
_("Can't use vector indexing on %zu×%zu matrix %s."),
dm->size1, dm->size2, lvalue->var->name);
return false;