|
From: SourceForge.net <no...@so...> - 2003-11-24 18:36:46
|
Bugs item #848480, was opened at 2003-11-24 13:36 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=848480&group_id=2435 Category: gcc Group: None Status: Open Resolution: None Priority: 5 Submitted By: Stuart Mentzer (stuart_mentzer) Assigned to: Danny Smith (dannysmith) Summary: tellg/seekg bug with DOS text files Initial Comment: Using tellg/seekg to backup by one line in some DOS text files is going to the wrong location now both with MinGW GCC 3.2.3 and Cygwin GCC 3.3.1. Using seekg with a tellg value doesn't return to the correct point in the file. It works properly with *nix text files (\n line endings). Other users have tried the example on non-MinGW GCCs and report that it works correctly for DOS and *nix text files so I believe this is a bug in the MinGW port. -- Stuart // seek.cc // // Build with g++ seek.cc -o seek.exe #include <string> #include <iostream> #include <fstream> int main() { std::ifstream afile( "sample.txt" ); std::string inp_line; getline( afile, inp_line ); std::cout << inp_line << std::endl; std::streampos sp = afile.tellg(); // Start of 2nd line getline( afile, inp_line ); std::cout << inp_line << std::endl; getline( afile, inp_line ); std::cout << inp_line << std::endl; afile.seekg( sp ); // Return to start of 2nd line getline( afile, inp_line ); std::cout << inp_line << std::endl; afile.close(); return 0; } /* sample.txt File (DOS line endings) first line second line third line fourth line */ /* Output generated by MinGW GCC 3.2.3 or Cygwin GCC 3.3.1 first line second line third line nd line */ Additional Information: Platform: Windows 2000 SP2 g++ -v Reading specs from E:/mingw/bin/../lib/gcc- lib/mingw32/3.2.3/specs Configured with: ../gcc/configure --with-gcc --with-gnu- ld --with-gnu-as --host=mingw32 --target=mingw32 -- prefix=/mingw --enable-th reads --disable-nls --enable-languages=c++,f77,objc -- disable-win32-registry --disable-shared --enable-sjlj- exceptions Thread model: win32 gcc version 3.2.3 (mingw special 20030504-1) ld -v GNU ld version 2.13.90 20030111 MinGW installation from separate components Tested in Windows console environment #define __MINGW32_VERSION 3.2 win32api version 2.4 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=848480&group_id=2435 |