Abstract the documents within a dictionary a little better. Thanks to
[pspp-builds.git] / src / data / sys-file-reader.c
index 87ba172d5801e7043dbd9391ff529b5336938f19..401e3e27451e1d9c42b15e4eca19433d541439ef 100644 (file)
@@ -671,9 +671,12 @@ read_documents (struct sfm_reader *r, struct dictionary *dict)
     sys_error (r, _("Number of document lines (%d) "
                     "must be greater than 0."), line_cnt);
 
-  documents = pool_nmalloc (r->pool, line_cnt + 1, 80);
-  read_string (r, documents, 80 * line_cnt + 1);
-  dict_set_documents (dict, documents);
+  documents = pool_nmalloc (r->pool, line_cnt + 1, DOC_LINE_LENGTH);
+  read_string (r, documents, DOC_LINE_LENGTH * line_cnt + 1);
+  if (strlen (documents) == DOC_LINE_LENGTH * line_cnt)
+    dict_set_documents (dict, documents);
+  else
+    sys_error (r, _("Document line contains null byte."));
   pool_free (r->pool, documents);
 }