diff options
author | Robert de Bath <rdebath@poboxes.com> | 1999-06-11 14:11:38 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:41:25 +0200 |
commit | 3d4957c86ff239b24b43933924ec72a3fd288518 (patch) | |
tree | da8225a4d7bb2d9123e10d558cdc3eebae6254c8 /libc/stdio2 | |
parent | e62b35169cdcd13632ae353b1e5ffde7dec44201 (diff) | |
download | dev86-3d4957c86ff239b24b43933924ec72a3fd288518.tar.gz |
Import Dev86src-0.14.8.tar.gzv0.14.8
Diffstat (limited to 'libc/stdio2')
-rw-r--r-- | libc/stdio2/stdio.c | 18 | ||||
-rw-r--r-- | libc/stdio2/stdio.h | 2 |
2 files changed, 14 insertions, 6 deletions
diff --git a/libc/stdio2/stdio.c b/libc/stdio2/stdio.c index c317859..6b0dba0 100644 --- a/libc/stdio2/stdio.c +++ b/libc/stdio2/stdio.c @@ -675,6 +675,11 @@ char *mode; { if (nfp) free(nfp); + if (fp) + { + fp->mode |= fopen_mode; + fclose(fp); /* Deallocate if required */ + } return 0; } @@ -730,12 +735,15 @@ FILE *fp; errno = EINVAL; return EOF; } - if (fflush(fp)) - return EOF; + if (fp->fd != -1) + { + if (fflush(fp)) + return EOF; - if (close(fp->fd)) - rv = EOF; - fp->fd = -1; + if (close(fp->fd)) + rv = EOF; + fp->fd = -1; + } if (fp->mode & __MODE_FREEBUF) { diff --git a/libc/stdio2/stdio.h b/libc/stdio2/stdio.h index 98ca38a..fd10923 100644 --- a/libc/stdio2/stdio.h +++ b/libc/stdio2/stdio.h @@ -56,7 +56,7 @@ struct __stdio_file { #define EOF (-1) #ifndef NULL -#define NULL (0) +#define NULL ((void*)0) #endif typedef struct __stdio_file FILE; |