octave-maintainers
[Top][All Lists]
Advanced

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

Re: New function proposal


From: David Bateman
Subject: Re: New function proposal
Date: Thu, 15 Feb 2007 12:08:39 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

address@hidden wrote:
> > For now, please leave the POSIX code in lo-syscalls and put the
> > Windows code in sysdep.
>  
> Here it is (with the NULL replacement as well).
>  
> Michael.
>  
>
>
>
Ok, I'm now compiling this. However, I'd like to add a unit test to the
popen2 code. Taking the example code from popen2 and modifying it
slightly I have a test like

[in, out, pid] = popen2 ("sort", "-nr");
fputs (in, "these\nare\nsome\nstrings\n");
fclose (in);
EAGAIN = errno ("EAGAIN");
done = false;
str = {};
idx= 0;
do
   s = fgets (out);
   if (ischar (s))
     idx++;
     str{idx} = s;
   elseif (errno () == EAGAIN)
     sleep (0.1);
     fclear (out);
   else
     done = true;
   endif
 until (done)
fclose (out);
assert(str,{"these\n","strings\n","some\n","are\n"})

However, this of course won't work on MSVC.. Is there a generic program
I can use on all platforms for the popen. If not what is an appropriate
test for MSVC? Then I'd do something like

if (isunix())
  [in, out, pid] = popen2 ("sort", "-nr");
  fputs (in, "these\nare\nsome\nstrings\n");
  fclose (in);
  EAGAIN = errno ("EAGAIN");
  done = false;
  str = {};
  idx= 0;
  do
     s = fgets (out);
     if (ischar (s))
       idx++;
       str{idx} = s;
     elseif (errno () == EAGAIN)
       sleep (0.1);
       fclear (out);
     else
       done = true;
     endif
   until (done)
  fclose (out);
  assert(str,{"these\n","strings\n","some\n","are\n"})
else
   ## INSERT MSVC/MINGW/CYGWIN TEST HERE!!!
endif

Cheers
David


-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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