From: cohrs Date: Thu, 21 Feb 2002 07:10:30 +0000 (+0000) Subject: fix tty crashes for empty news file X-Git-Tag: MOVE2GIT~3147 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5edf5d01e719f1e876dec6060cf87dc68243b93;p=nethack fix tty crashes for empty news file - menu-window code could access a null pointer when there was no data - menu-window code can't handle empty contents, because there's no place to position the cursor, so force text mode - still looked ugly, so added a check to avoid displaying anything if the file was empty --- diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 344d5a4e0..ced54c1ed 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1243,8 +1243,10 @@ struct WinDesc *cw; if (cw->npages > 1) Sprintf(cw->morestr, "(%d of %d)", curr_page + 1, (int) cw->npages); - else + else if (msave) Strcpy(cw->morestr, msave); + else + Strcpy(cw->morestr, defmorestr); tty_curs(window, 1, page_lines); cl_end(); @@ -1517,7 +1519,7 @@ tty_display_nhwindow(window, blocking) } else tty_clear_nhwindow(WIN_MESSAGE); - if (cw->data) + if (cw->data || !cw->maxrow) process_text_window(window, cw); else process_menu_window(window, cw); @@ -1910,6 +1912,8 @@ boolean complain; } else if(u.ux) docrt(); } else { winid datawin = tty_create_nhwindow(NHW_TEXT); + boolean empty = TRUE; + if(complain #ifndef NO_TERMS && nh_CD @@ -1926,11 +1930,12 @@ boolean complain; if ((cr = index(buf, '\r')) != 0) *cr = 0; #endif if (index(buf, '\t') != 0) (void) tabexpand(buf); + empty = FALSE; tty_putstr(datawin, 0, buf); if(wins[datawin]->flags & WIN_CANCELLED) break; } - tty_display_nhwindow(datawin, FALSE); + if (!empty) tty_display_nhwindow(datawin, FALSE); tty_destroy_nhwindow(datawin); (void) dlb_fclose(f); }