X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata-list.c;h=3d730939b3e4a854af4da91bda81639685af530c;hb=1339492699ce7e12c9bf9fa17f9d60a66024cbd1;hp=756fedc8b29219657be598771fe443cb53d8e571;hpb=20fd432b34d65999f06fabfa8e9c3f5efbac41bd;p=pspp diff --git a/src/data-list.c b/src/data-list.c index 756fedc8b2..3d730939b3 100644 --- a/src/data-list.c +++ b/src/data-list.c @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "data-list.h" @@ -65,7 +65,7 @@ struct dls_var_spec int fc, lc; /* Column numbers in record. */ /* Free format only. */ - char name[9]; /* Name of variable. */ + char name[LONG_NAME_LEN + 1]; /* Name of variable. */ }; /* Constants for DATA LIST type. */ @@ -278,8 +278,7 @@ cmd_data_list (void) add_transformation (&new_pgm->h); } else - vfm_source = create_case_source (&data_list_source_class, - default_dict, dls); + vfm_source = create_case_source (&data_list_source_class, dls); return CMD_SUCCESS; @@ -350,7 +349,7 @@ parse_fixed (struct data_list_pgm *dls) while (lex_match ('/')) { fx.recno++; - if (lex_integer_p ()) + if (lex_is_integer ()) { if (lex_integer () < fx.recno) { @@ -371,7 +370,7 @@ parse_fixed (struct data_list_pgm *dls) if (!parse_DATA_LIST_vars (&fx.name, &fx.name_cnt, PV_NONE)) return 0; - if (token == T_NUM) + if (lex_is_number ()) { if (!fixed_parse_compatible (&fx, &dls->first, &dls->last)) goto fail; @@ -384,7 +383,7 @@ parse_fixed (struct data_list_pgm *dls) else { msg (SE, _("SPSS-like or FORTRAN-like format " - "specification expected after variable names.")); + "specification expected after variable names.")); goto fail; } @@ -501,7 +500,7 @@ fixed_parse_compatible (struct fixed_parsing_state *fx, else input.type = FMT_F; - if (lex_integer_p ()) + if (lex_is_integer ()) { if (lex_integer () < 1) { @@ -535,7 +534,7 @@ fixed_parse_compatible (struct fixed_parsing_state *fx, input.type = FMT_F; input.d = 0; } - if (!check_input_specifier (&input)) + if (!check_input_specifier (&input, 1)) return 0; /* Start column for next specification. */ @@ -713,7 +712,7 @@ fixed_parse_fortran_internal (struct fixed_parsing_state *fx, tail = new; /* Parse count. */ - if (lex_integer_p ()) + if (lex_is_integer ()) { new->count = lex_integer (); lex_get (); @@ -731,8 +730,8 @@ fixed_parse_fortran_internal (struct fixed_parsing_state *fx, } else if (lex_match ('/')) new->f.type = FMT_NEWREC; - else if (!parse_format_specifier (&new->f, 1) - || !check_input_specifier (&new->f)) + else if (!parse_format_specifier (&new->f, FMTP_ALLOW_XT) + || !check_input_specifier (&new->f, 1)) goto fail; lex_match (','); @@ -842,10 +841,11 @@ parse_free (struct dls_var_spec **first, struct dls_var_spec **last) if (!parse_DATA_LIST_vars (&name, &name_cnt, PV_NONE)) return 0; + if (lex_match ('(')) { if (!parse_format_specifier (&input, 0) - || !check_input_specifier (&input) + || !check_input_specifier (&input, 1) || !lex_force_match (')')) { for (i = 0; i < name_cnt; i++) @@ -874,6 +874,7 @@ parse_free (struct dls_var_spec **first, struct dls_var_spec **last) struct variable *v; v = dict_create_var (default_dict, name[i], width); + if (!v) { msg (SE, _("%s is a duplicate variable name."), name[i]); @@ -888,7 +889,7 @@ parse_free (struct dls_var_spec **first, struct dls_var_spec **last) spec->input = input; spec->v = v; spec->fv = v->fv; - strcpy (spec->name, name[i]); + st_trim_copy (spec->name, v->name, sizeof spec->name); append_var_spec (first, last, spec); } for (i = 0; i < name_cnt; i++) @@ -956,10 +957,10 @@ dump_free_table (const struct data_list_pgm *dls, a 1-based column number indicating the beginning of the field on success. */ static int -cut_field (const struct data_list_pgm *dls, struct len_string *field, +cut_field (const struct data_list_pgm *dls, struct fixed_string *field, int *end_blank) { - struct len_string line; + struct fixed_string line; char *cp; size_t column_start; @@ -1094,7 +1095,7 @@ read_from_data_list_fixed (const struct data_list_pgm *dls, return -2; for (i = 1; i <= dls->rec_cnt; i++) { - struct len_string line; + struct fixed_string line; if (dfm_eof (dls->reader)) { @@ -1113,7 +1114,7 @@ read_from_data_list_fixed (const struct data_list_pgm *dls, data_in_finite_line (&di, ls_c_str (&line), ls_length (&line), var_spec->fc, var_spec->lc); di.v = case_data_rw (c, var_spec->fv); - di.flags = 0; + di.flags = DI_IMPLIED_DECIMALS; di.f1 = var_spec->fc; di.format = var_spec->input; @@ -1138,7 +1139,7 @@ read_from_data_list_free (const struct data_list_pgm *dls, for (var_spec = dls->first; var_spec; var_spec = var_spec->next) { - struct len_string field; + struct fixed_string field; int column; /* Cut out a field and read in a new record if necessary. */ @@ -1189,7 +1190,7 @@ read_from_data_list_list (const struct data_list_pgm *dls, for (var_spec = dls->first; var_spec; var_spec = var_spec->next) { - struct len_string field; + struct fixed_string field; int column; /* Cut out a field and check for end-of-line. */ @@ -1690,7 +1691,7 @@ parse_num_or_var (struct rpd_num_or_var *value, const char *message) return 0; } } - else if (lex_integer_p ()) + else if (lex_is_integer ()) { value->num = lex_integer (); @@ -1725,7 +1726,7 @@ parse_repeating_data (struct dls_var_spec **first, struct dls_var_spec **last) if (!parse_DATA_LIST_vars (&fx.name, &fx.name_cnt, PV_NONE)) return 0; - if (token == T_NUM) + if (lex_is_number ()) { if (!fixed_parse_compatible (&fx, first, last)) goto fail; @@ -1911,7 +1912,7 @@ repeating_data_trns_proc (struct trns_header *trns, struct ccase *c, { struct repeating_data_trns *t = (struct repeating_data_trns *) trns; - struct len_string line; /* Current record. */ + struct fixed_string line; /* Current record. */ int starts_beg; /* Starting column. */ int starts_end; /* Ending column. */