This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Cyg_StdioStream::read() bug


Cyg_StdioStream's read() member function reads one char in excess when
CYGFUN_LIBC_STDIO_ungetc is defined and the unget buffer holds one
character. Here is a fix to this problem.

Robin
Index: stream.cxx
===================================================================
RCS file: /usr/cvs/eCos/base/packages/language/c/libc/stdio/current/src/common/stream.cxx,v
retrieving revision 1.1.1.2
diff -C3 -r1.1.1.2 stream.cxx
*** stream.cxx	9 Apr 2001 13:50:23 -0000	1.1.1.2
--- stream.cxx	10 Aug 2001 13:14:04 -0000
***************
*** 355,365 ****
          bytes_available = io_buf.get_buffer_addr_to_read(
                (cyg_uint8 **)&buff_to_read_from );
          
!         *bytes_read += (bytes_available < buffer_length) ? bytes_available
!                                                          : buffer_length;
!         if (*bytes_read) {
!             memcpy( user_buffer, buff_to_read_from, *bytes_read );
!             io_buf.set_bytes_read( *bytes_read );
          } // if
  
      } // if
--- 355,367 ----
          bytes_available = io_buf.get_buffer_addr_to_read(
                (cyg_uint8 **)&buff_to_read_from );
          
!         cyg_ucount32 count =
!             (bytes_available < buffer_length) ? bytes_available : buffer_length;
! 
!         if (count) {
!             memcpy( user_buffer, buff_to_read_from, count );
!             io_buf.set_bytes_read( count );
!             *bytes_read += count;
          } // if
  
      } // if

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]