diff src/ov-cell.cc @ 5850:426b94346d70

[project @ 2006-06-09 15:44:35 by jwe]
author jwe
date Fri, 09 Jun 2006 15:46:10 +0000
parents db0598f94c0f
children c20eb7330d13
line wrap: on
line diff
--- a/src/ov-cell.cc
+++ b/src/ov-cell.cc
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#include <iomanip>
 #include <iostream>
 #include <sstream>
 #include <vector>
@@ -791,15 +792,18 @@
   // Recursively add each element of the cell to this group.
 
   Cell tmp = cell_value ();
-  
-  for (octave_idx_type i = 0; i < dv.numel (); i++)
+
+  octave_idx_type nel = dv.numel ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
     {
       std::ostringstream buf;
-      buf << "_" << i;
+      int digits = static_cast<int> (floor (log10 (nel) + 1.0));
+      buf << "_" << std::setw (digits) << std::setfill ('0') << i;
       std::string s = buf.str ();
 
-      if (! add_hdf5_data(data_hid, tmp.elem (i), s.c_str (), "", false,
-			  save_as_floats))
+      if (! add_hdf5_data (data_hid, tmp.elem (i), s.c_str (), "", false,
+			   save_as_floats))
 	{
 	  H5Gclose (data_hid);
 	  return false;