Date: Tue, 11 Aug 2009 13:27:30 +0200 (CEST) From: Stefan Bethke <stb@lassitu.de> To: FreeBSD-gnats-submit@FreeBSD.org Subject: gnu/137665: [patch] dialog goes into tight loop on encountering eof Message-ID: <200908111127.n7BBRUqk031516@koef.zs64.net> Resent-Message-ID: <200908111150.n7BBo6mp021897@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 137665 >Category: gnu >Synopsis: [patch] dialog goes into tight loop on encountering eof >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Aug 11 11:50:05 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Stefan Bethke >Release: FreeBSD 8.0-BETA2 amd64 >Organization: >Environment: System: FreeBSD diesel.lassitu.de 8.0-BETA2 FreeBSD 8.0-BETA2 #8 r195941: Wed Jul 29 15:55:32 CEST 2009 root@diesel.lassitu.de:/usr/obj/usr/src/sys/DIESEL amd64 >Description: >How-To-Repeat: dialog --yesno foo -1 -1 </dev/null Other variants suffer from the same problem. None of the invocations of wgetch() check for error conditions, and the input loops usually terminate only upon certain keys. This leads to a tight loop of calling wgetch(), which returns ERR immediately. The usual while or for look then calls wgetch() again. >Fix: This patch checks for wgetch() return value of ERR, and takes the same action as the user pressing escape. Index: msgbox.c =================================================================== --- msgbox.c (revision 195941) +++ msgbox.c (working copy) @@ -97,7 +97,7 @@ display_helpline(dialog, height-1, width); print_button(dialog, " OK ", height-2, width/2-6, TRUE); wrefresh(dialog); - while (key != ESC && key != '\n' && key != ' ' && key != '\r') + while (key != ERR && key != ESC && key != '\n' && key != ' ' && key != '\r') key = wgetch(dialog); if (key == '\r') key = '\n'; Index: inputbox.c =================================================================== --- inputbox.c (revision 195941) +++ inputbox.c (working copy) @@ -181,6 +181,9 @@ case '?': display_helpfile(); break; + case ERR: + key = ESC; + break; } } Index: checklist.c =================================================================== --- checklist.c (revision 195941) +++ checklist.c (working copy) @@ -202,6 +202,11 @@ while (key != ESC) { key = wgetch(dialog); + if (key == ERR) { + key = ESC; + break; + } + /* Shortcut to OK? */ if (toupper(key) == okButton) { if (ditems) { Index: ui_objects.c =================================================================== --- ui_objects.c (revision 195941) +++ ui_objects.c (working copy) @@ -666,7 +666,7 @@ if (!quit) key = wgetch(lo->win); } - if (key == ESC) { + if (key == ESC || key == ERR) { return(SEL_ESC); } if (key == '\t') { Index: lineedit.c =================================================================== --- lineedit.c (revision 195941) +++ lineedit.c (working copy) @@ -66,6 +66,7 @@ case KEY_F(1): display_helpfile(); break; + case ERR: case TAB: case KEY_BTAB: case KEY_UP: Index: textbox.c =================================================================== --- textbox.c (revision 195941) +++ textbox.c (working copy) @@ -411,6 +411,7 @@ else /* no need to find */ fprintf(stderr, "\a"); /* beep */ break; + case ERR: case ESC: break; case KEY_F(1): Index: yesno.c =================================================================== --- yesno.c (revision 195941) +++ yesno.c (working copy) @@ -159,6 +159,9 @@ case '?': display_helpfile(); break; + case ERR: + key = ESC; + break; } } Index: tree.c =================================================================== --- tree.c (revision 195941) +++ tree.c (working copy) @@ -446,6 +446,7 @@ if (!button) *result = scroll+choice; return button; + case ERR: case ESC: break; case KEY_F(1): Index: prgbox.c =================================================================== --- prgbox.c (revision 195941) +++ prgbox.c (working copy) @@ -136,7 +136,7 @@ display_helpline(dialog, height-1, width); print_button(dialog, " OK ", height-2, width/2-6, TRUE); wrefresh(dialog); - while (key != ESC && key != '\n' && key != ' ' && key != '\r') + while (key != ERR && key != ESC && key != '\n' && key != ' ' && key != '\r') key = wgetch(dialog); if (key == '\r') key = '\n'; Index: menubox.c =================================================================== --- menubox.c (revision 195941) +++ menubox.c (working copy) @@ -187,6 +187,11 @@ while (key != ESC) { key = wgetch(dialog); + if (key == ERR) { + key = ESC; + break; + } + /* Shortcut to OK? */ if (toupper(key) == okButton) { if (ditems) { Index: radiolist.c =================================================================== --- radiolist.c (revision 195941) +++ radiolist.c (working copy) @@ -544,7 +544,8 @@ key = ESC; break; } - + + case ERR: case ESC: rval = -1; break; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908111127.n7BBRUqk031516>