Mercurial > ecos
changeset 2304:543067294b88
* src/common/stream.cxx (read): Only update position after direct
reads from I/O system so it's updated by the correct number of
bytes.
(write): Reset underlying file position if there had been
stuff read from the file left in the buffer so the file positions
are inconsistent.
| author | jlarmour |
|---|---|
| date | Tue, 26 Sep 2006 18:51:22 +0000 |
| parents | 4c4508c2530f |
| children | 94516b63a992 |
| files | packages/language/c/libc/stdio/current/ChangeLog packages/language/c/libc/stdio/current/src/common/stream.cxx |
| diffstat | 2 files changed, 28 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,12 @@ +2006-09-26 Jonathan Larmour <jifl@eCosCentric.com> + + * src/common/stream.cxx (read): Only update position after direct + reads from I/O system so it's updated by the correct number of + bytes. + (write): Reset underlying file position if there had been + stuff read from the file left in the buffer so the file positions + are inconsistent. + 2005-07-22 Andrew Lunn <andrew.lunn@ascom.ch> * src/common/fopen.cxx (fopen): Default the open mode to Read @@ -484,7 +493,7 @@ 2000-05-02 Jonathan Larmour <jlarmour@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -// Copyright (C) 2004 eCosCentric Limited +// Copyright (C) 2004, 2006 eCosCentric Limited // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -508,9 +517,6 @@ 2000-05-02 Jonathan Larmour <jlarmour@ // // This exception does not invalidate any other reasons why a work based on // this file might be covered by the GNU General Public License. -// -// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -// at http://sources.redhat.com/ecos/ecos-license/ // ------------------------------------------- //####ECOSGPLCOPYRIGHTEND#### //===========================================================================
--- a/packages/language/c/libc/stdio/current/src/common/stream.cxx +++ b/packages/language/c/libc/stdio/current/src/common/stream.cxx @@ -9,6 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 2006 eCosCentric Limited // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -32,9 +33,6 @@ // // This exception does not invalidate any other reasons why a work based on // this file might be covered by the GNU General Public License. -// -// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -// at http://sources.redhat.com/ecos/ecos-license/ // ------------------------------------------- //####ECOSGPLCOPYRIGHTEND#### //======================================================================== @@ -386,8 +384,6 @@ Cyg_StdioStream::read( cyg_uint8 *user_b flags.readbuf_char_in_use = false; } - position += *bytes_read; - // if we are unbuffered, we read as much as we can directly from the // file system at this point. @@ -405,6 +401,8 @@ Cyg_StdioStream::read( cyg_uint8 *user_b *bytes_read+=len; } + position += *bytes_read; + unlock_me(); return read_err; @@ -615,8 +613,22 @@ Cyg_StdioStream::write( const cyg_uint8 } #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO - if (flags.last_buffer_op_was_read == true) + if (flags.last_buffer_op_was_read == true) { +#ifdef CYGPKG_LIBC_STDIO_FILEIO + if ( 0 != io_buf.get_buffer_space_used() ) + { + off_t newpos = position; + io_buf.drain_buffer(); // nuke input bytes to prevent confusion + Cyg_ErrNo err = cyg_stdio_lseek( my_device, &newpos, SEEK_SET ); + if (err) { + unlock_me(); + return err; + } + } +#else io_buf.drain_buffer(); // nuke input bytes to prevent confusion +#endif + } flags.last_buffer_op_was_read = false;
