added automake.mk files in src/language
[pspp] / src / sfm-write.c
index 3b74efe151231730bda08eee441900908621c7d3..dcdab0b46d616dd6604adab4b33108fd69c80b5b 100644 (file)
@@ -156,7 +156,7 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d,
     goto open_error;
 
   /* Open file handle. */
-  if (!fh_open (fh, "system file", "we"))
+  if (!fh_open (fh, FH_REF_FILE, "system file", "we"))
     goto error;
 
   /* Create and initialize writer. */
@@ -257,7 +257,7 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d,
 
  open_error:
   msg (ME, _("Error opening \"%s\" for writing as a system file: %s."),
-       fh_get_filename (w->fh), strerror (errno));
+       fh_get_filename (fh), strerror (errno));
   err_cond_fail ();
   goto error;
 }
@@ -788,7 +788,7 @@ static void write_compressed_data (struct sfm_writer *w, const flt64 *elem);
 /* Writes case C to system file W.
    Returns nonzero if successful. */
 int
-sfm_write_case (struct sfm_writer *w, struct ccase *c)
+sfm_write_case (struct sfm_writer *w, const struct ccase *c)
 {
   w->case_cnt++;
 
@@ -904,8 +904,6 @@ sfm_close_writer (struct sfm_writer *w)
   if (w == NULL)
     return;
 
-  fh_close (w->fh, "system file", "we");
-  
   if (w->file != NULL) 
     {
       /* Flush buffer. */
@@ -932,6 +930,8 @@ sfm_close_writer (struct sfm_writer *w)
              fh_get_filename (w->fh), strerror (errno));
     }
 
+  fh_close (w->fh, "system file", "we");
+  
   free (w->buf);
   free (w->vars);
   free (w);