Mercurial > hg > octave-jordi
changeset 17951:c02b8bf0e1f9
Fix failing test in syscalls.cc on MinGW platform (bug #40606).
* syscalls.cc: On PC platforms, check whether sort program is Microsoft
or UNIX-like version before using in %!test of popen2.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 18 Nov 2013 15:07:01 -0800 |
parents | e036b96133ec |
children | 96c76878c7c6 |
files | libinterp/corefcn/syscalls.cc |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/syscalls.cc +++ b/libinterp/corefcn/syscalls.cc @@ -378,11 +378,19 @@ /* %!test +%! unix_sort = true; +%! cmd = {"sort", "-r"}; +%! if (ispc ()) +%! status = system ("sort /? 2> NUL"); +%! if (status == 0) +%! unix_sort = false; +%! cmd = {"sort", "/R"}; +%! endif +%! endif +%! [in, out, pid] = popen2 (cmd{:}); %! if (isunix ()) -%! [in, out, pid] = popen2 ("sort", "-r"); %! EAGAIN = errno ("EAGAIN"); %! else -%! [in, out, pid] = popen2 ("sort", "/R"); %! EAGAIN = errno ("EINVAL"); %! endif %! fputs (in, "these\nare\nsome\nstrings\n"); @@ -392,7 +400,7 @@ %! idx = 0; %! errs = 0; %! do -%! if (!isunix ()) +%! if (! isunix ()) %! errno (0); %! endif %! s = fgets (out); @@ -410,7 +418,7 @@ %! endif %! until (done) %! fclose (out); -%! if (isunix ()) +%! if (unix_sort) %! assert (str, {"these\n","strings\n","some\n","are\n"}); %! else %! assert (str, {"these\r\n","strings\r\n","some\r\n","are\r\n"});