[PATCH] make PIO_fdopen return NULL on incorrect flags

2005-05-05 Thread Luke Palmer
This patch makes PIO_fdopen return NULL when you give it flags it
doesn't understand.  I gathered that this was the correct behavior
from the test that I untodid.

Luke
Index: t/src/io.t
===
--- t/src/io.t	(revision 7981)
+++ t/src/io.t	(working copy)
@@ -585,8 +585,6 @@
 
 ###
 
-SKIP: {
-skip (fdopen does not handle illegal modes correct, 1);
 c_output_is($main . 'CODE', 'OUTPUT', PIO_fdopen);
 static opcode_t*
 the_test(Interp *interpreter,
@@ -620,7 +618,6 @@
 CODE
 done
 OUTPUT
-}
 
 ###
 
Index: io/io.c
===
--- io/io.c	(revision 7981)
+++ io/io.c	(working copy)
@@ -730,6 +730,8 @@
 }
 
 flags = PIO_parse_open_flags(sflags);
+if (!flags) return NULL;
+
 io = PIO_fdopen_down(interpreter, layer, fd, flags);
 /* io could be null here but we still have to
  * to create a PMC for the caller, no PMCNULL here


Re: [PATCH] make PIO_fdopen return NULL on incorrect flags

2005-05-05 Thread Leopold Toetsch
Luke Palmer [EMAIL PROTECTED] wrote:

 This patch makes PIO_fdopen return NULL when you give it flags it
 doesn't understand.  I gathered that this was the correct behavior
 from the test that I untodid.

 Luke

Thanks, applied.
leo


Re: [PATCH] make PIO_fdopen return NULL on incorrect flags

2005-05-05 Thread MrJoltCola
Actually no, from the PIO routines you should return a PMC
that has a null handle, or that was my original intent. I think
I was considering changing new_io_pmc() to return something
like ParrotUndef in that case but never did. The very first
version of the IO routines actually did return NULL for every
error, but it was decided that wasn't the cleanest way.
If you look at the revision history of io.c, revision 4673, I commented:

Bug fixes. We should not be returning NULL for io PMCs, that generates
an exception now.. A PMC should be returned with a NULL ParrotIO * for
valid eof/bool tests.

As this was 2003, I honestly don't remember all of the discussion.
There might be a record of it between Dan and me in the
archives, however, chances are it was on IRC.
-Melvin
At 07:44 AM 5/5/2005, Leopold Toetsch wrote:
Luke Palmer [EMAIL PROTECTED] wrote:
 This patch makes PIO_fdopen return NULL when you give it flags it
 doesn't understand.  I gathered that this was the correct behavior
 from the test that I untodid.
 Luke
Thanks, applied.
leo