]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
don't abort from whiptail gauge on SIGWINCH
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Mar 2008 19:59:19 +0000 (20:59 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 21 Mar 2008 12:00:20 +0000 (13:00 +0100)
dialogboxes.c

index d3caee0b3eebcf5e0a7973ddea5116962c31dfb7..4d298a06b89d7a53f40df207a20a4cd07b126029 100644 (file)
@@ -137,37 +137,40 @@ int gauge(const char * text, int height, int width, poptContext optCon, int fd,
     newtDrawForm(form);
     newtRefresh();
 
-    while (fgets(buf, sizeof(buf) - 1, f)) {
+    do {
+       if (!fgets(buf, sizeof(buf) - 1, f))
+           continue;
        buf[strlen(buf) - 1] = '\0';
 
        if (!strcmp(buf, "XXX")) {
-           if (!fgets(buf3, sizeof(buf3) - 1, f))
+           while (!fgets(buf3, sizeof(buf3) - 1, f) && !feof(f))
+               ;
+           if (feof(f))
                break;
            buf3[strlen(buf3) - 1] = '\0';
-           arg = buf3;
 
            i = 0;
-           while (fgets(buf + i, sizeof(buf) - 1 - i, f)) {
+           do {
+               if (!fgets(buf + i, sizeof(buf) - 1 - i, f))
+                   continue;
                buf[strlen(buf) - 1] = '\0';
                if (!strcmp(buf + i, "XXX")) {
                    *(buf + i) = '\0';
                    break;
                }
                i = strlen(buf);
-           }
+           } while (!feof(f));
 
            newtTextboxSetText(tb, buf);
-       } else {
-           arg = buf;
        }
 
        val = strtoul(buf, &end, 10);
-       if (!*end) {
+       if (*buf && !*end) {
            newtScaleSet(scale, val);
            newtDrawForm(form);
            newtRefresh();
        }
-    }
+    } while (!feof(f));
 
     return DLG_OKAY;
 }