SET: Improve error messages for SET CCx.
[pspp] / src / language / data-io / matrix-data.c
index f741b4d54cc2808b59488d5caec39865c82aa813..56f691bf7c577291a1310bdaddd58ca9ade4ecd6 100644 (file)
@@ -871,8 +871,10 @@ parse_matrix_data_subvars (struct lexer *lexer, struct dictionary *dict,
                            struct variable ***vars, size_t **indexes,
                            size_t *n_vars)
 {
+  int start_ofs = lex_ofs (lexer);
   if (!parse_variables (lexer, dict, vars, n_vars, 0))
     return false;
+  int end_ofs = lex_ofs (lexer) - 1;
 
   *indexes = xnmalloc (*n_vars, sizeof **indexes);
   for (size_t i = 0; i < *n_vars; i++)
@@ -880,7 +882,8 @@ parse_matrix_data_subvars (struct lexer *lexer, struct dictionary *dict,
       struct variable *v = (*vars)[i];
       if (!strcasecmp (var_get_name (v), "ROWTYPE_"))
         {
-          msg (SE, _("ROWTYPE_ is not allowed on SPLIT or FACTORS."));
+          lex_ofs_error (lexer, start_ofs, end_ofs,
+                         _("ROWTYPE_ is not allowed on SPLIT or FACTORS."));
           goto error;
         }
       (*indexes)[i] = var_get_dict_index (v);
@@ -1033,7 +1036,9 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds)
       else if (lex_match_id (lexer, "CELLS"))
        {
           if (mf.input_rowtype)
-            msg (SW, _("CELLS is ignored when VARIABLES includes ROWTYPE_"));
+            lex_next_msg (lexer, SW,
+                          -1, -1, _("CELLS is ignored when VARIABLES "
+                                    "includes ROWTYPE_"));
 
          lex_match (lexer, T_EQUALS);
 
@@ -1058,7 +1063,14 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds)
                   if (open || in_parens || (lex_token (lexer) != T_ENDCMD
                                             && lex_token (lexer) != T_SLASH))
                     {
-                      lex_error (lexer, _("Row type keyword expected."));
+                      const char *rowtypes[] = {
+#define RT(NAME, DIMS) #NAME,
+                        ROWTYPES
+#undef RT
+                        "N_VECTOR", "SD",
+                      };
+                      lex_error_expecting_array (
+                        lexer, rowtypes, sizeof rowtypes / sizeof *rowtypes);
                       goto error;
                     }
                   break;