mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Wed Jul 3 11:26:28 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* time/strftime.c (strftime: do_number): Adjust P and I after sprintf in case it wrote fewer than MAXDIGITS chars. * stdio/fwrite.c (fwrite: fill_buffer): Separate flushing for last newline from flushing full buffer in loop, fix test so no fflush is done when last byte written exactly fills the buffer. * nss/Makefile ($(services:%=$(objpfx)libnss_%.so)): Depend on libc.so. * sysdeps/mach/hurd/Makefile (LDLIBS-c.so): Variable removed. (libc.so): Instead, give this deps on lib{mach,hurd}user.so. * elf/dl-debug.c (_dl_debug_initialize): Use LDBASE arg instead of extracting _dl_rtld_map.l_addr. * sysdeps/i386/dl-machine.h (elf_machine_rel): Declare _dl_rtld_map as weak. * sysdeps/alpha/dl-machine.h (elf_machine_rela): Likewise. * shlib-versions (*-*-*): Set libnss_db=1. * elf/rtld.c (dl_main): Set _dl_rtld_map's DT_DEBUG location too.
This commit is contained in:
101
stdio/fwrite.c
101
stdio/fwrite.c
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 1993, 1994, 1996 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -126,56 +126,67 @@ DEFUN(fwrite, (ptr, size, nmemb, stream),
|
||||
}
|
||||
}
|
||||
else if (!default_func || buffer_space >= to_write)
|
||||
fill_buffer:
|
||||
/* There is enough room in the buffer for everything we
|
||||
want to write or the user has specified his own output
|
||||
buffer-flushing/expanding function. */
|
||||
while (to_write > 0)
|
||||
{
|
||||
register size_t n = to_write;
|
||||
{
|
||||
/* There is enough room in the buffer for everything we want to write
|
||||
or the user has specified his own output buffer-flushing/expanding
|
||||
function. */
|
||||
fill_buffer:
|
||||
while (to_write > 0)
|
||||
{
|
||||
register size_t n = to_write;
|
||||
|
||||
if (n > buffer_space)
|
||||
n = buffer_space;
|
||||
if (n > buffer_space)
|
||||
n = buffer_space;
|
||||
|
||||
buffer_space -= n;
|
||||
buffer_space -= n;
|
||||
|
||||
written += n;
|
||||
to_write -= n;
|
||||
written += n;
|
||||
to_write -= n;
|
||||
|
||||
if (n < 20)
|
||||
while (n-- > 0)
|
||||
*stream->__bufp++ = *p++;
|
||||
else
|
||||
{
|
||||
memcpy ((PTR) stream->__bufp, (PTR) p, n);
|
||||
stream->__bufp += n;
|
||||
p += n;
|
||||
}
|
||||
if (n < 20)
|
||||
while (n-- > 0)
|
||||
*stream->__bufp++ = *p++;
|
||||
else
|
||||
{
|
||||
memcpy ((PTR) stream->__bufp, (PTR) p, n);
|
||||
stream->__bufp += n;
|
||||
p += n;
|
||||
}
|
||||
|
||||
if (buffer_space == 0 || (to_write == 0 && newlinep))
|
||||
{
|
||||
/* We've filled the buffer, so flush it. */
|
||||
if (fflush (stream) == EOF)
|
||||
break;
|
||||
if (to_write == 0)
|
||||
/* Done writing. */
|
||||
break;
|
||||
else if (buffer_space == 0)
|
||||
{
|
||||
/* We have filled the buffer, so flush it. */
|
||||
if (fflush (stream) == EOF)
|
||||
break;
|
||||
|
||||
/* Reset our record of the space available in the buffer,
|
||||
since we have just flushed it. */
|
||||
check_space:
|
||||
buffer_space = (stream->__bufsize -
|
||||
(stream->__bufp - stream->__buffer));
|
||||
if (buffer_space == 0)
|
||||
{
|
||||
/* With a custom output-room function, flushing might
|
||||
not create any buffer space. Try writing a single
|
||||
character to create the space. */
|
||||
if (__flshfp (stream, *p++) == EOF)
|
||||
goto done;
|
||||
++written;
|
||||
--to_write;
|
||||
goto check_space;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Reset our record of the space available in the buffer,
|
||||
since we have just flushed it. */
|
||||
check_space:
|
||||
buffer_space = (stream->__bufsize -
|
||||
(stream->__bufp - stream->__buffer));
|
||||
if (buffer_space == 0)
|
||||
{
|
||||
/* With a custom output-room function, flushing might
|
||||
not create any buffer space. Try writing a single
|
||||
character to create the space. */
|
||||
if (__flshfp (stream, *p++) == EOF)
|
||||
goto done;
|
||||
++written;
|
||||
--to_write;
|
||||
goto check_space;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We have written all the data into the buffer. If we are
|
||||
line-buffered and just put a newline in the buffer, flush now to
|
||||
make sure it gets out. */
|
||||
if (newlinep)
|
||||
fflush (stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* It won't all fit in the buffer. */
|
||||
|
Reference in New Issue
Block a user