From: Andrew Stevens (as@prg.ox.ac.uk)
Date: 06/07/92


From: as@prg.ox.ac.uk (Andrew Stevens)
Subject: Re: Misbehaving Pcomm
Date: 7 Jun 1992 14:19:40 GMT


Dear all,

I think I've pinned down the source of the trouble with pcomm. As
suspected a faulty library seems to blame. The program pcomm_input
(which echoes incoming data from serial port to user tty) does a setbuf
of stdout to turn off buffering. This, under my version of the library
(gcc 2.1 0.95a) doesn't seem to work. I have no idea if this is fixed
in later versions of the library. The simple workaround until a lib fix
arrives / until you relink with a suitably up to date lib is to apply
the following patch:

(Yes, it really was that trivial in the end. I hang my head in shame at
not diving into the code earlier...)

======CUT HERE =========================================
*** input.c Sun Jun 7 14:32:01 1992
--- input.c.old Sun Jun 7 14:56:43 1992
***************
*** 235,248 ****
                                        /* output in smaller chunks */
                        if (out_cnt >= OUTPUT_BUF) {
                                fwrite(out_buf, sizeof(char), out_cnt, stdout);
- fflush(stdout);
                                out_cnt = 0;
                        }
                }
! if (out_cnt) {
                        fwrite(out_buf, sizeof(char), out_cnt, stdout);
- fflush(stdout);
- }
        }
  }
  
--- 235,245 ----
                                        /* output in smaller chunks */
                        if (out_cnt >= OUTPUT_BUF) {
                                fwrite(out_buf, sizeof(char), out_cnt, stdout);
                                out_cnt = 0;
                        }
                }
! if (out_cnt)
                        fwrite(out_buf, sizeof(char), out_cnt, stdout);
        }
  }
  
        Andrew Stevens
      Programmming Research Group JANET: Andrew.Stevens@uk.ac.oxford.prg
     11 Keble Road, Oxford, England UUCP: ...!uunet!mcvax!ukc!ox-prg!as
     OX1 3QD +44 0865 272563