-
- if (flip->case_cnt > 99999)
- {
- msg (SE, _("Cannot create more than 99999 variable names."));
- return 0;
- }
-
- for (i = 0; i < flip->case_cnt; i++)
- {
- struct variable *v;
- char s[SHORT_NAME_LEN + 1];
-
- sprintf (s, "VAR%03d", i);
- v = dict_create_var_assert (dict, s, 0);
- }
- }
- else
- {
- struct varname *v;
-
- for (v = flip->new_names_head; v; v = v->next)
- if (!make_new_var (dict, v->name))
- return 0;
- }
-
- return 1;
-}
-
-/* Creates a flip sink based on FLIP. */
-static struct case_sink *
-flip_sink_create (struct dataset *ds, struct flip_pgm *flip)
-{
- size_t i;
-
- flip->output_buf = pool_nalloc (flip->pool,
- flip->var_cnt, sizeof *flip->output_buf);
-
- flip->file = pool_tmpfile (flip->pool);
- if (flip->file == NULL)
- {
- msg (SE, _("Could not create temporary file for FLIP."));
- return NULL;
- }
-
- /* Write variable names as first case. */
- for (i = 0; i < flip->var_cnt; i++)
- buf_copy_str_rpad (flip->output_buf[i].s, MAX_SHORT_STRING,
- var_get_name (flip->var[i]));
- if (fwrite (flip->output_buf, sizeof *flip->output_buf,
- flip->var_cnt, flip->file) != (size_t) flip->var_cnt)
- {
- msg (SE, _("Error writing FLIP file: %s."), strerror (errno));
- return NULL;
- }
-
- flip->case_cnt = 1;
-
- return create_case_sink (&flip_sink_class,
- dataset_dict (ds),
- dataset_get_casefile_factory (ds),
- flip);
-}
-
-/* Writes case C to the FLIP sink.
- Returns true if successful, false if an I/O error occurred. */
-static bool
-flip_sink_write (struct case_sink *sink, const struct ccase *c)
-{
- struct flip_pgm *flip = sink->aux;
- size_t i;
-
- flip->case_cnt++;
-
- if (flip->new_names != NULL)
- {
- struct varname *v = pool_alloc (flip->pool, sizeof *v);
- int fv = flip->idx_to_fv[var_get_dict_index (flip->new_names)];
- v->next = NULL;
- if (var_is_numeric (flip->new_names))