Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#158 closed defect (fixed)

Incorrect mapping of ncurses C string-retrieval functions to Scheme procedures

Reported by: Neil Santos Owned by: felix winkelmann
Priority: major Milestone:
Component: extensions Version: 4.3.x
Keywords: ncurses Cc:
Estimated difficulty:

Description

There's a bunch of ncurses functions that aren't properly mapped to Scheme-y equivalents. All of the ones I've stumbled upon related to retrieving input strings. To wit:

  • (getnstr STRING)
  • (getstr STRING)
  • (mvgetnstr INT INT STRING INT)
  • (mvgetstr INT INT STRING)
  • (mvwgetnstr WINDOW INT INT STRING INT)
  • (mvwgetstr WINDOW INT INT STRING)
  • (wgetnstr WINDOW STRING INT)

The bug is that, as with their C counterparts, the Scheme procedures expect a STRING argument. The C functions expect to be able to use said argument as a pointer to the retrieved string.

The Scheme mappings should instead return the retrieved string.

Attachments (1)

reverted-realname-fix.txt (1.3 KB) - added by Jim Ursetto 14 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 14 years ago by Jim Ursetto

I'm pretty sure those Scheme procedures take a pointer argument.

However I can't verify because I am getting a bus error trying to compile ncurses with latest Chicken master. (!)

comment:2 in reply to:  1 Changed 14 years ago by felix winkelmann

Replying to zbigniew:

I'm pretty sure those Scheme procedures take a pointer argument.

Yes, they are declared as receiving a pointer.

However I can't verify because I am getting a bus error trying to compile ncurses with latest Chicken master. (!)

What platform?

comment:3 Changed 14 years ago by Jim Ursetto

Felix: offending commit is

  • 2b2fab2 drop previous safe toplevel assigns if assigned multiple times

Reverting corrects the bus error when compiling ncurses egg.
Platform macosx

comment:4 Changed 14 years ago by Jim Ursetto

nsantos: Works for me. Are you contending the interface does not work (it does) or that it's not particularly Scheme-like (a valid point)? See below.

#;> (initscr)
#;> (define s (make-string 10))
#;> (getnstr s 10)
abcdef
#;> s
"abcdef\x00 "

comment:5 in reply to:  4 ; Changed 14 years ago by Neil Santos

Replying to zbigniew:

nsantos: Works for me. Are you contending the interface does not work (it does) or that it's not particularly Scheme-like (a valid point)?

Yes on the latter, although it's mostly a nice-to-have at this point. This is the ncurses error I'm getting, preceded by code I'm trying to get to work.

(define (input-loop entry-window mailbox)
  (make-thread
   (lambda ()
     (let loop ((input ""))
       (mvwgetstr entry-window 0 0 input)
       (mailbox-send! mailbox input)
       (loop "")))))

The error being,

Warning (#<thread: thread929>): : curses error
Call history:

  <eval>          [input-loop] ((##core#letrec ((loop (##core#loop-lambda (input) (mvwgetstr entry-window 0 0 input) (mailbox-send!......
  <eval>          [input-loop] (mvwgetstr entry-window 0 0 input) <-- Warning (#<thread: thread927>): : <condition> (uncaught-exception)

Error: uncaught exception: #<condition: (uncaught-exception)>

comment:6 in reply to:  3 ; Changed 14 years ago by felix winkelmann

Replying to zbigniew:

Felix: offending commit is

  • 2b2fab2 drop previous safe toplevel assigns if assigned multiple times

Reverting corrects the bus error when compiling ncurses egg.
Platform macosx

This actually appears to be a compiler bug. I'm working on it.

comment:7 in reply to:  6 ; Changed 14 years ago by felix winkelmann

Replying to felix:

Replying to zbigniew:

Felix: offending commit is

  • 2b2fab2 drop previous safe toplevel assigns if assigned multiple times

Reverting corrects the bus error when compiling ncurses egg.
Platform macosx

This actually appears to be a compiler bug. I'm working on it.

(of course it's a compiler bug - I mean it is caused by an incorrect entry in an internal table, not so much by the optimization introduced by the commit you mentioned)

comment:8 in reply to:  7 ; Changed 14 years ago by felix winkelmann

Replying to felix:

Replying to felix:

Replying to zbigniew:

Felix: offending commit is

  • 2b2fab2 drop previous safe toplevel assigns if assigned multiple times

Reverting corrects the bus error when compiling ncurses egg.
Platform macosx

This actually appears to be a compiler bug. I'm working on it.

(of course it's a compiler bug - I mean it is caused by an incorrect entry in an internal table, not so much by the optimization introduced by the commit you mentioned)

Jim, I have committed a change to master. Can you give ncurses a try? I don't have access to a UNIX machine right now.

comment:9 in reply to:  5 Changed 14 years ago by Neil Santos

Replying to nsantos:

Warning (#<thread: thread929>): : curses error
Call history:

Ah! Found it! I call (nodelay) on the target window after it gets drawn; when I removed that, it worked.

There's still the matter of the not-very-Scheme-y feel of the calls, but I supposed I should open a new ticket for that? Feel free to close this ticket when you guys are through working out that bug zbigniew pointed out.

Thanks!

comment:10 in reply to:  8 ; Changed 14 years ago by Jim Ursetto

Replying to felix:

Jim, I have committed a change to master. Can you give ncurses a try? I don't have access to a UNIX machine right now.

Works in c08efe2b8, BUT looks like you accidentally reverted it in 21a4cae97, possibly along with some changes to the mingw makefiles. Probably working tree was in a bad state. See attached for example.

Changed 14 years ago by Jim Ursetto

Attachment: reverted-realname-fix.txt added

comment:11 in reply to:  10 Changed 14 years ago by felix winkelmann

Replying to zbigniew:

Replying to felix:

Jim, I have committed a change to master. Can you give ncurses a try? I don't have access to a UNIX machine right now.

Works in c08efe2b8, BUT looks like you accidentally reverted it in 21a4cae97, possibly along with some changes to the mingw makefiles. Probably working tree was in a bad state. See attached for example.

Argh. Thanks for telling me. I've repaired it (I think).

comment:12 Changed 14 years ago by Jim Ursetto

Resolution: fixed
Status: newclosed

Yep, it is fixed now. Thanks!

nsantos: I am closing this ticket since it kind of got offtopic. Feel free to open another one with your concerns on the API. However, I do not think it is being actively maintained, so you may want to ask someone for help on the list.

comment:13 Changed 14 years ago by (none)

Milestone 4.4.0 deleted

Note: See TracTickets for help on using tickets.