dir listing not starting with . and ..
Jaroslav Hajek
highegg at gmail.com
Thu Feb 5 02:23:41 CST 2009
On Thu, Feb 5, 2009 at 7:50 AM, Jaroslav Hajek <highegg at gmail.com> wrote:
> On Wed, Feb 4, 2009 at 9:53 PM, John W. Eaton <jwe at octave.org> wrote:
>> On 4-Feb-2009, Jaroslav Hajek wrote:
>>
>> | My fault, due to an older change string_vector::sort was not working.
>> | Patch uploaded:
>> | http://hg.savannah.gnu.org/hgweb/octave/rev/4238f2600a17
>> |
>> | Note that readdir (and, consequently, dir) simply sorts the result.
>> | This does *not* ensure that . and .. go first.
>> | If, for instance, a file named "(" exists, it will end up first. Worse
>> | yet, this is compatible with Matlab 2007a.
>>
>> This change doesn't seem to work correctly for me. With it, dir
>> returns repeated entries and misses other files that exist. Do you
>> see the same result? I noticed it because make check was suddenly
>> skipping over all the tests in the DLD-FUNCTIONS directory. After
>> undoing the change, I don't see the problem, and the list of files
>> returned by dir still appears to be sorted, with "." and ".." first in
>> the list.
>
> In fact I see quite the opposite, as expected. With the reverse,
> `readdir(".")' no longer returns a sorted list.
> But I also see you are right, there are skipped tests. I'll try to
> investigate what's wrong.
>
>> So I guess I don't understand what the original problem was
>> that prompted this change. For now, I've reversed it in the savannah
>> archive.
>>
>
> string_vector::sort was not sorting anything. If you look at the code,
> not the results, you'll see it - Array<T>::sort is a const method, so
> calling it without an output argument does no good. Since
> string_vector::sort should operate in-place, I replaced this with a
> direct call to octave_sort. This seems OK. There must be other problem
> somewhere. I'll look for it.
>
> cheers
>
>
Fix uploaded - apparently this was triggered by 0168d22e6bba (from
me). I didn't realize that octave_sort<T>::merge_hi is going from
backwards, and needs copy_backward. It's surprising this went
unnoticed so long.
I've undone the undo with added fixes to oct-sort.cc
regards
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
More information about the Bug-octave
mailing list