]> diplodocus.org Git - nmh/commitdiff
scan(1) now checks for full output device [Bug #50925].
authorDavid Levine <levinedl@acm.org>
Sun, 28 Oct 2018 18:27:39 +0000 (14:27 -0400)
committerDavid Levine <levinedl@acm.org>
Sun, 28 Oct 2018 18:27:39 +0000 (14:27 -0400)
Added fflush(3) after every output line:  may slow down scan on
output with large number of lines.

docs/pending-release-notes
test/scan/test-scan
uip/scan.c
uip/scansbr.c

index 138a909..4623da5 100644 (file)
@@ -19,3 +19,4 @@ DEPRECATED FEATURES
 BUG FIXES
 ---------
 
 BUG FIXES
 ---------
 
+- scan(1) now checks for full output device [Bug #50925].
\ No newline at end of file
index 00e383c..510ad36 100755 (executable)
@@ -39,6 +39,15 @@ run_prog scan +inbox -width 80 >"$actual" || exit 1
 check "$expected" "$actual"
 
 
 check "$expected" "$actual"
 
 
+# check full output device, if one exists
+if test -c /dev/full; then
+  start_test 'full output device'
+  printf 'scan: failed to fflush stdout: No space left on device\n' >"$expected"
+  scan last >/dev/full 2>"$actual"  &&  false
+  check "$expected" "$actual"
+fi
+
+
 # check highlighting
 start_test 'highlighting'
 cat >"$expected" <<EOF
 # check highlighting
 start_test 'highlighting'
 cat >"$expected" <<EOF
index b999378..c85a9ef 100644 (file)
@@ -299,8 +299,9 @@ main (int argc, char **argv)
            scan_finished ();
            hdrflag = false;
            fclose (in);
            scan_finished ();
            hdrflag = false;
            fclose (in);
-           if (ontty)
-               fflush (stdout);
+           if (ontty  &&  fflush (stdout) == EOF) {
+               adios("stdout", "failed to fflush");
+           }
        }
     }
     charstring_free (scanl);
        }
     }
     charstring_free (scanl);
index 38b2ca4..2d281c2 100644 (file)
@@ -340,8 +340,14 @@ finished:
     if (bodycomp)
        bodycomp->c_text = saved_c_text;
 
     if (bodycomp)
        bodycomp->c_text = saved_c_text;
 
-    if (noisy)
-       fputs (charstring_buffer (*scanl), stdout);
+    if (noisy) {
+       if (fputs (charstring_buffer (*scanl), stdout) == EOF) {
+           adios("stdout", "failed to fputs");
+       }
+       if (fflush (stdout)) {
+           adios("stdout", "failed to fflush");
+       }
+    }
 
     cptr = fmt_findcomp ("encrypted");
     encrypted = cptr && cptr->c_text;
 
     cptr = fmt_findcomp ("encrypted");
     encrypted = cptr && cptr->c_text;