[comp.os.minix] Fix to _fopen.c in estdio version 2.1

ghelmer@dsuvax.uucp (Guy Helmer) (04/15/91)

Here's a quick change to Earl Chew's stdio that I believe mimics the
behavior of other stdio implementations, at least the BSD and Microsoft C
environments, if nothing else.  When a file is fopen'ed with the "a"
option, ftell() would return incorrect values for the location of
the file pointer until a write from the stdio buffer was forced.
This change corrects the behavior for the case of a single process
appending a file.  To account for multiple writers appending to a file
through stdio, much more work would be required; I've chosen to not
concern myself with this more general case yet (right now I just need the
functionality for a single process).

Here's the straight fix.  It's small enough that BITNET and other
mail-munching networks shouldn't render it unreadable even though it's
in source form:

*** _fopen.c.orig	Thu Aug  9 03:06:05 1990
--- _fopen.c	Thu Apr  4 18:56:47 1991
***************
*** 68,73 ****
      if (fd < 0)
        fd = open(name, openmode, CREATMODE);
    }
! 
    return fd;
  }
--- 68,74 ----
      if (fd < 0)
        fd = open(name, openmode, CREATMODE);
    }
!   if (fd > -1 && (openmode & O_APPEND) != 0)
!     lseek(fd, 0L, SEEK_END);
    return fd;
  }

-- 
Guy Helmer, Dakota State University Computing Services
helmer@sdnet.bitnet, dsuvax!ghelmer@wunoc.wustl.edu, wupost!dsuvax!ghelmer
"I'm a cowboy, on a keyboard I ride..."
                                        -- with apologies to Bon Jovi