1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include <sys/types.h>
25 #include <libpspp/alloc.h>
26 #include <language/command.h>
27 #include <libpspp/message.h>
28 #include <language/lexer/lexer.h>
29 #include <data/settings.h>
30 #include "sort-criteria.h"
31 #include <math/sort.h>
32 #include <data/variable.h>
35 #define _(msgid) gettext (msgid)
38 /* Performs the SORT CASES procedures. */
42 struct sort_criteria *criteria;
47 criteria = sort_parse_criteria (default_dict, NULL, NULL, NULL, NULL);
49 return CMD_CASCADING_FAILURE;
51 if (get_testing_mode () && lex_match ('/'))
53 if (!lex_force_match_id ("BUFFERS") || !lex_match ('=')
57 min_buffers = max_buffers = lex_integer ();
58 allow_internal_sort = false;
61 msg (SE, _("Buffer limit must be at least 2."));
68 success = sort_active_file_in_place (criteria);
72 max_buffers = INT_MAX;
73 allow_internal_sort = true;
75 sort_destroy_criteria (criteria);
76 return success ? lex_end_of_command () : CMD_CASCADING_FAILURE;