changeset 617:5acc6db54c8f

[project @ 1994-08-15 04:32:29 by jwe]
author jwe
date Mon, 15 Aug 1994 04:32:29 +0000
parents 9ced66fce8a3
children ca6e72746161
files src/load-save.cc
diffstat 1 files changed, 50 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/load-save.cc	Mon Aug 15 04:16:43 1994 +0000
+++ b/src/load-save.cc	Mon Aug 15 04:32:29 1994 +0000
@@ -88,12 +88,17 @@
     LS_UNKNOWN_FLT_FMT,
   };
 
+// Not all of the following are currently used.
+
 enum save_type
   {
     LS_U_CHAR,
     LS_U_SHORT,
+    LS_U_INT,
+    LS_CHAR,
     LS_SHORT,
     LS_INT,
+    LS_FLOAT,
     LS_DOUBLE,
   };
 
@@ -464,6 +469,14 @@
       LS_DO_WRITE (unsigned TWO_BYTE_INT, data, 2, len, os);
       break;
 
+    case LS_U_INT:
+      LS_DO_WRITE (unsigned FOUR_BYTE_INT, data, 4, len, os);
+      break;
+
+    case LS_CHAR:
+      LS_DO_WRITE (signed char, data, 1, len, os);
+      break;
+
     case LS_SHORT:
       LS_DO_WRITE (TWO_BYTE_INT, data, 2, len, os);
       break;
@@ -1390,6 +1403,39 @@
   return -1;
 }
 
+// We don't just use a cast here, because we need to be able to detect
+// possible errors.
+
+static floating_point_format
+get_floating_point_format (int mach)
+{
+  switch (mach)
+    {
+    case 0:
+      flt_fmt = LS_IEEE_LITTLE;
+      break;
+
+    case 1:
+      flt_fmt = LS_IEEE_BIG;
+      break;
+
+    case 2:
+      flt_fmt = LS_VAX_D;
+      break;
+
+    case 3:
+      flt_fmt = LS_VAX_G;
+      break;
+
+    case 4:
+      flt_fmt = LS_CRAY;
+      break;
+
+    default:
+      flt_fmt = LS_UNKOWN_FLT_FMT;
+      break;
+    }
+}
 // Extract one value (scalar, matrix, string, etc.) from stream IS and
 // place it in TC, returning the name of the variable.
 //
@@ -1430,14 +1476,9 @@
   mopt /= 100;      // Skip unused third digit too.
   mach = mopt % 10; // IEEE, VAX, etc.
 
-  switch (mach)
+  flt_fmt = get_floating_point_format (mach);
+  if (flt_fmt == LS_UNKNOWN_FLT_FMT)
     {
-    case 0: flt_fmt = LS_IEEE_LITTLE; break;
-    case 1: flt_fmt = LS_IEEE_BIG;    break;
-    case 2: flt_fmt = LS_VAX_D;       break;
-    case 3: flt_fmt = LS_VAX_G;       break;
-    case 4: flt_fmt = LS_CRAY;        break;
-    default:
       error ("load: unrecognized binary format!");
       return 0;
     }
@@ -1553,14 +1594,9 @@
   char tmp = 0;
   is.read (&tmp, 1);
 
-  switch (tmp)
+  flt_fmt = get_floating_point_format (tmp);
+  if (flt_fmt == LS_UNKNOWN_FLT_FMT)
     {
-    case 0: flt_fmt = LS_IEEE_LITTLE; break;
-    case 1: flt_fmt = LS_IEEE_BIG;    break;
-    case 2: flt_fmt = LS_VAX_D;       break;
-    case 3: flt_fmt = LS_VAX_G;       break;
-    case 4: flt_fmt = LS_CRAY;        break;
-    default:
       if (! quiet)
         error ("load: unrecognized binary format!");
       return -1;