From bug-octave-request at bevo dot che dot wisc dot edu Tue Jun 24 10:16:29 2003 Subject: Bug (doc-bug?) in 'exist'. From: "John W. Eaton" To: Mats Jansson Cc: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 24 Jun 2003 10:16:23 -0500 On 24-Jun-2003, Mats Jansson wrote: | Bug report for Octave 2.1.49 configured for i686-pc-linux-gnu | | Description: | ----------- | | The call 'exist ("find")' returns 2. According to the documentation it | should return 3 for oct-files. On my system it does return 3. It looks like your LOADPATH is LOADPATH = "./:/home/mj/m-files/2.1.4x//:/home/mj/m-files/2.1.x//:/home/mj/m-files/common//:/home/mj/no_unison/octavelib//:" What does Octave return for file_in_loadpath ("find.m") and file_in_loadpath ("find.m") ? In any case, if you are getting find.oct when you use find, but exist is finding find.m, then I think that is a bug. Please try the following patch. Thanks, jwe src/ChangeLog: 2003-06-24 John W. Eaton * variables.cc (symbol_exist): Use dir_path::find_first_of to search for .oct and .m files. Index: src/variables.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/variables.cc,v retrieving revision 1.248 diff -u -r1.248 variables.cc --- src/variables.cc 23 Jun 2003 17:52:36 -0000 1.248 +++ src/variables.cc 24 Jun 2003 15:15:28 -0000 at @ -603,21 +603,24 @@ if (! retval) { - std::string file_name = fcn_file_in_path (name); + string_vector names (2); - if ((type == "any" || type == "file") && ! file_name.empty ()) - { - retval = 2; - } - } + names(0) = name + ".oct"; + names(1) = name + ".m"; + + std::string file_name = Vload_path_dir_path.find_first_of (names); - if (! retval) - { - std::string file_name = oct_file_in_path (name); + size_t len = file_name.length (); - if ((type == "any" || type == "file") && ! file_name.empty ()) + if (! file_name.empty ()) { - retval = 3; + if (type == "any" || type == "file") + { + if (file_name.substr (len-4) == ".oct") + retval = 3; + else + retval = 2; + } } } ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------