X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Flanguage%2Fstats%2Fflip.c;h=0e9b56c5c87ecf7962db9cacd7083d9c29c8f2b8;hb=fb67d7201c231228f4a528f0c10d1cd17cddd6c5;hp=f2c0290c0b31cf3823e2438cfd4793ae34645261;hpb=1b47c4afe993f715c03e7392427b0b8919a26d4e;p=pspp diff --git a/src/language/stats/flip.c b/src/language/stats/flip.c index f2c0290c0b..0e9b56c5c8 100644 --- a/src/language/stats/flip.c +++ b/src/language/stats/flip.c @@ -18,31 +18,36 @@ 02110-1301, USA. */ #include "config.h" -#include + #include #include #include #include #include -#include -#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#include +#include #include -#include #include -#include -#include "intprops.h" +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include #include -#include #include -#include -#include -#include -#ifdef HAVE_SYS_TYPES_H -#include -#endif +#include "intprops.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -87,14 +92,12 @@ int cmd_flip (void) { struct flip_pgm *flip; + struct case_sink *sink; bool ok; - if (temporary != 0) - { - msg (SW, _("FLIP ignores TEMPORARY. " - "Temporary transformations will be made permanent.")); - cancel_temporary (); - } + if (proc_make_temporary_transformations_permanent ()) + msg (SW, _("FLIP ignores TEMPORARY. " + "Temporary transformations will be made permanent.")); flip = pool_create_container (struct flip_pgm, pool); flip->var = NULL; @@ -146,10 +149,11 @@ cmd_flip (void) /* Read the active file into a flip_sink. */ flip->case_cnt = 0; - temp_trns = temporary = 0; - vfm_sink = flip_sink_create (flip); - if (vfm_sink == NULL) + proc_make_temporary_transformations_permanent (); + sink = flip_sink_create (flip); + if (sink == NULL) goto error; + proc_set_sink (sink); flip->new_names_tail = NULL; ok = procedure (NULL, NULL); @@ -170,7 +174,7 @@ cmd_flip (void) flip->case_size = dict_get_case_size (default_dict); /* Set up flipped data for reading. */ - vfm_source = flip_source_create (flip); + proc_set_source (flip_source_create (flip)); return ok ? lex_end_of_command () : CMD_CASCADING_FAILURE; @@ -331,12 +335,8 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c) strcpy (v->name, "VNEGINF"); else if (f > INT_MAX) strcpy (v->name, "VPOSINF"); - else - { - char name[INT_STRLEN_BOUND (int) + 2]; - sprintf (name, "V%d", (int) f); - str_copy_trunc (v->name, sizeof v->name, name); - } + else + snprintf (v->name, sizeof v->name, "V%d", (int) f); } else { @@ -475,7 +475,11 @@ flip_file (struct flip_pgm *flip) case_idx += read_cases; } - pool_fclose (flip->pool, input_file); + if (pool_fclose (flip->pool, input_file) == EOF) + { + msg (SE, _("Error closing FLIP source file: %s."), strerror (errno)); + return false; + } pool_unregister (flip->pool, input_buf); free (input_buf);