#include <stdlib.h>
+#include "data/dataset.h"
#include "data/dictionary.h"
#include "data/format.h"
#include "data/gnumeric-reader.h"
-#include "data/procedure.h"
#include "data/psql-reader.h"
#include "data/settings.h"
#include "language/command.h"
struct casereader *reader = psql_open_reader (&psql, &dict);
if ( reader )
- proc_set_active_file (ds, reader, dict);
+ {
+ dataset_set_dict (ds, dict);
+ dataset_set_source (ds, reader);
+ }
}
ds_destroy (&psql.sql);
struct casereader *reader = gnumeric_open_reader (&gri, &dict);
if ( reader )
- proc_set_active_file (ds, reader, dict);
+ {
+ dataset_set_dict (ds, dict);
+ dataset_set_source (ds, reader);
+ }
}
free (gri.file_name);
parse_get_txt (struct lexer *lexer, struct dataset *ds)
{
struct data_parser *parser = NULL;
- struct dictionary *dict = dict_create ();
+ struct dictionary *dict = dict_create (get_default_encoding ());
struct file_handle *fh = NULL;
struct dfm_reader *reader = NULL;
char *name = NULL;
if (!lex_force_match_id (lexer, "FILE"))
goto error;
lex_force_match (lexer, T_EQUALS);
- fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE);
+ fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE, NULL);
if (fh == NULL)
goto error;
if (!parse_format_specifier (lexer, &input)
|| !fmt_check_input (&input))
goto error;
+
+ output = fmt_for_output_from_input (&input);
}
else
{
+ char fmt_type_name[FMT_TYPE_LEN_MAX + 1];
+ enum fmt_type fmt_type;
+ int w, d;
+
if (!parse_column_range (lexer, 0, &fc, &lc, NULL))
goto error;
- if (!parse_format_specifier_name (lexer, &input.type))
+
+ /* Accept a format (e.g. F8.2) or just a type name (e.g. DOLLAR). */
+ if (!parse_abstract_format_specifier (lexer, fmt_type_name, &w, &d))
goto error;
+ if (!fmt_from_name (fmt_type_name, &fmt_type))
+ {
+ msg (SE, _("Unknown format type `%s'."), fmt_type_name);
+ goto error;
+ }
+
+ /* Compose input format. */
+ input.type = fmt_type;
input.w = lc - fc + 1;
input.d = 0;
if (!fmt_check_input (&input))
goto error;
+
+ /* Compose output format. */
+ if (w != 0)
+ {
+ output.type = fmt_type;
+ output.w = w;
+ output.d = d;
+ if (!fmt_check_output (&output))
+ goto error;
+ }
+ else
+ output = fmt_for_output_from_input (&input);
}
- output = fmt_for_output_from_input (&input);
v = dict_create_var (dict, name, fmt_var_width (&input));
if (v == NULL)