+ mtf.head = mtf.tail = NULL;
+ mtf.by_cnt = 0;
+ mtf.first[0] = '\0';
+ mtf.last[0] = '\0';
+ mtf.dict = dict_create ();
+ mtf.sink = NULL;
+ case_nullify (&mtf.mtf_case);
+ mtf.seq_num = 0;
+ mtf.seq_nums = NULL;
+ dict_set_case_limit (mtf.dict, dict_get_case_limit (default_dict));
+
+ lex_match ('/');
+ while (token == T_ID
+ && (lex_id_match ("FILE", tokid) || lex_id_match ("TABLE", tokid)))
+ {
+ struct mtf_file *file = xmalloc (sizeof *file);
+
+ if (lex_match_id ("FILE"))
+ file->type = MTF_FILE;
+ else if (lex_match_id ("TABLE"))
+ {
+ file->type = MTF_TABLE;
+ saw_table = true;
+ }
+ else
+ assert (0);
+ lex_match ('=');
+
+ file->by = NULL;
+ file->handle = NULL;
+ file->reader = NULL;
+ file->dict = NULL;
+ file->in_name = NULL;
+ file->in_var = NULL;
+ case_nullify (&file->input);
+
+ /* FILEs go first, then TABLEs. */
+ if (file->type == MTF_TABLE || first_table == NULL)
+ {
+ file->next = NULL;
+ file->prev = mtf.tail;
+ if (mtf.tail)
+ mtf.tail->next = file;
+ mtf.tail = file;
+ if (mtf.head == NULL)
+ mtf.head = file;
+ if (file->type == MTF_TABLE && first_table == NULL)
+ first_table = file;
+ }
+ else
+ {
+ assert (file->type == MTF_FILE);
+ file->next = first_table;
+ file->prev = first_table->prev;
+ if (first_table->prev)
+ first_table->prev->next = file;
+ else
+ mtf.head = file;
+ first_table->prev = file;
+ }
+
+ if (lex_match ('*'))
+ {
+ file->handle = NULL;
+ file->reader = NULL;
+
+ if (used_active_file)
+ {
+ msg (SE, _("The active file may not be specified more "
+ "than once."));
+ goto error;
+ }
+ used_active_file = true;
+
+ assert (pgm_state != STATE_INPUT);
+ if (pgm_state == STATE_INIT)
+ {
+ msg (SE, _("Cannot specify the active file since no active "
+ "file has been defined."));
+ goto error;
+ }
+
+ if (temporary != 0)
+ {
+ msg (SE,
+ _("MATCH FILES may not be used after TEMPORARY when "
+ "the active file is an input source. "
+ "Temporary transformations will be made permanent."));
+ cancel_temporary ();
+ }
+
+ file->dict = default_dict;
+ }
+ else
+ {
+ file->handle = fh_parse (FH_REF_FILE | FH_REF_SCRATCH);
+ if (file->handle == NULL)
+ goto error;
+
+ file->reader = any_reader_open (file->handle, &file->dict);
+ if (file->reader == NULL)
+ goto error;
+
+ case_create (&file->input, dict_get_next_value_idx (file->dict));
+ }
+
+ while (lex_match ('/'))
+ if (lex_match_id ("RENAME"))
+ {
+ if (!rename_variables (file->dict))
+ goto error;
+ }
+ else if (lex_match_id ("IN"))
+ {
+ lex_match ('=');
+ if (token != T_ID)
+ {
+ lex_error (NULL);
+ goto error;
+ }
+
+ if (file->in_name != NULL)
+ {
+ msg (SE, _("Multiple IN subcommands for a single FILE or "
+ "TABLE."));
+ goto error;
+ }
+ file->in_name = xstrdup (tokid);
+ lex_get ();
+ saw_in = true;
+ }
+
+ mtf_merge_dictionary (mtf.dict, file);
+ }