octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #48247] addpath('dir1', 'dir2', 'dir3') revers


From: Garrett Euler
Subject: [Octave-bug-tracker] [bug #48247] addpath('dir1', 'dir2', 'dir3') reverses input directory order
Date: Thu, 16 Jun 2016 19:13:06 +0000 (UTC)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Firefox/38.0

URL:
  <http://savannah.gnu.org/bugs/?48247>

                 Summary: addpath('dir1','dir2','dir3') reverses input
directory order
                 Project: GNU Octave
            Submitted by: ggeuler
            Submitted on: Thu 16 Jun 2016 07:13:04 PM GMT
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

In Matlab the addpath function always preserves the order (read from left to
right) of the input directory list such that in the path they are listed as:


        dir1
        dir2
        ...
        dirN


This is the case for either prepending or appending.

In Octave (default, current and prior releases) prepending a list of
directories with the command addpath('dir1','dir2','dir3') reverses the
result:

>> addpath('dir1','dir2','dir3')
>> path

Octave's search path contains the following directories:

.
dir3
dir2
dir1
...


Compare this to giving the directories in a single argument which preserves
the order in the Octave path:

>> addpath('dir1:dir2:dir3')
>> path

Octave's search path contains the following directories:

.
dir1
dir2
dir3
...


This leads to strange results for mixed inputs in Octave:

>> addpath('dir1','dir2:dir3:dir4','dir5')
>> path

Octave's search path contains the following directories:

.
dir5
dir2
dir3
dir4
dir1
...


When appending directories to the path (with the '-end' flag) Octave is
compatible with Matlab.

I've attached an untested patch to fix this (only touches
libinterp/corefcn/load-path.cc).  The patch looks rather large for what it is.
 Basically I split argument handling based on if you are appending or
prepending directories to the path.  If appending, the code loops over the
directories proceeding from the first entry to the last while prepending goes
from the last entry to the first.  This seemed the simplest approach but I've
barely ever coded in c++ so I'll leave this to those more experienced.  I did
not know what the commented out regex lines are so I kept those.  Since this
is a Matlab Compatibility issue and not an Octave Regression I figured this
best applied to the default branch.

Apologies that I don't have a system setup yet to test this - I've hit a
couple known issues at the make stage and have not worked around them.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 16 Jun 2016 07:13:04 PM GMT  Name: octave_addpath.diff  Size: 3kB  
By: ggeuler

<http://savannah.gnu.org/bugs/download.php?file_id=37506>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48247>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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