X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdata-io%2Fmatrix-data.c;h=83490d4db824fe67756d7c1fc824971bcb815003;hb=8011f9998ed6cc3cd8948d080a1b7e36d932e5c5;hp=4ae4ef70cd7b13ced5138a1d71a549e65e66b94b;hpb=72c9c6a2f92e94779b2e55d0726568090411871c;p=pspp diff --git a/src/language/data-io/matrix-data.c b/src/language/data-io/matrix-data.c index 4ae4ef70cd..83490d4db8 100644 --- a/src/language/data-io/matrix-data.c +++ b/src/language/data-io/matrix-data.c @@ -837,11 +837,13 @@ parse_matrix_data_variables (struct lexer *lexer) size_t n_names = 0; char **names = NULL; + int vars_start = lex_ofs (lexer); if (!parse_DATA_LIST_vars (lexer, dict, &names, &n_names, PV_NO_DUPLICATE)) { dict_unref (dict); return NULL; } + int vars_end = lex_ofs (lexer) - 1; for (size_t i = 0; i < n_names; i++) if (!strcasecmp (names[i], "ROWTYPE_")) @@ -858,7 +860,8 @@ parse_matrix_data_variables (struct lexer *lexer) if (dict_lookup_var (dict, "VARNAME_")) { - msg (SE, _("VARIABLES may not include VARNAME_.")); + lex_ofs_error (lexer, vars_start, vars_end, + _("VARIABLES may not include VARNAME_.")); dict_unref (dict); return NULL; } @@ -871,8 +874,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 +885,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); @@ -888,8 +894,9 @@ parse_matrix_data_subvars (struct lexer *lexer, struct dictionary *dict, bool *tv = &taken_vars[var_get_dict_index (v)]; if (*tv) { - msg (SE, _("%s may not appear on both SPLIT and FACTORS."), - var_get_name (v)); + lex_ofs_error (lexer, start_ofs, end_ofs, + _("%s may not appear on both SPLIT and FACTORS."), + var_get_name (v)); goto error; } *tv = true; @@ -911,9 +918,11 @@ error: int cmd_matrix_data (struct lexer *lexer, struct dataset *ds) { + int input_vars_start = lex_ofs (lexer); struct dictionary *dict = parse_matrix_data_variables (lexer); if (!dict) return CMD_FAILURE; + int input_vars_end = lex_ofs (lexer) - 1; size_t n_input_vars = dict_get_n_vars (dict); struct variable **input_vars = xnmalloc (n_input_vars, sizeof *input_vars); @@ -951,6 +960,8 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) taken_vars[var_get_dict_index (rowtype)] = true; struct file_handle *fh = NULL; + int n_start = 0; + int n_end = 0; while (lex_token (lexer) != T_ENDCMD) { if (!lex_force_match (lexer, T_SLASH)) @@ -958,16 +969,19 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) if (lex_match_id (lexer, "N")) { + n_start = lex_ofs (lexer) - 1; lex_match (lexer, T_EQUALS); if (!lex_force_int_range (lexer, "N", 0, INT_MAX)) goto error; mf.n = lex_integer (lexer); + n_end = lex_ofs (lexer); lex_get (lexer); } else if (lex_match_id (lexer, "FORMAT")) { + int start_ofs = lex_ofs (lexer) - 1; lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD) @@ -992,6 +1006,15 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) goto error; } } + int end_ofs = lex_ofs (lexer) - 1; + + if (mf.diagonal == NO_DIAGONAL && mf.triangle == FULL) + { + lex_ofs_error (lexer, start_ofs, end_ofs, + _("FORMAT=FULL and FORMAT=NODIAGONAL are " + "mutually exclusive.")); + goto error; + } } else if (lex_match_id (lexer, "FILE")) { @@ -1099,11 +1122,6 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) goto error; } } - if (mf.diagonal == NO_DIAGONAL && mf.triangle == FULL) - { - msg (SE, _("FORMAT=FULL and FORMAT=NODIAGONAL are mutually exclusive.")); - goto error; - } if (!mf.input_rowtype) { if (mf.cells < 0) @@ -1138,7 +1156,8 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) } if (!mf.n_cvars) { - msg (SE, _("At least one continuous variable is required.")); + lex_ofs_error (lexer, input_vars_start, input_vars_end, + _("At least one continuous variable is required.")); goto error; } if (mf.input_rowtype) @@ -1146,15 +1165,18 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) for (size_t i = 0; i < mf.n_cvars; i++) if (mf.cvars[i] != input_vars[n_input_vars - mf.n_cvars + i]) { - msg (SE, _("VARIABLES includes ROWTYPE_ but the continuous " - "variables are not the last ones on VARIABLES.")); + lex_ofs_error (lexer, input_vars_start, input_vars_end, + _("VARIABLES includes ROWTYPE_ but the continuous " + "variables are not the last ones on VARIABLES.")); goto error; } } unsigned int rowtype_mask = mf.pooled_rowtype_mask | mf.factor_rowtype_mask; if (rowtype_mask & (1u << C_N) && mf.n >= 0) { - msg (SE, _("Cannot specify N on CONTENTS along with the N subcommand.")); + lex_ofs_error (lexer, n_start, n_end, + _("Cannot specify N on CONTENTS along with the " + "N subcommand.")); goto error; }