bugGNU Octave - Bugs: bug #55448, dir() command sometimes returns...

 
 

bug #55448: dir() command sometimes returns filenames in the .folder field

Submitter:  Lars Kindermann <larskindermann>
Submitted:  Fri 11 Jan 2019 04:36:49 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 5.1.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 07 Aug 2019 04:16:13 AM UTC, comment #2: 

I fixed this on the stable branch here https://hg.savannah.gnu.org/hgweb/octave/rev/29e52bcc72af.  The fix preserves the caching mechanism so there is no loss of speed.  This will be part of the next bug fix release.

Rik <rik5>
Group administrator
Fri 11 Jan 2019 10:33:39 PM UTC, comment #1: 

Confirmed.  The issue is with a caching mechanism in dir.m designed to speed it up.


if (! strcmp (last_dir, tmpdir))
  ## Caching mechanism to speed up function
  last_dir = tmpdir;
  last_absdir = canonicalize_file_name (last_dir);
endif


The function canonicalize_file_name is returning the full absolute path.  Here is a clumsy fix


diff -r 7da6136d3ecd scripts/miscellaneous/dir.m
--- a/scripts/miscellaneous/dir.m        Tue Jan 08 21:35:53 2019 -0800
+++ b/scripts/miscellaneous/dir.m        Fri Jan 11 14:32:17 2019 -0800
@@ -141,6 +141,9 @@ function retval = dir (directory)
           ## Caching mechanism to speed up function
           last_dir = tmpdir;
           last_absdir = canonicalize_file_name (last_dir);
+          if (! isdir (last_absdir))
+            last_absdir = fileparts (last_absdir);
+          endif
         endif
         info(i).folder = last_absdir;
         lt = localtime (st.mtime);


Really, the entire caching mechanism needs to be reviewed.  I think the regular expression used may be returning the wrong thing.


Rik <rik5>
Group administrator
Fri 11 Jan 2019 04:36:49 PM UTC, original submission:  

this works correctly:


list=dir('*');list.folder

ans = /home/kinder/octave
ans = /home/kinder/octave
ans = /home/kinder/octave
...


but not this:


list=dir('*.m');list.folder

ans = /home/kinder/octave/audiotest.m
ans = /home/kinder/octave/datenumtest.m
ans = /home/kinder/octave/figclose.m
...


Lars Kindermann <larskindermann>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by larskindermann (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-08-07 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
        Releasedev 5.1.0
    2019-02-26 mtmiller Release5.0.1 dev
    2019-01-11 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code