X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fsort-cases.c;h=86c31f854b2832738ee33a7169f4836208b8efe9;hb=f5c108becd49d78f4898cab11352291f5689d24e;hp=be8e3235070634dadbf6cd7692ba3f8049506ba2;hpb=244ade48f9c233532cc535d3233fdef53bf9266b;p=pspp-builds.git diff --git a/src/language/stats/sort-cases.c b/src/language/stats/sort-cases.c index be8e3235..86c31f85 100644 --- a/src/language/stats/sort-cases.c +++ b/src/language/stats/sort-cases.c @@ -1,6 +1,5 @@ /* PSPP - computes sample statistics. Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. - Written by Ben Pfaff . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -31,6 +30,7 @@ #include #include #include +#include #include #include @@ -40,42 +40,46 @@ /* Performs the SORT CASES procedures. */ int -cmd_sort_cases (struct dataset *ds) +cmd_sort_cases (struct lexer *lexer, struct dataset *ds) { - struct sort_criteria *criteria; - bool success = false; + struct case_ordering *ordering; + struct casereader *output; + bool ok = false; - lex_match (T_BY); + lex_match (lexer, T_BY); - criteria = sort_parse_criteria (dataset_dict (ds), NULL, NULL, NULL, NULL); - if (criteria == NULL) + proc_cancel_temporary_transformations (ds); + ordering = parse_case_ordering (lexer, dataset_dict (ds), NULL); + if (ordering == NULL) return CMD_CASCADING_FAILURE; - if (get_testing_mode () && lex_match ('/')) + if (get_testing_mode () && lex_match (lexer, '/')) { - if (!lex_force_match_id ("BUFFERS") || !lex_match ('=') - || !lex_force_int ()) + if (!lex_force_match_id (lexer, "BUFFERS") || !lex_match (lexer, '=') + || !lex_force_int (lexer)) goto done; - min_buffers = max_buffers = lex_integer (); - allow_internal_sort = false; - if (max_buffers < 2) + min_buffers = max_buffers = lex_integer (lexer); + if (max_buffers < 2) { msg (SE, _("Buffer limit must be at least 2.")); goto done; } - lex_get (); + lex_get (lexer); } - success = sort_active_file_in_place (ds, criteria); + proc_discard_output (ds); + output = sort_execute (proc_open (ds), ordering); + ordering = NULL; + ok = proc_commit (ds); + ok = proc_set_active_file_data (ds, output) && ok; done: min_buffers = 64; max_buffers = INT_MAX; - allow_internal_sort = true; - - sort_destroy_criteria (criteria); - return success ? lex_end_of_command () : CMD_CASCADING_FAILURE; + + case_ordering_destroy (ordering); + return ok ? lex_end_of_command (lexer) : CMD_CASCADING_FAILURE; }