Menu

#692 missing output for DISPLAY WITH NO ADVANCING

GC 3.1
closed
libcob (19)
5 - default
2020-12-15
2020-12-15
No

The following code normally shows the output before the display:

        PROGRAM-ID. 'test'.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        77 SOME  PIC X.
        PROCEDURE DIVISION.
        DISPLAY "Test: " WITH NO ADVANCING
        ACCEPT SOME.
        GOBACK. 

But it doesn't do this if stdout is "captured":

exec 1> >(tee -a logfile) && exec 2> >(tee -a logfile >&2)

The issue exists since OC 0.33...

Related

Commit: [r4792]
Commit: [r4925]
Discussion: NO ADVANCING Problem?
Discussion: NO ADVANCING Problem?

Discussion

  • Simon Sobisch

    Simon Sobisch - 2020-12-15

    First patch:

    @@ -262,6 +262,8 @@
        display_alnum (f, fp);
     }
    
    +static cob_u32_t   pending_flush;
    +
     void
     cob_display (const int to_device, const int newline, const int varcnt, ...)
     {
    @@ -381,6 +383,9 @@
        if (newline && !disp_redirect) {
            putc ('\n', fp);
            fflush (fp);
    
    +       pending_flush = 0;
    +   } else if (fp == stdout) {
    +       pending_flush = 1;
        }
     #ifdef HAVE_POPEN
        if (pclose_fp) {
    @@ -917,6 +922,11 @@
                memset (COB_MODULE_PTR->crt_status->data, '0', (size_t)4);
            }
        }
    +   if (pending_flush) {
    +       pending_flush = 0;
    +       fflush (stdout);
    +   }
    +
        /* extension: ACCEPT OMITTED */
        if (unlikely (!f)) {
            for (; ; ) {
    

    ... but it is may be more reasonable to always flush before accepting data and drop the additional variable and checks (the unnecessary flush could only be a minor issue if input does not come from the keyboard but a redirection).

     
  • Simon Sobisch

    Simon Sobisch - 2020-12-15
    • status: accepted --> closed
     
  • Simon Sobisch

    Simon Sobisch - 2020-12-15

    Fixed with [r4088], will be merged to 3.1 soon with next merge.

     

    Related

    Commit: [r4088]


Log in to post a comment.

MongoDB Logo MongoDB