groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 10/35: [grohtml]: Flush stderr in pre-html more often.


From: G. Branden Robinson
Subject: [groff] 10/35: [grohtml]: Flush stderr in pre-html more often.
Date: Fri, 15 Jul 2022 23:11:57 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 5a58e77c116d2e6579ddc625ddb4775ee667316d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Jul 8 18:04:15 2022 -0500

    [grohtml]: Flush stderr in pre-html more often.
    
    * src/preproc/html/pre-html.cpp (generateImages): Flush the standard
      error stream after writing to it in a loop.
    
    Also fix code style nit: drop space between function call and opening
    paren.
    
    Also elaborate a comment.
---
 ChangeLog                     | 5 +++++
 src/preproc/html/pre-html.cpp | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index edbb811a..924a43ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-07-08  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/html/pre-html.cpp (generateImages): Flush the
+       standard error stream after writing to it in a loop.
+
 2022-07-08  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/s.tmac (RP): Recognize new optional arguments
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 21860b8f..4f2dfdc3 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -1090,6 +1090,7 @@ static void generateImages(char *region_file_name)
       fputc(f->getPB(), stderr);
     }
   }
+  fflush(stderr);
 
   listOfImages.createImages();
   if (want_progress_report) {
@@ -1109,7 +1110,7 @@ static void set_redirection(int was, int willbe)
   // Nothing to do if 'was' and 'willbe' already have same handle.
   if (was != willbe) {
     // Otherwise attempt the specified redirection.
-    if (dup2 (willbe, was) < 0) {
+    if (dup2(willbe, was) < 0) {
       // Redirection failed, so issue diagnostic and bail out.
       fprintf(stderr, "failed to replace fd=%d with %d\n", was, willbe);
       if (willbe == STDOUT_FILENO)
@@ -1306,7 +1307,9 @@ int char_buffer::run_output_filter(int filter, int argc, 
char **argv)
     // The IMAGE_OUTPUT_FILTER needs special output redirection...
 
     if (filter == IMAGE_OUTPUT_FILTER) {
-      // with BOTH 'stdout' AND 'stderr' diverted to files.
+      // ...with BOTH 'stdout' AND 'stderr' diverted to files, the
+      // latter so that `generateImages()` can scrape "grohtml-info"
+      // from it.
 
       set_redirection(STDOUT_FILENO, PS_OUTPUT_STREAM);
       set_redirection(STDERR_FILENO, REGION_OUTPUT_STREAM);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]