/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007, 2010, 2011, 2012 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006-2007, 2010-15 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
#include "language/lexer/lexer.h"
#include "libpspp/compiler.h"
#include "libpspp/misc.h"
+#include "libpspp/message.h"
#include "libpspp/str.h"
#include "gl/xalloc.h"
struct file_handle *fh = NULL;
struct dictionary *dict = NULL;
struct case_map *map = NULL;
+ struct case_map_stage *stage = NULL;
char *encoding = NULL;
for (;;)
if (!lex_match_id (lexer, "COMM")
&& !lex_match_id (lexer, "TAPE"))
{
- lex_error_expecting (lexer, "COMM", "TAPE", NULL_SENTINEL);
+ lex_error_expecting (lexer, "COMM", "TAPE");
goto error;
}
}
goto error;
}
- reader = any_reader_open (fh, encoding, &dict);
+ reader = any_reader_open_and_decode (fh, encoding, &dict, NULL);
if (reader == NULL)
goto error;
- case_map_prepare_dict (dict);
+ if (dict_get_n_vars (dict) == 0)
+ {
+ msg (SE, _("%s: Data file dictionary has no variables."),
+ fh_get_name (fh));
+ goto error;
+ }
+
+ stage = case_map_stage_create (dict);
while (lex_token (lexer) != T_ENDCMD)
{
lex_match (lexer, T_SLASH);
- if (!parse_dict_trim (lexer, dict))
+ if (!parse_dict_trim (lexer, dict, false))
goto error;
}
dict_compact_values (dict);
- map = case_map_from_dict (dict);
+ map = case_map_stage_get_case_map (stage);
+ case_map_stage_destroy (stage);
if (map != NULL)
reader = case_map_create_input_translator (map, reader);
return CMD_SUCCESS;
error:
+ case_map_stage_destroy (stage);
fh_unref (fh);
casereader_destroy (reader);
if (dict != NULL)
- dict_destroy (dict);
+ dict_unref (dict);
free (encoding);
return CMD_CASCADING_FAILURE;
}