From 391d844acaa0608cf178718260186e58a8433ca6 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 14 Jan 2013 21:53:49 +0100 Subject: [PATCH] FILE backend controls return value of fclose. --- libc/fclose.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libc/fclose.cpp b/libc/fclose.cpp index 2f625c11..61405dfa 100644 --- a/libc/fclose.cpp +++ b/libc/fclose.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. This file is part of the Sortix C Library. @@ -26,8 +26,12 @@ extern "C" int fclose(FILE* fp) { - int result = fflush(fp); - result |= fp->close_func ? fp->close_func(fp->user) : 0; + if ( fflush(fp) ) + { + /* TODO: How to report errors here? fclose may need us to return its + exact error value, for instance, as with popen/pclose. */; + } + int result = fp->close_func ? fp->close_func(fp->user) : 0; funregister(fp); if ( fp->free_func ) fp->free_func(fp);