Thu 16 Jun 2016 07:13:04 PM UTC, original submission:
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:
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:
Compare this to giving the directories in a single argument which preserves the order in the Octave path:
This leads to strange results for mixed inputs in Octave:
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.
|