Completely rewrite src/data/format.[ch], to achieve better
[pspp-builds.git] / src / data / por-file-writer.c
index c7c7dd2f211672a68a0cbe5866599b481816f849..b144dee9e5dfa68ec6125fe7cca9f3f64bc8695c 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - computes sample statistics.
-   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
    Written by Ben Pfaff <blp@gnu.org>.
 
    This program is free software; you can redistribute it and/or
@@ -47,8 +47,6 @@
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
-#include <libpspp/debug-print.h>
-
 /* Portable file writer. */
 struct pfm_writer
   {
@@ -107,7 +105,7 @@ pfm_open_writer (struct file_handle *fh, struct dictionary *dict,
   mode = S_IRUSR | S_IRGRP | S_IROTH;
   if (opts.create_writeable)
     mode |= S_IWUSR | S_IWGRP | S_IWOTH;
-  fd = open (fh_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode);
+  fd = open (fh_get_file_name (fh), O_WRONLY | O_CREAT | O_TRUNC, mode);
   if (fd < 0) 
     goto open_error;
 
@@ -164,7 +162,7 @@ pfm_open_writer (struct file_handle *fh, struct dictionary *dict,
  open_error:
   msg (ME, _("An error occurred while opening \"%s\" for writing "
              "as a portable file: %s."),
-       fh_get_filename (fh), strerror (errno));
+       fh_get_file_name (fh), strerror (errno));
   goto error;
 }
 \f  
@@ -284,7 +282,7 @@ write_version_data (struct pfm_writer *w)
 static void
 write_format (struct pfm_writer *w, struct fmt_spec *f)
 {
-  write_int (w, formats[f->type].spss);
+  write_int (w, fmt_to_io (f->type));
   write_int (w, f->w);
   write_int (w, f->d);
 }
@@ -447,7 +445,7 @@ pfm_close_writer (struct pfm_writer *w)
 
       if (!ok) 
         msg (ME, _("An I/O error occurred writing portable file \"%s\"."),
-             fh_get_filename (w->fh));
+             fh_get_file_name (w->fh));
     }
 
   fh_close (w->fh, "portable file", "we");