Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

3-arg opens

5 views
Skip to first unread message

Bryan C. Warnock

unread,
May 26, 2003, 7:47:36 PM5/26/03
to perl6-i...@perl.org
Is the following:

open I3, "temp.file", "r"

valid, and/or is it supposed to be valid?

--
Bryan C. Warnock
bwarnock@(gtemail.net|raba.com)

Simon Glover

unread,
May 26, 2003, 8:04:00 PM5/26/03
to Bryan C. Warnock, perl6-i...@perl.org

On 26 May 2003, Bryan C. Warnock wrote:

> Is the following:
>
> open I3, "temp.file", "r"
>
> valid, and/or is it supposed to be valid?
>

I don't think so -- this form of open calls PIO_open, which calls
PIO_parse_open_flags to parse the third argument, and
PIO_parse_open_flags expects flags of the form "<", ">+", etc.
(although this is not stated anywhere in the documentation, as far as
I can see).

Simon


Bryan C. Warnock

unread,
May 26, 2003, 8:09:56 PM5/26/03
to Simon Glover, perl6-i...@perl.org

Yep. t/op/hacks.t has a test with both the above line and the coded '<'
flag. I didn't know if the test was wrong accidentally, the test was
wrong purposefully, or if PIO_parse_open_flags() was incomplete.

Simon Glover

unread,
May 26, 2003, 8:38:58 PM5/26/03
to Bryan C. Warnock, perl6-i...@perl.org

On 26 May 2003, Bryan C. Warnock wrote:

> On Mon, 2003-05-26 at 20:04, Simon Glover wrote:
> > On 26 May 2003, Bryan C. Warnock wrote:
> >
> > > Is the following:
> > >
> > > open I3, "temp.file", "r"
> > >
> > > valid, and/or is it supposed to be valid?
> > >
> >
> > I don't think so -- this form of open calls PIO_open, which calls
> > PIO_parse_open_flags to parse the third argument, and
> > PIO_parse_open_flags expects flags of the form "<", ">+", etc.
> > (although this is not stated anywhere in the documentation, as far as
> > I can see).
>
> Yep. t/op/hacks.t has a test with both the above line and the coded '<'
> flag. I didn't know if the test was wrong accidentally, the test was
> wrong purposefully, or if PIO_parse_open_flags() was incomplete.

Looking at the CVS change log, I see that the person responsible for
the offending line was... erm, well, me. In which case you can definitely
put this one down to incompetence :-(

Simon

PS However, more documentation for the IO ops (and the IO subsystem
generally) would be a Good Thing, and might stop this sort of thing
from happening in the future.


Bruce Gray

unread,
May 26, 2003, 8:44:01 PM5/26/03
to Bryan C. Warnock, Simon Glover, perl6-i...@perl.org

The test had bugs, then was TODO'ed for a long time, then un-TODO'ed with
the bugs intact. I worked on a patch a few days ago, but I seem to have
lost it. (I have 7 different CVS copies across 5 systems). Try this patch
(coded from memory, and not yet tested-to-death). I remember the bugs as
being:
* Old comment not removed.
* 'r' should be 'w', which should now be '>'.
* Second open should be '<', not '>'.
* 'print' op should print to I1, not STDOUT. (This is why the test was
passing for the wrong reason).

Brian, since you have your eyes on this test, please let me know if my
assessment is complete.

--
Hope this helps,
Bruce Gray

hacks_3_arg_open.patch

Bryan C. Warnock

unread,
May 26, 2003, 9:03:53 PM5/26/03
to Bruce Gray, Simon Glover, perl6-i...@perl.org
On Mon, 2003-05-26 at 20:44, Bruce Gray wrote:
> The test had bugs, then was TODO'ed for a long time, then un-TODO'ed with
> the bugs intact. I worked on a patch a few days ago, but I seem to have
> lost it. (I have 7 different CVS copies across 5 systems). Try this patch
> (coded from memory, and not yet tested-to-death). I remember the bugs as
> being:
> * Old comment not removed.
> * 'r' should be 'w', which should now be '>'.
> * Second open should be '<', not '>'.
> * 'print' op should print to I1, not STDOUT. (This is why the test was
> passing for the wrong reason).
>
> Brian, since you have your eyes on this test, please let me know if my
> assessment is complete.

That seems sensible. If nothing else, this test exercised some broken
threads in the IO section. I submitted a patch to fix those threads in
Parrot, but not this test, about the same time I started this thread.

I would state that one item missed in your comments is the one that
raised the other issues for me, and that is a failed open. There are no
checks to make sure the opens succeeded.

The format of the test is largely unimportant to my patch. It just
wasn't clear if I should have possibly patch the flags processor to
handle lexical (vice symbolic) modes. Just ignore the portions of my
comments that we've already covered here.

Juergen Boemmels

unread,
May 27, 2003, 9:27:52 AM5/27/03
to Simon Glover, Bryan C. Warnock, perl6-i...@perl.org
Simon Glover <sc...@amnh.org> writes:

[...]


>>>> open I3, "temp.file", "r"

As written before, this is invalid. The correct way opening a file (at
least this week) for reading is

open I3, "temp.file", "<"

some months ago I changed the io from stdio to PIO and this changed
from "r" to "<".

> Looking at the CVS change log, I see that the person responsible for
> the offending line was... erm, well, me. In which case you can definitely
> put this one down to incompetence :-(

Maybe it was an oversight of me when porting from stdio to PIO...

> PS However, more documentation for the IO ops (and the IO subsystem
> generally) would be a Good Thing, and might stop this sort of thing
> from happening in the future.

I'm working on this. But at the moment I try to get ParrotIO away from
sys_mem_allocate/sys_mem_free to the garbage-collector, but there are
still bugs left.

I promise more documentation, but dont hold the breath

bye
boe
--
Juergen Boemmels boem...@physik.uni-kl.de
Fachbereich Physik Tel: ++49-(0)631-205-2817
Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906
PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47

0 new messages