changeset 2345:0f441b4fefdb

[project @ 1996-07-25 06:51:03 by jwe]
author jwe
date Thu, 25 Jul 1996 06:51:03 +0000
parents 968a33af8b3d
children 5baf74b55020
files src/ChangeLog src/load-save.cc
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Jul 24 21:49:50 1996 +0000
+++ b/src/ChangeLog	Thu Jul 25 06:51:03 1996 +0000
@@ -1,3 +1,9 @@
+Thu Jul 25 01:42:38 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* load-save.cc (read_mat_binary_data): Expect to read terminating
+	NUL character in the variable name.
+	(save_mat_binary_data): Likewise, save it here.
+
 Wed Jul 24 05:08:07 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* lsode.cc (Flsode): Don't set the return value if an error
--- a/src/load-save.cc	Wed Jul 24 21:49:50 1996 +0000
+++ b/src/load-save.cc	Thu Jul 25 06:51:03 1996 +0000
@@ -1147,8 +1147,10 @@
       return 0;
     }
 
-  name = new char [len+1];
-  name[len] = '\0';
+  // LEN includes the terminating character, and the file is also
+  // supposed to include it.
+
+  name = new char [len];
   if (! is.read (name, len))
     goto data_read_error;
 
@@ -1784,10 +1786,13 @@
   FOUR_BYTE_INT imag = tc.is_complex_type () ? 1 : 0;
   os.write (&imag, 4);
 
-  FOUR_BYTE_INT name_len = name.length ();
+  // LEN includes the terminating character, and the file is also
+  // supposed to include it.
+
+  FOUR_BYTE_INT name_len = name.length () + 1;
 
   os.write (&name_len, 4);
-  os << name;
+  os << name << '\0';
 
   if (tc.is_real_scalar ())
     {