diff --git a/libc/Makefile b/libc/Makefile index a491c1fd..d4d1708b 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -76,8 +76,14 @@ stdio/clearerr.o \ stdio/clearerr_unlocked.o \ stdio/cbprintf.o \ stdio/dprintf.o \ -stdio/fbufsize.o \ -stdio/fbufsize_unlocked.o \ +stdio_ext/__fbufsize.o \ +stdio_ext/__fpending.o \ +stdio_ext/__fpurge.o \ +stdio_ext/__freadable.o \ +stdio_ext/__freading.o \ +stdio_ext/__fseterr.o \ +stdio_ext/__fwritable.o \ +stdio_ext/__fwriting.o \ stdio/fclose.o \ stdio/fdeletefile.o \ stdio/feof.o \ @@ -99,19 +105,11 @@ stdio/flockfile.o \ stdio/fmemopen.o \ stdio/fnewfile.o \ stdio/fparsemode.o \ -stdio/fpending.o \ -stdio/fpending_unlocked.o \ stdio/fprintf_unlocked.o \ -stdio/fpurge.o \ -stdio/fpurge_unlocked.o \ stdio/fputc.o \ stdio/fputc_unlocked.o \ stdio/fputs.o \ stdio/fputs_unlocked.o \ -stdio/freadable.o \ -stdio/freadable_unlocked.o \ -stdio/freading.o \ -stdio/freading_unlocked.o \ stdio/fread.o \ stdio/fread_unlocked.o \ stdio/fregister.o \ @@ -123,8 +121,6 @@ stdio/fseeko.o \ stdio/fseeko_unlocked.o \ stdio/fsetdefaultbuf.o \ stdio/fsetdefaultbuf_unlocked.o \ -stdio/fseterr.o \ -stdio/fseterr_unlocked.o \ stdio/fshutdown.o \ stdio/ftell.o \ stdio/ftello.o \ @@ -132,12 +128,8 @@ stdio/ftello_unlocked.o \ stdio/ftrylockfile.o \ stdio/funlockfile.o \ stdio/funregister.o \ -stdio/fwritable.o \ -stdio/fwritable_unlocked.o \ stdio/fwrite.o \ stdio/fwrite_unlocked.o \ -stdio/fwriting.o \ -stdio/fwriting_unlocked.o \ stdio/getdelim.o \ stdio/getline.o \ stdio/rewind.o \ diff --git a/libc/include/stdio.h b/libc/include/stdio.h index a635265f..9f0a7ce1 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014, 2015. This file is part of the Sortix C Library. @@ -289,14 +289,11 @@ int vfscanf_unlocked(FILE* __restrict stream, const char* __restrict format, __g /* Functions that are Sortix extensions used for libc internal purposes. */ #if __USE_SORTIX - int fflush_stop_reading(FILE* fp); int fflush_stop_reading_unlocked(FILE* fp); int fflush_stop_writing(FILE* fp); int fflush_stop_writing_unlocked(FILE* fp); void fdeletefile(FILE* fp); -void fseterr(FILE* fp); -void fseterr_unlocked(FILE* fp); void fregister(FILE* fp); void fresetfile(FILE* fp); void funregister(FILE* fp); @@ -306,25 +303,6 @@ int fsetdefaultbuf_unlocked(FILE* fp); int fshutdown(FILE* fp); #endif -/* The functions. */ -#if __USE_SORTIX && (!defined(__IMPLICIT_SORTIX_SOURCE) || defined(__is_sortix_libc)) -#include -#define fbufsize __fbufsize -size_t fbufsize_unlocked(FILE* fp); -#define freading __freading -int freading_unlocked(FILE* fp); -#define fwriting __fwriting -int fwriting_unlocked(FILE* fp); -#define freadable __freadable -int freadable_unlocked(FILE* fp); -#define fwritable __fwritable -int fwritable_unlocked(FILE* fp); -#define fpurge __fpurge -void fpurge_unlocked(FILE* fp); -#define fpending __fpending -size_t fpending_unlocked(FILE* fp); -#endif - /* The backends for printf and scanf. */ #if __USE_SORTIX int cbprintf(void*, size_t (*)(void*, const char*, size_t), const char*, ...) diff --git a/libc/include/stdio_ext.h b/libc/include/stdio_ext.h index 5f85986f..ba6b49ce 100644 --- a/libc/include/stdio_ext.h +++ b/libc/include/stdio_ext.h @@ -32,13 +32,13 @@ __BEGIN_DECLS size_t __fbufsize(FILE* fp); -int __freading(FILE* fp); -int __fwriting(FILE* fp); -int __freadable(FILE* fp); -int __fwritable(FILE* fp); -void __fpurge(FILE* fp); size_t __fpending(FILE* fp); +void __fpurge(FILE* fp); +int __freadable(FILE* fp); +int __freading(FILE* fp); void __fseterr(FILE* fp); +int __fwritable(FILE* fp); +int __fwriting(FILE* fp); __END_DECLS diff --git a/libc/stdio/fbufsize_unlocked.cpp b/libc/stdio/fbufsize_unlocked.cpp deleted file mode 100644 index 3c5ef430..00000000 --- a/libc/stdio/fbufsize_unlocked.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. - - This file is part of the Sortix C Library. - - The Sortix C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - The Sortix C Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the Sortix C Library. If not, see . - - stdio/fbufsize_unlocked.cpp - Returns the size of the FILE's buffer. - -*******************************************************************************/ - -#include - -extern "C" size_t fbufsize_unlocked(FILE* fp) -{ - return fp->buffersize; -} diff --git a/libc/stdio/fpending_unlocked.cpp b/libc/stdio/fpending_unlocked.cpp deleted file mode 100644 index 16895c26..00000000 --- a/libc/stdio/fpending_unlocked.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. - - This file is part of the Sortix C Library. - - The Sortix C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - The Sortix C Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the Sortix C Library. If not, see . - - stdio/fpending_unlocked.cpp - Returns the number of bytes pending in the output buffer. - -*******************************************************************************/ - -#include - -extern "C" size_t fpending_unlocked(FILE* fp) -{ - return fp->amount_output_buffered; -} diff --git a/libc/stdio/fpurge.cpp b/libc/stdio/fpurge.cpp deleted file mode 100644 index 10c67292..00000000 --- a/libc/stdio/fpurge.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. - - This file is part of the Sortix C Library. - - The Sortix C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - The Sortix C Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the Sortix C Library. If not, see . - - stdio/fpurge.cpp - Discards all contents in the FILE's buffer. - -*******************************************************************************/ - -#include - -extern "C" void fpurge(FILE* fp) -{ - flockfile(fp); - fpurge_unlocked(fp); - funlockfile(fp); -} diff --git a/libc/stdio/freadable.cpp b/libc/stdio/freadable.cpp deleted file mode 100644 index 8fb76d8f..00000000 --- a/libc/stdio/freadable.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. - - This file is part of the Sortix C Library. - - The Sortix C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - The Sortix C Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the Sortix C Library. If not, see . - - stdio/freadable.cpp - Returns whether this FILE can be read from. - -*******************************************************************************/ - -#include - -extern "C" int freadable(FILE* fp) -{ - flockfile(fp); - int ret = freadable_unlocked(fp); - funlockfile(fp); - return ret; -} diff --git a/libc/stdio/freading.cpp b/libc/stdio/freading.cpp deleted file mode 100644 index 736e8095..00000000 --- a/libc/stdio/freading.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. - - This file is part of the Sortix C Library. - - The Sortix C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - The Sortix C Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the Sortix C Library. If not, see . - - stdio/freading.cpp - Returns whether the last operation was a read or FILE is read only. - -*******************************************************************************/ - -#include - -extern "C" int freading(FILE* fp) -{ - flockfile(fp); - int ret = freading_unlocked(fp); - funlockfile(fp); - return ret; -} diff --git a/libc/stdio/fseterr.cpp b/libc/stdio/fseterr.cpp deleted file mode 100644 index 167d7e20..00000000 --- a/libc/stdio/fseterr.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2015. - - This file is part of the Sortix C Library. - - The Sortix C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - The Sortix C Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the Sortix C Library. If not, see . - - stdio/fseterr.cpp - Sets the error condition bit on a FILE. - -*******************************************************************************/ - -#include - -extern "C" void fseterr(FILE* fp) -{ - flockfile(fp); - fseterr_unlocked(fp); - funlockfile(fp); -} - -// &%#!ing gnulib compatibility. -extern "C" void __fseterr(FILE* fp) -{ - fseterr(fp); -} diff --git a/libc/stdio/fwritable.cpp b/libc/stdio/fwritable.cpp deleted file mode 100644 index 35ebc656..00000000 --- a/libc/stdio/fwritable.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. - - This file is part of the Sortix C Library. - - The Sortix C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - The Sortix C Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the Sortix C Library. If not, see . - - stdio/fwritable.cpp - Returns whether this FILE can be written to. - -*******************************************************************************/ - -#include - -extern "C" int fwritable(FILE* fp) -{ - flockfile(fp); - int ret = fwritable_unlocked(fp); - funlockfile(fp); - return ret; -} diff --git a/libc/stdio/fwriting.cpp b/libc/stdio/fwriting.cpp deleted file mode 100644 index 9d758d53..00000000 --- a/libc/stdio/fwriting.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. - - This file is part of the Sortix C Library. - - The Sortix C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - The Sortix C Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the Sortix C Library. If not, see . - - stdio/fwriting.cpp - Returns whether the last operation was a write or FILE is write only. - -*******************************************************************************/ - -#include - -extern "C" int fwriting(FILE* fp) -{ - flockfile(fp); - int ret = fwriting_unlocked(fp); - funlockfile(fp); - return ret; -} diff --git a/libc/stdio/fbufsize.cpp b/libc/stdio_ext/__fbufsize.cpp similarity index 84% rename from libc/stdio/fbufsize.cpp rename to libc/stdio_ext/__fbufsize.cpp index 616b23d1..c5fad42d 100644 --- a/libc/stdio/fbufsize.cpp +++ b/libc/stdio_ext/__fbufsize.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2015. This file is part of the Sortix C Library. @@ -17,17 +17,18 @@ You should have received a copy of the GNU Lesser General Public License along with the Sortix C Library. If not, see . - stdio/fbufsize.cpp + stdio_ext/__fbufsize.cpp Returns the size of the FILE's buffer. *******************************************************************************/ #include +#include -extern "C" size_t fbufsize(FILE* fp) +extern "C" size_t __fbufsize(FILE* fp) { flockfile(fp); - size_t result = fbufsize_unlocked(fp); + size_t result = fp->buffersize; funlockfile(fp); return result; } diff --git a/libc/stdio/fpending.cpp b/libc/stdio_ext/__fpending.cpp similarity index 82% rename from libc/stdio/fpending.cpp rename to libc/stdio_ext/__fpending.cpp index 89a3e35c..f375acf0 100644 --- a/libc/stdio/fpending.cpp +++ b/libc/stdio_ext/__fpending.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014, 2015. This file is part of the Sortix C Library. @@ -17,17 +17,18 @@ You should have received a copy of the GNU Lesser General Public License along with the Sortix C Library. If not, see . - stdio/fpending.cpp + stdio_ext/__fpending.cpp Returns the number of bytes pending in the output buffer. *******************************************************************************/ #include +#include -extern "C" size_t fpending(FILE* fp) +extern "C" size_t __fpending(FILE* fp) { flockfile(fp); - size_t ret = fpending_unlocked(fp); + size_t result = fp->amount_output_buffered; funlockfile(fp); - return ret; + return result; } diff --git a/libc/stdio/fpurge_unlocked.cpp b/libc/stdio_ext/__fpurge.cpp similarity index 85% rename from libc/stdio/fpurge_unlocked.cpp rename to libc/stdio_ext/__fpurge.cpp index 684cf06b..785d0673 100644 --- a/libc/stdio/fpurge_unlocked.cpp +++ b/libc/stdio_ext/__fpurge.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2015. This file is part of the Sortix C Library. @@ -17,16 +17,19 @@ You should have received a copy of the GNU Lesser General Public License along with the Sortix C Library. If not, see . - stdio/fpurge_unlocked.cpp + stdio_ext/__fpurge.cpp Discards all contents in the FILE's buffer. *******************************************************************************/ #include +#include -extern "C" void fpurge_unlocked(FILE* fp) +extern "C" void __fpurge(FILE* fp) { + flockfile(fp); fp->offset_input_buffer = 0; fp->amount_input_buffered = 0; fp->amount_output_buffered = 0; + funlockfile(fp); } diff --git a/libc/stdio/freadable_unlocked.cpp b/libc/stdio_ext/__freadable.cpp similarity index 84% rename from libc/stdio/freadable_unlocked.cpp rename to libc/stdio_ext/__freadable.cpp index 3f6963be..d37219f6 100644 --- a/libc/stdio/freadable_unlocked.cpp +++ b/libc/stdio_ext/__freadable.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014, 2015. This file is part of the Sortix C Library. @@ -17,14 +17,18 @@ You should have received a copy of the GNU Lesser General Public License along with the Sortix C Library. If not, see . - stdio/freadable_unlocked.cpp + stdio_ext/__freadable.cpp Returns whether this FILE can be read from. *******************************************************************************/ #include +#include -extern "C" int freadable_unlocked(FILE* fp) +extern "C" int __freadable(FILE* fp) { - return fp->flags & _FILE_READABLE; + flockfile(fp); + int result = fp->flags & _FILE_READABLE ? 1 : 0; + funlockfile(fp); + return result; } diff --git a/libc/stdio/freading_unlocked.cpp b/libc/stdio_ext/__freading.cpp similarity index 80% rename from libc/stdio/freading_unlocked.cpp rename to libc/stdio_ext/__freading.cpp index 19b54b94..d207386d 100644 --- a/libc/stdio/freading_unlocked.cpp +++ b/libc/stdio_ext/__freading.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014, 2015. This file is part of the Sortix C Library. @@ -17,18 +17,22 @@ You should have received a copy of the GNU Lesser General Public License along with the Sortix C Library. If not, see . - stdio/freading_unlocked.cpp + stdio_ext/__freading.cpp Returns whether the last operation was a read or FILE is read only. *******************************************************************************/ #include +#include -extern "C" int freading_unlocked(FILE* fp) +extern "C" int __freading(FILE* fp) { + int result = 0; + flockfile(fp); if ( fp->flags & _FILE_LAST_READ ) - return 1; - if ( (fp->flags & _FILE_READABLE) && !(fp->flags & _FILE_WRITABLE) ) - return 1; - return 0; + result = 1; + else if ( (fp->flags & _FILE_READABLE) && !(fp->flags & _FILE_WRITABLE) ) + result = 1; + funlockfile(fp); + return result; } diff --git a/libc/stdio/fseterr_unlocked.cpp b/libc/stdio_ext/__fseterr.cpp similarity index 89% rename from libc/stdio/fseterr_unlocked.cpp rename to libc/stdio_ext/__fseterr.cpp index 717905a0..4067d00e 100644 --- a/libc/stdio/fseterr_unlocked.cpp +++ b/libc/stdio_ext/__fseterr.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014, 2015. This file is part of the Sortix C Library. @@ -17,14 +17,17 @@ You should have received a copy of the GNU Lesser General Public License along with the Sortix C Library. If not, see . - stdio/fseterr_unlocked.cpp + stdio_ext/__fseterr.cpp Sets the error condition bit on a FILE. *******************************************************************************/ #include +#include -extern "C" void fseterr_unlocked(FILE* fp) +extern "C" void __fseterr(FILE* fp) { + flockfile(fp); fp->flags |= _FILE_STATUS_ERROR; + funlockfile(fp); } diff --git a/libc/stdio/fwritable_unlocked.cpp b/libc/stdio_ext/__fwritable.cpp similarity index 84% rename from libc/stdio/fwritable_unlocked.cpp rename to libc/stdio_ext/__fwritable.cpp index 2db8b94a..93c07036 100644 --- a/libc/stdio/fwritable_unlocked.cpp +++ b/libc/stdio_ext/__fwritable.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014, 2015. This file is part of the Sortix C Library. @@ -17,14 +17,18 @@ You should have received a copy of the GNU Lesser General Public License along with the Sortix C Library. If not, see . - stdio/fwritable_unlocked.cpp + stdio_ext/__fwritable.cpp Returns whether this FILE can be written to. *******************************************************************************/ #include +#include -extern "C" int fwritable_unlocked(FILE* fp) +extern "C" int __fwritable(FILE* fp) { - return fp->flags & _FILE_WRITABLE; + flockfile(fp); + int result = fp->flags & _FILE_WRITABLE ? 1 : 0; + funlockfile(fp); + return result; } diff --git a/libc/stdio/fwriting_unlocked.cpp b/libc/stdio_ext/__fwriting.cpp similarity index 86% rename from libc/stdio/fwriting_unlocked.cpp rename to libc/stdio_ext/__fwriting.cpp index 8ad911a7..d906689c 100644 --- a/libc/stdio/fwriting_unlocked.cpp +++ b/libc/stdio_ext/__fwriting.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014, 2015. This file is part of the Sortix C Library. @@ -17,18 +17,22 @@ You should have received a copy of the GNU Lesser General Public License along with the Sortix C Library. If not, see . - stdio/fwriting_unlocked.cpp + stdio_ext/__fwriting.cpp Returns whether the last operation was a write or FILE is write only. *******************************************************************************/ #include +#include -extern "C" int fwriting_unlocked(FILE* fp) +extern "C" int __fwriting(FILE* fp) { + int result = 0; + flockfile(fp); if ( fp->flags & _FILE_LAST_WRITE ) - return 1; + result = 1; if ( (fp->flags & _FILE_WRITABLE) && !(fp->flags & _FILE_READABLE) ) - return 1; - return 0; + result = 1; + funlockfile(fp); + return result; }