dir listing not starting with . and ..
John W. Eaton
jwe at octave.org
Thu Feb 5 02:18:25 CST 2009
On 5-Feb-2009, Jaroslav Hajek 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.
OK, I see now that it is not sorted. But on my system "." and ".."
happen to appear first in the list:
octave:1> dir ("/export/home/jwe/src/octave/src");
. ov-bool-mat.h pt-mat.cc
.. ov-bool-sparse.cc pt-mat.h
Cell.cc ov-bool-sparse.h pt-misc.cc
Cell.h ov-bool.cc pt-misc.h
ChangeLog ov-bool.h pt-pr-code.cc
DLD-FUNCTIONS ov-builtin.cc pt-pr-code.h
Makefile.in ov-builtin.h pt-select.cc
OPERATORS ov-cell.cc pt-select.h
TEMPLATE-INST ov-cell.h pt-stmt.cc
base-list.h ov-ch-mat.cc pt-stmt.h
bitfcns.cc ov-ch-mat.h pt-unop.cc
builtins.h variables.cc pt-unop.h
c-file-ptr-stream.cc ov-struct.cc pt-walk.h
c-file-ptr-stream.h ov-colon.cc pt.cc
comment-list.cc ov-colon.h pt.h
comment-list.h ov-complex.cc sighandlers.cc
cutils.c ov-complex.h sighandlers.h
data.cc ov-cs-list.cc siglist.c
debug.cc ov-cs-list.h siglist.h
debug.h ov-cx-mat.cc sparse-xdiv.cc
defaults.cc ov-cx-mat.h sparse-xdiv.h
defaults.h.in ov-cx-sparse.cc sparse-xpow.cc
defun-dld.h ov-cx-sparse.h sparse-xpow.h
defun-int.h ov-dld-fcn.cc lex.l.orig
defun.cc ov-dld-fcn.h symtab.cc
defun.h ov-fcn-handle.cc symtab.h
dirfns.cc ov-fcn-handle.h syscalls.cc
dirfns.h ov-fcn-inline.cc sysdep.cc
dynamic-ld.cc ov-fcn-inline.h sysdep.h
dynamic-ld.h ov-fcn.cc token.cc
error.cc ov-fcn.h token.h
error.h ov-int-traits.h toplev.cc
file-io.cc ov-int16.cc toplev.h
file-io.h ov-int16.h unwind-prot.cc
genprops.awk ov-int32.cc unwind-prot.h
graphics.cc ov-int32.h utils.cc
graphics.h.in ov-int64.cc utils.h
gripes.cc ov-int64.h pt-cbinop.cc
gripes.h ov-int8.cc variables.h
help.cc ov-int8.h version.h
help.h ov-intx.h xdiv.cc
input.cc ov-list.cc xdiv.h
input.h ov-list.h xpow.cc
lex.h ov-mex-fcn.cc xpow.h
lex.l ov-mex-fcn.h zfstream.cc
load-path.cc ov-range.cc zfstream.h
load-path.h ov-range.h pt-cbinop.h
load-save.cc ov-re-mat.cc ChangeLog.orig
load-save.h ov-re-mat.h lex.h.orig
ls-hdf5.cc ov-re-sparse.cc gl-render.cc
ls-hdf5.h ov-re-sparse.h gl-render.h
ls-mat-ascii.cc ov-scalar.cc ov-class.cc
ls-mat-ascii.h ov-scalar.h ov-class.h
ls-mat4.cc ov-str-mat.cc ov-float.cc
ls-mat4.h ov-str-mat.h parse.y.orig
ls-mat5.cc ov.cc ov-float.h
ls-mat5.h ov.h ov-flt-complex.h
ls-oct-ascii.cc pt-decl.h ov-perm.cc
ls-oct-ascii.h strfns.cc ov-flt-complex.cc
ls-oct-binary.cc ov-struct.h ov-flt-cx-mat.cc
ls-oct-binary.h ov-type-conv.h ov-base-diag.cc
ls-utils.cc ov-typeinfo.cc ov-base-diag.h
ls-utils.h ov-typeinfo.h ov-perm.h
main.c ov-uint16.cc display.cc
mappers.cc ov-uint16.h gl-render.h.save
matherr.c ov-uint32.cc foo-a
mex.cc ov-uint32.h foo
mex.h ov-uint64.cc bar
mexproto.h ov-uint64.h graphics.cc.orig
mk-errno-list ov-uint8.cc help.cc.orig
mk-pkg-add ov-uint8.h display.cc~
mkbuiltins ov-usr-fcn.cc display.h~
mkdefs ov-usr-fcn.h mappers.cc.rej~
mkdocs ChangeLog.rej display.h
mkgendoc pager.cc ov-flt-cx-mat.h
mkops pager.h help.cc.rej~
mxarray.h.in parse.h ov-flt-re-mat.cc
oct-conf.h.in parse.y ov-null-mat.cc
oct-errno.cc.in pr-output.cc ov-null-mat.h
oct-errno.h pr-output.h defun-int.h.orig
oct-fstrm.cc procstream.cc defun.cc.orig
oct-fstrm.h procstream.h help.h.orig
oct-hist.cc pt-all.h ov-flt-re-mat.h
oct-hist.h pt-arg-list.cc Makefile.in.orig
oct-iostrm.cc pt-arg-list.h ov-flt-re-diag.cc
oct-iostrm.h pt-assign.cc pt-eval.cc
oct-lvalue.cc pt-assign.h save-symtab-stuff
oct-lvalue.h pt-binop.cc pt-stmt.cc.rej
oct-map.cc pt-binop.h xnorm.cc
oct-map.h pt-bp.cc ov-usr-fcn.cc.orig
oct-obj.cc pt-bp.h pt-eval.cc.orig
oct-obj.h pt-cell.cc xnorm.h
oct-prcstrm.cc pt-cell.h pt-eval.h.orig
oct-prcstrm.h pt-check.cc foo~
oct-procbuf.cc pt-check.h pt-eval.cc.rej
oct-procbuf.h pt-cmd.cc pt-eval.h.rej
oct-stdstrm.h pt-cmd.h token.cc.orig
oct-stream.cc pt-colon.cc foo-b
oct-stream.h pt-colon.h pt-bp.cc.orig
oct-strstrm.cc pt-const.cc pt-debug.cc~
oct-strstrm.h pt-const.h token.h.orig
oct.h pt-decl.cc pt-debug.cc
octave.cc help.cc.rej ov-re-diag.cc
octave.gperf pt-except.cc pt-eval.h
octave.h pt-except.h ls-hdf5.cc.orig
ops.h pt-exp.cc oct-hdf5.h
ov-base-int.cc pt-exp.h ov-cx-diag.cc
ov-base-int.h pt-fcn-handle.cc ov-cx-diag.h
ov-base-mat.cc pt-fcn-handle.h ov-flt-cx-diag.cc
ov-base-mat.h pt-id.cc ov-flt-cx-diag.h
ov-base-scalar.cc pt-id.h ov-flt-perm.cc
ov-base-scalar.h pt-idx.cc ov-flt-perm.h
ov-base-sparse.cc pt-idx.h ov-flt-re-diag.h
ov-base-sparse.h pt-jump.cc oct-hdf5.h~
ov-base.cc pt-jump.h ov-re-diag.h
ov-base.h pt-loop.cc pt-eval.h~
ov-bool-mat.cc pt-loop.h pt-eval.cc~
With the patch, I see this:
. main.c ov-colon.cc pt-cell.h
.. mappers.cc ov-colon.cc pt-check.cc
Cell.cc mappers.cc.rej~ ov-colon.cc pt-check.h
Cell.h matherr.c ov-colon.cc pt-cmd.cc
ChangeLog mex.cc ov-colon.cc pt-cmd.h
ChangeLog.orig mex.h ov-colon.cc pt-colon.cc
ChangeLog.rej mexproto.h ov-colon.cc pt-colon.h
ChangeLog.rej mk-errno-list ov-colon.cc pt-const.cc
ChangeLog.rej mk-pkg-add ov-colon.cc pt-const.h
Makefile.in.orig mkbuiltins ov-colon.cc pt-debug.cc
OPERATORS mkdefs ov-colon.cc pt-debug.cc~
TEMPLATE-INST mkdocs ov-colon.cc pt-decl.cc
bar mkgendoc ov-colon.cc pt-decl.h
base-list.h mkops ov-colon.cc pt-eval.cc
bitfcns.cc mxarray.h.in ov-colon.cc pt-eval.cc.orig
builtins.h oct-conf.h.in ov-colon.cc pt-eval.cc.rej
base-list.h oct-errno.cc.in ov-colon.cc pt-eval.cc~
bitfcns.cc oct-errno.h ov-colon.cc pt-eval.h
builtins.h oct-fstrm.cc ov-colon.cc pt-eval.h
base-list.h oct-fstrm.h ov-colon.cc pt-eval.h
bitfcns.cc oct-hdf5.h ov-colon.cc pt-eval.h~
data.cc oct-hdf5.h~ ov-colon.cc pt-except.cc
debug.cc oct-hist.cc ov-colon.cc pt-except.h
debug.h oct-hist.h ov-colon.cc pt-exp.cc
defaults.cc oct-iostrm.cc ov-colon.cc pt-exp.h
defaults.h.in oct-iostrm.h ov-colon.cc pt-fcn-handle.cc
defun-dld.h oct-lvalue.cc ov-colon.cc pt-fcn-handle.h
defun-int.h oct-lvalue.h ov-colon.cc pt-id.cc
defun-int.h.orig oct-map.cc ov-colon.cc pt-id.h
defun.cc oct-map.h ov-colon.cc pt-idx.cc
defun.cc.orig oct-obj.cc ov-colon.cc pt-idx.h
defun.h oct-obj.h ov-colon.cc pt-jump.cc
dirfns.cc oct-prcstrm.cc ov-colon.cc pt-jump.h
dirfns.h oct-prcstrm.h ov-colon.cc pt-loop.cc
display.cc oct-procbuf.cc ov-colon.cc pt-loop.h
display.cc~ oct-procbuf.h ov-colon.cc pt-mat.cc
display.h oct-stdstrm.h ov-colon.cc pt-mat.h
display.h~ oct-stream.cc ov-colon.cc pt-misc.cc
dynamic-ld.cc oct-stream.h ov-colon.cc pt-misc.h
dynamic-ld.h oct-strstrm.cc ov-colon.cc pt-pr-code.cc
error.cc oct-strstrm.h ov-colon.cc pt-pr-code.h
error.h oct.h ov-colon.cc pt-select.cc
file-io.cc octave.cc ov-colon.cc pt-select.h
file-io.h octave.gperf ov-colon.cc pt-stmt.cc
foo octave.h ov-colon.cc pt-stmt.cc.rej
foo-a ops.h ov-colon.cc save-symtab-stuff
foo-b ov-base-diag.cc ov-colon.cc pt-stmt.cc.rej
foo~ ov-base-diag.h ov-colon.cc save-symtab-stuff
genprops.awk ov-base-int.cc ov-colon.cc pt-stmt.cc.rej
gl-render.cc ov-base-int.h ov-colon.cc save-symtab-stuff
gl-render.h ov-base-mat.cc ov-colon.cc pt-stmt.cc.rej
gl-render.h.save ov-base-mat.h ov-colon.cc save-symtab-stuff
graphics.cc ov-base-scalar.cc ov-colon.cc pt-stmt.cc.rej
graphics.cc.orig ov-base-scalar.h ov-colon.cc save-symtab-stuff
graphics.h.in ov-base-sparse.cc ov-colon.cc pt-stmt.cc.rej
gripes.cc ov-base-sparse.h ov-colon.cc save-symtab-stuff
gripes.h ov-base.cc ov-colon.cc pt-stmt.cc.rej
help.cc ov-base.h ov-colon.cc pt-stmt.h
help.cc.orig ov-bool-mat.cc ov-colon.cc pt-unop.cc
help.cc.rej ov-bool-mat.h ov-colon.cc pt-unop.h
help.cc.rej~ ov-bool-sparse.cc ov-colon.cc pt-walk.h
help.h ov-bool-sparse.h ov-cx-diag.cc pt.cc
help.h.orig ov-bool.cc ov-cx-diag.h pt.h
input.cc ov-bool.h ov-float.cc save-symtab-stuff
input.h ov-builtin.cc ov-float.h sighandlers.cc
lex.h ov-builtin.h ov-flt-complex.cc sighandlers.h
lex.h.orig ov-cell.cc ov-flt-complex.h siglist.c
lex.l ov-cell.h ov-flt-cx-diag.cc siglist.h
lex.l.orig ov-ch-mat.cc ov-flt-cx-diag.h sparse-xdiv.cc
load-path.cc ov-ch-mat.h ov-flt-cx-mat.cc sparse-xdiv.h
load-path.h ov-class.cc ov-flt-cx-mat.h sparse-xpow.cc
load-save.cc ov-class.h ov-flt-perm.cc sparse-xpow.h
load-save.h ov-colon.cc ov-flt-perm.h strfns.cc
ls-hdf5.cc ov-colon.cc ov-flt-re-diag.cc symtab.cc
ls-hdf5.cc.orig ov-colon.cc ov-flt-re-diag.h symtab.h
ls-hdf5.h ov-colon.cc ov-flt-re-mat.cc syscalls.cc
ls-mat-ascii.cc ov-colon.cc ov-flt-re-mat.h variables.cc
ls-mat-ascii.h ov-colon.cc ov-null-mat.cc variables.h
ls-mat4.cc ov-colon.cc ov-null-mat.h version.h
ls-mat4.h ov-colon.cc ov-perm.cc xdiv.cc
ls-mat5.cc ov-colon.cc ov-perm.h xdiv.h
ls-mat5.h ov-colon.cc ov-re-diag.cc xnorm.cc
ls-oct-ascii.cc ov-colon.cc ov-re-diag.h xnorm.h
ls-oct-ascii.h ov-colon.cc ov-usr-fcn.cc.orig xpow.cc
ls-oct-binary.cc ov-colon.cc parse.y.orig xpow.h
ls-oct-binary.h ov-colon.cc pt-bp.cc.orig zfstream.cc
ls-utils.cc ov-colon.cc pt-cbinop.cc zfstream.h
ls-utils.h ov-colon.cc pt-cbinop.h
So although it looks closer to being sorted, something bad must have
happened for it to end up with multiple copies of some entries.
jwe
More information about the Bug-octave
mailing list