Changed return type from int to bool
[pspp-builds.git] / src / data / sys-file-writer.c
index e923b9d5e43e56b5975511e20e53bddc0f38b6f1..808a307ec7dc53dc68e26baed0f6fd6c45d41262 100644 (file)
@@ -1,6 +1,5 @@
 /* PSPP - computes sample statistics.
    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
    modify it under the terms of the GNU General Public License as
@@ -47,7 +46,6 @@
 #include "value-labels.h"
 #include "variable.h"
 
-#include "stat-macros.h"
 #include "minmax.h"
 
 #include "gettext.h"
@@ -664,16 +662,15 @@ write_documents (struct sfm_writer *w, const struct dictionary *d)
     int32_t n_lines ;          /* Number of lines of documents. */
   } ATTRIBUTE((packed)) rec_6;
 
-  const char *documents;
-  size_t n_lines;
+  const char * documents = dict_get_documents (d);
+  size_t doc_bytes = strlen (documents);
 
-  documents = dict_get_documents (d);
-  n_lines = strlen (documents) / 80;
+  assert (doc_bytes % 80 == 0);
 
   rec_6.rec_type = 6;
-  rec_6.n_lines = n_lines;
+  rec_6.n_lines = doc_bytes / 80;
   buf_write (w, &rec_6, sizeof rec_6);
-  buf_write (w, documents, 80 * n_lines);
+  buf_write (w, documents, 80 * rec_6.n_lines);
 }
 
 /* Write the alignment, width and scale values */
@@ -710,9 +707,13 @@ write_variable_display_parameters (struct sfm_writer *w,
 
       v = dict_get_var(dict, i);
 
-      params.measure = var_get_measure (v);
+      params.measure = (var_get_measure (v) == MEASURE_NOMINAL ? 1
+                        : var_get_measure (v) == MEASURE_ORDINAL ? 2
+                        : 3);
       params.width = var_get_display_width (v);
-      params.align = var_get_alignment (v);
+      params.align = (var_get_alignment (v) == ALIGN_LEFT ? 0
+                      : var_get_alignment (v) == ALIGN_RIGHT ? 1
+                      : 2);
       
       buf_write (w, &params, sizeof(params));
 
@@ -926,7 +927,7 @@ static void write_compressed_data (struct sfm_writer *w, const flt64 *elem);
 
 /* Writes case C to system file W.
    Returns 1 if successful, 0 if an I/O error occurred. */
-int
+bool
 sfm_write_case (struct sfm_writer *w, const struct ccase *c)
 {
   if (ferror (w->file))