Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-05-27 18:56:54 +0400
committerJeff Johnston <jjohnstn@redhat.com>2004-05-27 18:56:54 +0400
commit3f611058b784531fb75fa47f1c980611b9cabc97 (patch)
tree6cbc882b8a73689c25af118731725ba26d2b0061 /newlib/libc/stdio/vfprintf.c
parent6d70519a4b8ee771792957adb5a2dab11e41ecbc (diff)
2004-05-27 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/vfprintf.c (_VFPRINTF): Move file locking from here ... (_VFPRINTF_R): ... to here so all I/O printf routines are covered.
Diffstat (limited to 'newlib/libc/stdio/vfprintf.c')
-rw-r--r--newlib/libc/stdio/vfprintf.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index e63a7d886..b589d18d7 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -381,10 +381,7 @@ _DEFUN(VFPRINTF, (fp, fmt0, ap),
va_list ap)
{
int result;
- _flockfile (fp);
- CHECK_INIT (fp);
result = _VFPRINTF_R (_REENT, fp, fmt0, ap);
- _funlockfile (fp);
return result;
}
@@ -536,14 +533,21 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
(u_long)GET_ARG (N, ap, u_int))
#endif
+ _flockfile (fp);
+ CHECK_INIT (fp);
+
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
- if (cantwrite (fp))
+ if (cantwrite (fp)) {
+ _funlockfile (fp);
return (EOF);
+ }
/* optimise fprintf(stderr) (and other unbuffered Unix files) */
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
- fp->_file >= 0)
+ fp->_file >= 0) {
+ _funlockfile (fp);
return (__sbprintf (data, fp, fmt0, ap));
+ }
fmt = (char *)fmt0;
uio.uio_iov = iovp = iov;
@@ -1211,6 +1215,7 @@ done:
error:
if (malloc_buf != NULL)
_free_r (data, malloc_buf);
+ _funlockfile (fp);
return (__sferror (fp) ? EOF : ret);
/* NOTREACHED */
}