From ffc023930d2fc1b445cacc8ac507aaa79ee4a009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 27 Nov 2004 13:14:19 +0000 Subject: [PATCH] Reverted back to an older version of freopen.c (1.15 from sources.redhat.com, which doesn't use fd_to_filename() yet) and added it to the build. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10271 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/glibc/libio/Jamfile | 2 +- .../libroot/posix/glibc/libio/freopen.c | 35 ++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/kernel/libroot/posix/glibc/libio/Jamfile b/src/kernel/libroot/posix/glibc/libio/Jamfile index 893b067aa0..8c137a7a9d 100644 --- a/src/kernel/libroot/posix/glibc/libio/Jamfile +++ b/src/kernel/libroot/posix/glibc/libio/Jamfile @@ -25,7 +25,7 @@ KernelMergeObject posix_gnu_libio.o : <$(SOURCE_GRIST)>flockfile.c <$(SOURCE_GRIST)>fputc.c <$(SOURCE_GRIST)>fputc_u.c -# <$(SOURCE_GRIST)>freopen.c + <$(SOURCE_GRIST)>freopen.c <$(SOURCE_GRIST)>fseek.c <$(SOURCE_GRIST)>fseeko.c <$(SOURCE_GRIST)>ftello.c diff --git a/src/kernel/libroot/posix/glibc/libio/freopen.c b/src/kernel/libroot/posix/glibc/libio/freopen.c index bf2d7688c3..0b4e889cd0 100644 --- a/src/kernel/libroot/posix/glibc/libio/freopen.c +++ b/src/kernel/libroot/posix/glibc/libio/freopen.c @@ -27,9 +27,41 @@ #include "libioP.h" #include "stdio.h" -#include #include + +FILE* +freopen (filename, mode, fp) + const char* filename; + const char* mode; + FILE* fp; +{ + FILE *result; + CHECK_FILE (fp, NULL); + if (!(fp->_flags & _IO_IS_FILEBUF)) + return NULL; + _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); + _IO_flockfile (fp); +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + if (&_IO_stdin_used == NULL) + /* If the shared C library is used by the application binary which + was linked against the older version of libio, we just use the + older one even for internal use to avoid trouble since a pointer + to the old libio may be passed into shared C library and wind + up here. */ + result = _IO_old_freopen (filename, mode, fp); + else +#endif + result = _IO_freopen (filename, mode, fp); + if (result != NULL) + /* unbound stream orientation */ + result->_mode = 0; + _IO_funlockfile (fp); + _IO_cleanup_region_end (0); + return result; +} + +#if 0 #include FILE* @@ -87,3 +119,4 @@ freopen (filename, mode, fp) _IO_cleanup_region_end (0); return result; } +#endif