alt.org stuff - Problems with this forum or with alt.org in general?
 
User: [Log In] [Create A New Profile]
Actions: [New Topic] [Print View] [RSS]
Search
Path: [NAO] [Forums] [alt.org stuff]
Topic:
Curses interface bug (2 Posts)
Started By:
Date:
April 04, 2012 02:37AM

Curses interface bug
chasonr - April 04, 2012 02:37AM
 
Doing the '/' command and selecting a piece of food gives:

0x0.00005087b0058p-1022 piece of Pick an object.

This only happens with the curses interface; the tty interface gives the expected results.

That string of hex digits with the p-1022 is a floating point number as formatted by %a on a C99-compliant sprintf. The expected string is something like "% a piece of food...", which begins with %a with several spaces in between.

Perhaps whatever's displaying that line is passing it as the format string (naughty!) instead of passing it through "%s"? Recent GCCs will warn if you do that.
 

Re: Curses interface bug
chasonr - April 04, 2012 02:55AM
 
I have tracked down the bug. It appears twice in win/curses/cursmesg.c, at lines 131 and 148. Here is a patch to fix it; hopefully the whitespace won't get too badly munged:

--- nethack-3.4.3-curses/win/curses/cursmesg.c.old 2011-03-18 03:45:59.545794085 -0400
+++ nethack-3.4.3-curses/win/curses/cursmesg.c 2012-04-03 23:01:07.738509926 -0400
@@ -128,7 +128,7 @@
if ((mx == border_space) && ((message_length + 2) > width))
{
tmpstr = curses_break_str(message, (width - 2), 1);
- mvwprintw(win, my, mx, tmpstr);
+ mvwaddstr(win, my, mx, tmpstr);
mx += strlen(tmpstr);
if (strlen(tmpstr) < (width - 2))
{
@@ -145,7 +145,7 @@
}
else
{
- mvwprintw(win, my, mx, message);
+ mvwaddstr(win, my, mx, message);
curses_toggle_color_attr(win, NONE, A_BOLD, OFF);
mx += message_length + 1;
}
 

Go to Topic: [Previous] [Next]