X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fautorecode.c;h=e7d06a818ddfa7c8d860943d82d492696d0d9111;hb=d416357a9e9c23251ff1357f0f1c3ba5ac48223e;hp=f6ea46241634e3d9b0d8e14db119e7bdadd532fe;hpb=6e097c89af440da90b43ce90864394c4d0c843d5;p=pspp diff --git a/src/language/stats/autorecode.c b/src/language/stats/autorecode.c index f6ea462416..e7d06a818d 100644 --- a/src/language/stats/autorecode.c +++ b/src/language/stats/autorecode.c @@ -105,7 +105,7 @@ static bool value_is_blank (const union value *val, int width, const struct dictionary *dict) { mbi_iterator_t iter; - const char *str = CHAR_CAST_BUG (const char*, value_str (val, width)); + const char *str = CHAR_CAST_BUG (const char *, val->s); char *text = recode_string (UTF8, dict_get_encoding (dict), str, width); for (mbi_init (iter, text, width); mbi_avail (iter); mbi_advance (iter)) @@ -140,7 +140,6 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) struct casereader *input; struct ccase *c; - size_t i; bool ok; /* Create procedure. */ @@ -168,7 +167,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) goto error; } - for (i = 0; i < n_dsts; i++) + for (size_t i = 0; i < n_dsts; i++) { const char *name = dst_names[i]; @@ -207,10 +206,16 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) arc->blank_valid = false; } else - goto error; + { + lex_error_expecting (lexer, "VALID", "MISSING"); + goto error; + } } else - goto error; + { + lex_error_expecting (lexer, "DESCENDING", "PRINT", "GROUP", "BLANK"); + goto error; + } } if (lex_token (lexer) != T_ENDCMD) @@ -223,7 +228,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) arc->n_specs = n_dsts; - for (i = 0; i < n_dsts; i++) + for (size_t i = 0; i < n_dsts; i++) { struct arc_spec *spec = &arc->specs[i]; @@ -247,7 +252,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) /* Execute procedure. */ input = proc_open (ds); for (; (c = casereader_read (input)) != NULL; case_unref (c)) - for (i = 0; i < arc->n_specs; i++) + for (size_t i = 0; i < arc->n_specs; i++) { struct arc_spec *spec = &arc->specs[i]; int width = spec->width; @@ -277,7 +282,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) dict = dataset_dict (ds); /* Create transformation. */ - for (i = 0; i < arc->n_specs; i++) + for (size_t i = 0; i < arc->n_specs; i++) { struct arc_spec *spec = &arc->specs[i]; struct arc_item **items; @@ -319,7 +324,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) the source value from whence the new value comes. */ if (src_width > 0) { - const char *str = CHAR_CAST_BUG (const char*, value_str (from, src_width)); + const char *str = CHAR_CAST_BUG (const char *, from->s); recoded_value = recode_string (UTF8, dict_get_encoding (dict), str, src_width); @@ -342,7 +347,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) } add_transformation (ds, autorecode_trns_proc, autorecode_trns_free, arc); - for (i = 0; i < n_dsts; i++) + for (size_t i = 0; i < n_dsts; i++) free (dst_names[i]); free (dst_names); free (src_vars); @@ -350,7 +355,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE; error: - for (i = 0; i < n_dsts; i++) + for (size_t i = 0; i < n_dsts; i++) free (dst_names[i]); free (dst_names); free (src_vars); @@ -363,9 +368,7 @@ arc_free (struct autorecode_pgm *arc) { if (arc != NULL) { - size_t i; - - for (i = 0; i < arc->n_specs; i++) + for (size_t i = 0; i < arc->n_specs; i++) { struct arc_spec *spec = &arc->specs[i]; struct arc_item *item, *next; @@ -379,7 +382,7 @@ arc_free (struct autorecode_pgm *arc) } } - for (i = 0; i < arc->n_specs; i++) + for (size_t i = 0; i < arc->n_specs; i++) { struct arc_spec *spec = &arc->specs[i]; @@ -430,8 +433,8 @@ compare_arc_items (const void *a_, const void *b_, const void *aux UNUSED) if ( width_b == 0 && width_a != 0) return +1; - return buf_compare_rpad (CHAR_CAST_BUG (const char *, value_str (&(*a)->from, width_a)), width_a, - CHAR_CAST_BUG (const char *, value_str (&(*b)->from, width_b)), width_b); + return buf_compare_rpad (CHAR_CAST_BUG (const char *, (*a)->from.s), width_a, + CHAR_CAST_BUG (const char *, (*b)->from.s), width_b); } static int @@ -439,10 +442,9 @@ autorecode_trns_proc (void *arc_, struct ccase **c, casenumber case_idx UNUSED) { struct autorecode_pgm *arc = arc_; - size_t i; *c = case_unshare (*c); - for (i = 0; i < arc->n_specs; i++) + for (size_t i = 0; i < arc->n_specs; i++) { const struct arc_spec *spec = &arc->specs[i]; const union value *value = case_data_idx (*c, spec->src_idx);