9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] reading addr always returns #0,#0?
@ 2013-08-31 17:23 James A. Robinson
  2013-08-31 17:29 ` James A. Robinson
  0 siblings, 1 reply; 5+ messages in thread
From: James A. Robinson @ 2013-08-31 17:23 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

Say I have an acme window with a $winid of 2.
If I type the following commands:

$ echo -n , | 9p write acme/2/addr
$ echo dot=addr | 9p write acme/2/ctl

I see the entire text of the window get selected.
I had assumed that if I then read addr that I would
get back two numbers, 0 and the final byte offset
of the file (it is a non-zero length file).

However, I get back two zeros:

$ 9p read acme/2/addr
          0           0

What am I missing?

Jim

[-- Attachment #2: Type: text/html, Size: 735 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] reading addr always returns #0,#0?
  2013-08-31 17:23 [9fans] reading addr always returns #0,#0? James A. Robinson
@ 2013-08-31 17:29 ` James A. Robinson
  2013-09-02 10:13   ` Alexander Sychev
  0 siblings, 1 reply; 5+ messages in thread
From: James A. Robinson @ 2013-08-31 17:29 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

On Sat, Aug 31, 2013 at 10:23 AM, James A. Robinson <
jimr@highwire.stanford.edu> wrote:

> I see the entire text of the window get selected.
> I had assumed that if I then read addr that I would
> get back two numbers, 0 and the final byte offset
> of the file (it is a non-zero length file).
>
> However, I get back two zeros:
>
> $ 9p read acme/2/addr
>           0           0
>
> What am I missing?
>

I should have said character offset, not byte offset.
I was also experimenting with using addr=dot, but
didn't see any change in behavior.

Jim

[-- Attachment #2: Type: text/html, Size: 1152 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] reading addr always returns #0,#0?
  2013-08-31 17:29 ` James A. Robinson
@ 2013-09-02 10:13   ` Alexander Sychev
  2013-09-02 10:38     ` dexen deVries
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Sychev @ 2013-09-02 10:13 UTC (permalink / raw)
  To: jimr, Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 2171 bytes --]

Hi,
The problem is the "addr" file is closed between your calls. When you open
the "addr" file next time, an internal address is set to 0,0.
But after the writing the address is actual and if you read "data" file you
will see the text according to your address.

I you write the code on C or Go without a closing a descriptor of "addr"
file, everything will be ok :-)
<------------------------------------------------------------------------------------->
santucco@santucco ~/work/go/src/test $ cat test.go
package main

import (
        "bitbucket.org/santucco/goacme"
        "fmt"
        "io"
)

func main() {
        w, err:=goacme.New()
        if err!=nil {
                panic(err)
        }
        defer w.Close()
        if _, err:=w.Write([]byte("test\ntest2\n")); err!=nil {
                panic(err)
        }
        if err:=w.WriteAddr("#5,#10"); err!=nil {
                panic(err)
        }
        f, err:=w.File("addr")
        if err!=nil {
                panic(err)
        }
        b:=make([]byte,100)
        if _, err:=f.Read(b); err!=nil&&err!=io.EOF {
                panic(err)
        }
        fmt.Println(string(b))
}
santucco@santucco ~/work/go/src/test $ go build
santucco@santucco ~/work/go/src/test $ ./test
          5          10

<------------------------------------------------------------------------------------->
Best regards,
  santucco


On Sat, Aug 31, 2013 at 9:29 PM, James A. Robinson <
jimr@highwire.stanford.edu> wrote:

> On Sat, Aug 31, 2013 at 10:23 AM, James A. Robinson <
> jimr@highwire.stanford.edu> wrote:
>
>> I see the entire text of the window get selected.
>> I had assumed that if I then read addr that I would
>> get back two numbers, 0 and the final byte offset
>> of the file (it is a non-zero length file).
>>
>> However, I get back two zeros:
>>
>> $ 9p read acme/2/addr
>>           0           0
>>
>> What am I missing?
>>
>
> I should have said character offset, not byte offset.
> I was also experimenting with using addr=dot, but
> didn't see any change in behavior.
>
> Jim
>
>


--
Best regards,
  santucco

[-- Attachment #2: Type: text/html, Size: 3679 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] reading addr always returns #0,#0?
  2013-09-02 10:13   ` Alexander Sychev
@ 2013-09-02 10:38     ` dexen deVries
  2013-09-02 15:25       ` James A. Robinson
  0 siblings, 1 reply; 5+ messages in thread
From: dexen deVries @ 2013-09-02 10:38 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Monday 02 of September 2013 14:13:56 Alexander Sychev wrote:
> The problem is the "addr" file is closed between your calls. When you open
> the "addr" file next time, an internal address is set to 0,0.
> But after the writing the address is actual and if you read "data" file you
> will see the text according to your address.
> 
> I you write the code on C or Go without a closing a descriptor of "addr"
> file, everything will be ok :-)


or use 9p rdwr:


echo -n , | 9p write acme/2/addr
echo 'dot=addr' | 9p rdwr acme/2/ctl 

-- 
dexen deVries

[[[↓][→]]]

Take care of the luxuries and the necessities will take care of themselves.
                -- L. Long




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] reading addr always returns #0,#0?
  2013-09-02 10:38     ` dexen deVries
@ 2013-09-02 15:25       ` James A. Robinson
  0 siblings, 0 replies; 5+ messages in thread
From: James A. Robinson @ 2013-09-02 15:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]

Thank you both for the explanation!


On Mon, Sep 2, 2013 at 3:38 AM, dexen deVries <dexen.devries@gmail.com>wrote:

> On Monday 02 of September 2013 14:13:56 Alexander Sychev wrote:
> > The problem is the "addr" file is closed between your calls. When you
> open
> > the "addr" file next time, an internal address is set to 0,0.
> > But after the writing the address is actual and if you read "data" file
> you
> > will see the text according to your address.
> >
> > I you write the code on C or Go without a closing a descriptor of "addr"
> > file, everything will be ok :-)
>
>
> or use 9p rdwr:
>
>
> echo -n , | 9p write acme/2/addr
> echo 'dot=addr' | 9p rdwr acme/2/ctl
>
> --
> dexen deVries
>
> [[[↓][→]]]
>
> Take care of the luxuries and the necessities will take care of themselves.
>                 -- L. Long
>
>
>

[-- Attachment #2: Type: text/html, Size: 1401 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-02 15:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-31 17:23 [9fans] reading addr always returns #0,#0? James A. Robinson
2013-08-31 17:29 ` James A. Robinson
2013-09-02 10:13   ` Alexander Sychev
2013-09-02 10:38     ` dexen deVries
2013-09-02 15:25       ` James A. Robinson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).