>>> .sub _main >>> fdopen $P1, 0, "r" # STDIN > >BTW > fdopen $P1, 0, "<" # read STDIN > >>> 3. its currently only defined for PIO_OS_UNIX > >> Okaaay, so the plan is for this to work and I should probably code this way anyway, >> right? > > You could just delete the #ifdef PIO_OS_UNIX in io.ops:fdopen and see, > if its working.
Given Jürgen's patch to completely remove the integer file descriptors and to add the getstdin, getstdout, and getstderr I think this bug can be dropped. fdopen() isn't completely functional under Win32 (either that, or I blew the part where I expose the Unix interface) but this should take care of most fd problems in Win32. (I don't think I've *ever* seen a Windows program pass a file descriptor...) Given that, there's a possible bug in Jürgen's patch (or IMCC?). Given: .sub _main call _INIT .arg 0 call _READLINE .result $S0 print $S0 end .end .sub _INIT $P0=new PerlArray # Array of BASIC FD's getstdin $P1 # traditional #0 defined $I0, $P1 unless $I0, err $P0[0]=$P1 getstdout $P1 # traditional #1, etc... $P0[1]=$P1 defined $I0, $P1 unless $I0, err store_global "FDS", $P0 ret err: print "Cannot get handle for STDIN" end .end .sub _READLINE # string readline(int fd) saveall .param int fd find_global $P0, "FDS" $P1=$P0[fd] set $S0, "" read $S0, $P1, 255 # <-- Crunch .return $S0 restoreall ret .end This produces the PASM: _main: bsr _INIT save 0 bsr _READLINE restore S0 print S0 end _INIT: new P1, 19 # .PerlArray getstdin P0 defined I0, P0 unless I0, err set P1[0], P0 getstdout P0 # <-- bug is here? Overwrote my P0. set P1[1], P0 store_global "FDS", P1 ret err: print "Cannot get handle for STDIN" end _READLINE: saveall restore I0 find_global P0, "FDS" set P0, P0[I0] set S0, "" read S0, P0, 255 save S0 restoreall ret Given that I'm just taking STDIN, STDOUT, STDERR and trying to stuff them into an array, should I have to use three different registers for this in the PIR? new $P4, PerlArray getstdin $P0 getstdout $P1 getstderr $P2 $P4[0], $P0 $P4[1], $P1 $P4[2], $P2 Or should getstdin/out/err have not overwritten the Px register and given up a new one each time? Either behavior is fine, so long as we're consistant and/or documented.