1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2008 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include <data/format.h>
22 #include <data/format-guesser.h>
23 #include <language/command.h>
24 #include <language/lexer/lexer.h>
25 #include <libpspp/message.h>
27 /* Executes the DEBUG FORMAT GUESSER command. */
29 cmd_debug_format_guesser (struct lexer *lexer, struct dataset *ds UNUSED)
31 struct fmt_guesser *g;
32 struct fmt_spec format;
33 char format_string[FMT_STRING_LEN_MAX + 1];
35 g = fmt_guesser_create ();
36 while (lex_token (lexer) == T_STRING)
38 fprintf (stderr, "\"%s\" ", ds_cstr (lex_tokstr (lexer)));
39 fmt_guesser_add (g, ds_ss (lex_tokstr (lexer)));
43 fmt_guesser_guess (g, &format);
44 fmt_to_string (&format, format_string);
45 fprintf (stderr, "=> %s", format_string);
47 if (!fmt_check_input (&format))
49 fmt_fix_input (&format);
50 fmt_to_string (&format, format_string);
51 fprintf (stderr, " (%s)", format_string);
56 return lex_end_of_command (lexer);