From: Thibaut Paumard <paumard@users.sourceforge.net>
Last-Update: 2009-11-23
Forwarded: yes
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506297
Description: Make yorick-ml4 64bit-safe
 With version 0.6.0, ml4 has been made almost 64bit-safe. However,
 saving an array of longs on a 64-bit machine still produces a corrupt
 file. Fix: always convert longs to ints before saving. Done in ml4.i.


--- a/ml4.i
+++ b/ml4.i
@@ -124,7 +124,9 @@
     ncols=int(dims(3));
   }
   
-  if      (structof(data)==long)   { type='l'; }
+  tmp = data; // otherwise data may be swapped in place in endian='L'
+  
+  if      (structof(data)==long)   { type='l'; tmp=int(tmp); }
   else if (structof(data)==int)    { type='l'; }
   else if (structof(data)==float)  { type='r'; }
   else if (structof(data)==double) { type='d'; }
@@ -132,8 +134,6 @@
   else if (structof(data)==char)   { type='b'; }
   else error,"Unsupported type";
 
-  tmp = data; // otherwise data may be swapped in place in endian='L'
-  
   status = matout(file,varname,&tmp,nrows,ncols,type,mode,endian);
   if (status) error,"write failed";
 }
