help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to debug this strange load problem


From: frank wang
Subject: Re: how to debug this strange load problem
Date: Thu, 31 Aug 2006 11:03:03 -0700

Hi, John,
 
It fixed the problem. Now I can load the data file.
 
Thanks
 
Frank

 
On 8/30/06, John W. Eaton <address@hidden> wrote:
On 30-Aug-2006, frank wang wrote:

static load_save_format
get_file_format (const std::string& fname, const std::string& orig_fname,
                bool &use_zlib)
| 2)Without the success to recompile the code, I used gdb to debug the code
| with the original build. After stepping through the code, I found that by
| typing command in octave load test2.txt. Octave in load-save.cc could not
| find the correct format, so variable format = LS_UNKNOWN. Then Octave
| returns without read the data.

Ah.  Try the following patch.  The code in question was

static load_save_format
get_file_format (const std::string& fname, const std::string& orig_fname,
                bool &use_zlib)
{
load_save_format retval = LS_UNKNOWN;

#ifdef HAVE_HDF5
// check this before we open the file
if (H5Fis_hdf5 (fname.c_str ()) > 0)
   return LS_HDF5;
#endif /* HAVE_HDF5 */

std::ifstream file (fname.c_str ());
use_zlib = false;

if (file)
   {
     retval = get_file_format (file);
     file.close ();

#ifdef HAVE_ZLIB
     if (retval == LS_UNKNOWN && check_gzip_magic (fname))
       {
         gzifstream gzfile (fname.c_str ());
         use_zlib = true;

         if (gzfile)
           {
             retval = get_file_format (gzfile);
             gzfile.close ();
           }
       }

     if (retval == LS_UNKNOWN)
       {
         // Try reading the file as numbers only, determining the
         // number of rows and columns from the data.  We don't
         // even bother to check to see if the first item in the
         // file is a number, so that get_complete_line() can
         // skip any comments that might appear at the top of the
         // file.

         retval = LS_MAT_ASCII;
       }

#endif
   }
else
   gripe_file_open ("load", orig_fname);

return retval;
}

so if you didn't have zlib installed when configuring Octave, Octave
would never try to load the file using the numbers-only format
(LS_MAT_ASCII).  The fix is to move the #endif up before the final
if (retval == LS_UNKNOWN) statement.

I'm sorry this problem was so painful to diagnose.

Thanks for helping to uncover it.

jwe


src/ChangeLog:

2006-08-30  John W. Eaton  < address@hidden>

       * load-save.cc (get_file_format): Fix misplaced #endif.


Index: src/load-save.cc
===================================================================
RCS file: /cvs/octave/src/load- save.cc,v
retrieving revision 1.217
diff -u -u -r1.217 load-save.cc
--- src/load-save.cc    23 Aug 2006 18:35:38 -0000      1.217
+++ src/load-save.cc    30 Aug 2006 20:01:05 -0000
@@ -425,6 +425,7 @@
             gzfile.close ();
           }
       }
+#endif

      if (retval == LS_UNKNOWN)
       {
@@ -437,8 +438,6 @@

         retval = LS_MAT_ASCII;
       }
-
-#endif
    }
  else
    gripe_file_open ("load", orig_fname);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]