X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Faggregate.c;h=7a2c986bf04282051a7854e1c671a097daf35565;hb=541f79a70aaecfef60022cb7ec7cfc687c94860a;hp=2a4eda87ad042092f81d3eccd93c4bb46c2f4025;hpb=9ade26c8349b4434008c46cf09bc7473ec743972;p=pspp diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index 2a4eda87ad..7a2c986bf0 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2008, 2009, 2010, 2011, 2012, 2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,10 +25,10 @@ #include "data/casegrouper.h" #include "data/casereader.h" #include "data/casewriter.h" +#include "data/dataset.h" #include "data/dictionary.h" #include "data/file-handle-def.h" #include "data/format.h" -#include "data/procedure.h" #include "data/settings.h" #include "data/subcase.h" #include "data/sys-file-writer.h" @@ -49,6 +49,7 @@ #include "math/sort.h" #include "math/statistic.h" +#include "gl/c-strcase.h" #include "gl/minmax.h" #include "gl/xalloc.h" @@ -182,7 +183,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_EQUALS); if (!lex_match (lexer, T_ASTERISK)) { - out_file = fh_parse (lexer, FH_REF_FILE | FH_REF_SCRATCH); + out_file = fh_parse (lexer, FH_REF_FILE, dataset_session (ds)); if (out_file == NULL) goto error; } @@ -208,7 +209,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) if ( agr.add_variables ) agr.dict = dict_clone (dict); else - agr.dict = dict_create (); + agr.dict = dict_create (dict_get_encoding (dict)); dict_set_label (agr.dict, dict_get_label (dict)); dict_set_documents (agr.dict, dict_get_documents (dict)); @@ -223,7 +224,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_EQUALS); if (!lex_match_id (lexer, "COLUMNWISE")) { - lex_error (lexer, _("expecting %s"), "COLUMNWISE"); + lex_error_expecting (lexer, "COLUMNWISE", NULL); goto error; } agr.missing = COLUMNWISE; @@ -275,7 +276,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) if (out_file == NULL) { - /* The active file will be replaced by the aggregated data, + /* The active dataset will be replaced by the aggregated data, so TEMPORARY is moot. */ proc_cancel_temporary_transformations (ds); proc_discard_output (ds); @@ -332,8 +333,8 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) else { dump_aggregate_info (&agr, output, c); - case_unref (c); } + case_unref (c); } if (!casegrouper_destroy (grouper)) goto error; @@ -351,7 +352,8 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) if (next_input == NULL) goto error; - proc_set_active_file (ds, next_input, agr.dict); + dataset_set_dict (ds, agr.dict); + dataset_set_source (ds, next_input); agr.dict = NULL; } else @@ -451,7 +453,7 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, exclude = ds_chomp_byte (&function_name, '.') ? MV_SYSTEM : MV_ANY; for (function = agr_func_tab; function->name; function++) - if (!strcasecmp (function->name, ds_cstr (&function_name))) + if (!c_strcasecmp (function->name, ds_cstr (&function_name))) break; if (NULL == function->name) { @@ -468,7 +470,6 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, { if (function->src_vars == AGR_SV_YES) { - lex_force_match (lexer, T_LPAREN); goto error; } } @@ -637,8 +638,7 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, free (dest[i]); if (dest_label[i]) - var_set_label (destvar, dest_label[i], - dict_get_encoding (agr->dict), true); + var_set_label (destvar, dest_label[i]); v->dest = destvar; } @@ -733,7 +733,7 @@ agr_destroy (struct agr_proc *agr) free (iter); } if (agr->dict != NULL) - dict_destroy (agr->dict); + dict_unref (agr->dict); } /* Execution. */