X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata-list.c;h=1a6b9af89f0699417055f34ce65bc7518e170792;hb=7b98b3a4f58f6dc5a8e9cbc188b627966d5e652d;hp=c775c8daac14ede01bd6e8b2727db870eb3edcc6;hpb=4944c86a9318bc5b5578ab145a95c116ffd2c9fd;p=pspp diff --git a/src/data-list.c b/src/data-list.c index c775c8daac..1a6b9af89f 100644 --- a/src/data-list.c +++ b/src/data-list.c @@ -17,24 +17,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* AIX requires this to be the first thing in the file. */ #include -#if __GNUC__ -#define alloca __builtin_alloca -#else -#if HAVE_ALLOCA_H -#include -#else -#ifdef _AIX -#pragma alloca -#else -#ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -#endif -#endif -#endif -#endif - #include #include #include @@ -74,7 +57,7 @@ struct dls_var_spec int fc, lc; /* Fixed-format: Column numbers in record. */ struct fmt_spec input; /* Input format of this field. */ int fv; /* First value in case. */ - int type; /* 0=numeric, >0=width of alpha field. */ + int width; /* 0=numeric, >0=width of alpha field. */ }; /* Constants for DATA LIST type. */ @@ -177,9 +160,12 @@ cmd_data_list (void) lex_match ('='); if (!lex_force_id ()) return CMD_FAILURE; - dls.end = find_variable (tokid); - if (!dls.end) - dls.end = force_create_variable (&default_dict, tokid, NUMERIC, 0); + dls.end = dict_lookup_var (default_dict, tokid); + if (!dls.end) + { + dls.end = dict_create_var (default_dict, tokid, 0); + assert (dls.end != NULL); + } lex_get (); } else if (token == T_ID) @@ -276,10 +262,6 @@ append_var_spec (struct dls_var_spec *spec) else next = next->next = xmalloc (sizeof *spec); -#if __CHECKER__ - spec->type = ROUND_UP (spec->type, 8); -#endif - memcpy (next, spec, sizeof *spec); next->next = NULL; } @@ -517,14 +499,21 @@ fixed_parse_compatible (void) for (i = 0; i < fx.nname; i++) { int type; + int width; struct variable *v; - if (fx.spec.input.type == FMT_A || fx.spec.input.type == FMT_AHEX) - type = ALPHA; - else - type = NUMERIC; - - v = create_variable (&default_dict, fx.name[i], type, dividend); + if (fx.spec.input.type == FMT_A || fx.spec.input.type == FMT_AHEX) + { + type = ALPHA; + width = dividend; + } + else + { + type = NUMERIC; + width = 0; + } + + v = dict_create_var (default_dict, fx.name[i], width); if (v) { convert_fmt_ItoO (&fx.spec.input, &v->print); @@ -532,8 +521,8 @@ fixed_parse_compatible (void) } else { - v = find_variable (fx.name[i]); - assert (v); + v = dict_lookup_var (default_dict, fx.name[i]); + assert (v != NULL); if (!vfm_source) { msg (SE, _("%s is a duplicate variable name."), fx.name[i]); @@ -558,7 +547,7 @@ fixed_parse_compatible (void) fx.spec.fc = fx.fc + dividend * i; fx.spec.lc = fx.spec.fc + dividend - 1; fx.spec.fv = v->fv; - fx.spec.type = v->type == NUMERIC ? 0 : v->width; + fx.spec.width = v->width; append_var_spec (&fx.spec); } return 1; @@ -607,9 +596,19 @@ dump_fmt_list (struct fmt_list *f) else { int type; + int width; struct variable *v; - type = (formats[f->f.type].cat & FCAT_STRING) ? ALPHA : NUMERIC; + if (formats[f->f.type].cat & FCAT_STRING) + { + type = ALPHA; + width = f->f.w; + } + else + { + type = NUMERIC; + width = 0; + } if (fx.cname >= fx.nname) { msg (SE, _("The number of format " @@ -618,9 +617,9 @@ dump_fmt_list (struct fmt_list *f) return 0; } - fx.spec.v = v = create_variable (&default_dict, + fx.spec.v = v = dict_create_var (default_dict, fx.name[fx.cname++], - type, f->f.w); + width); if (!v) { msg (SE, _("%s is a duplicate variable name."), fx.name[i]); @@ -635,7 +634,7 @@ dump_fmt_list (struct fmt_list *f) fx.spec.fc = fx.sc; fx.spec.lc = fx.sc + f->f.w - 1; fx.spec.fv = v->fv; - fx.spec.type = v->type == NUMERIC ? 0 : v->width; + fx.spec.width = v->width; append_var_spec (&fx.spec); fx.sc += f->f.w; @@ -755,9 +754,14 @@ dump_fixed_table (void) filename = ""; buf = local_alloc (strlen (filename) + INT_DIGITS + 80); sprintf (buf, (dls.handle != inline_file - ? _("Reading %d record%s from file %s.") - : _("Reading %d record%s from the command file.")), - dls.nrec, dls.nrec != 1 ? "s" : "", filename); + ? + ngettext("Reading %d record from file %s.", + "Reading %d records from file %s.",dls.nrec) + : + ngettext("Reading %d record from the command file.", + "Reading %d records from the command file.", + dls.nrec)), + dls.nrec, filename); } else { @@ -781,14 +785,12 @@ parse_free (void) char **name; int nname; int i; - int type; -#if __CHECKER__ - memset (&spec, 0, sizeof spec); -#endif lex_get (); while (token != '.') { + int width; + if (!parse_DATA_LIST_vars (&name, &nname, PV_NONE)) return 0; if (lex_match ('(')) @@ -810,14 +812,14 @@ parse_free (void) spec.input = in; if (in.type == FMT_A || in.type == FMT_AHEX) - type = ALPHA; + width = in.w; else - type = NUMERIC; + width = 0; for (i = 0; i < nname; i++) { struct variable *v; - spec.v = v = create_variable (&default_dict, name[i], type, in.w); + spec.v = v = dict_create_var (default_dict, name[i], width); if (!v) { msg (SE, _("%s is a duplicate variable name."), name[i]); @@ -828,7 +830,7 @@ parse_free (void) strcpy (spec.name, name[i]); spec.fv = v->fv; - spec.type = type == NUMERIC ? 0 : v->width; + spec.width = width; append_var_spec (&spec); } for (i = 0; i < nname; i++) @@ -1034,9 +1036,6 @@ do_reading (int flag) break; } fh_close_handle (dlsp->handle); -#if __CHECKER__ - code = 0; /* prevent error at `return code;' */ -#endif } dfm_pop (dlsp->handle); @@ -1156,10 +1155,10 @@ read_from_data_list_list (void) "or blanks, as appropriate."), var_spec->name); for (; var_spec; var_spec = var_spec->next) - if (!var_spec->type) + if (var_spec->width == 0) temp_case->data[var_spec->fv].f = SYSMIS; else - memset (temp_case->data[var_spec->fv].s, ' ', var_spec->type); + memset (temp_case->data[var_spec->fv].s, ' ', var_spec->width); break; } @@ -1200,7 +1199,7 @@ destroy_dls (struct trns_header *pgm) /* Note that since this is exclusively an input program, C is guaranteed to be temp_case. */ static int -read_one_case (struct trns_header *t, struct ccase *c unused) +read_one_case (struct trns_header *t, struct ccase *c UNUSED) { dlsp = (struct data_list_pgm *) t; return do_reading (1); @@ -1319,7 +1318,7 @@ cmd_repeating_data (void) lex_match ('='); if (seen & 1) { - msg (SE, _("STARTS subcommand given multiple times.")); + msg (SE, _("%s subcommand given multiple times."),"STARTS"); return CMD_FAILURE; } seen |= 1; @@ -1354,7 +1353,7 @@ cmd_repeating_data (void) lex_match ('='); if (seen & 2) { - msg (SE, _("OCCURS subcommand given multiple times.")); + msg (SE, _("%s subcommand given multiple times."),"OCCURS"); return CMD_FAILURE; } seen |= 2; @@ -1367,7 +1366,7 @@ cmd_repeating_data (void) lex_match ('='); if (seen & 4) { - msg (SE, _("LENGTH subcommand given multiple times.")); + msg (SE, _("%s subcommand given multiple times."),"LENGTH"); return CMD_FAILURE; } seen |= 4; @@ -1380,7 +1379,7 @@ cmd_repeating_data (void) lex_match ('='); if (seen & 8) { - msg (SE, _("CONTINUED subcommand given multiple times.")); + msg (SE, _("%s subcommand given multiple times."),"CONTINUED"); return CMD_FAILURE; } seen |= 8; @@ -1413,7 +1412,7 @@ cmd_repeating_data (void) lex_match ('='); if (seen & 16) { - msg (SE, _("ID subcommand given multiple times.")); + msg (SE, _("%s subcommand given multiple times."),"ID"); return CMD_FAILURE; } seen |= 16; @@ -1766,7 +1765,7 @@ rpd_parse_record (int beg, int end, int ofs, struct ccase *c, warned = 1; tmsg (SW, RPD_ERR, - _("Variable %s startging in column %d extends " + _("Variable %s starting in column %d extends " "beyond physical record length of %d."), var_spec->v->name, fc, len); }