libstdc++ - ios::ate not working
Martin v. Loewis
martin@mira.isdn.cs.tu-berlin.de
Sun Nov 21 13:14:00 GMT 1999
> In the following program, the info in both 'Length' lines should be
> the same (as it is in earlier libstdc++2.9 versions). However,
> while the second line is correct, the first on always outputs 0.
Thanks for your bug report. A patch is attached below.
Ok to install in gcc mainline and release branch?
Regards,
Martin
1999-11-21 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* filebuf.cc (open): Support ios::ate if _G_HAVE_IO_FILE_OPEN.
Index: filebuf.cc
===================================================================
RCS file: /cvs/gcc/egcs/libio/filebuf.cc,v
retrieving revision 1.3
diff -u -r1.3 filebuf.cc
--- filebuf.cc 1998/02/24 20:09:49 1.3
+++ filebuf.cc 1999/11/21 21:07:48
@@ -1,5 +1,5 @@
/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993, 1995 Free Software Foundation
+Copyright (C) 1993, 1995, 1999 Free Software Foundation
This file is part of the GNU IO Library. This library is free
software; you can redistribute it and/or modify it under the
@@ -112,8 +112,16 @@
if (mode & (int)ios::noreplace)
posix_mode |= O_EXCL;
#if _G_HAVE_IO_FILE_OPEN
- return (filebuf*)_IO_file_open (this, filename, posix_mode, prot,
- read_write, 0);
+ if (!_IO_file_open (this, filename, posix_mode, prot,
+ read_write, 0))
+ return NULL;
+ if (mode & (ios::ate|ios::app)) {
+ if (pubseekoff(0, ios::end) == EOF) {
+ _IO_un_link (this);
+ return NULL;
+ }
+ }
+ return this;
#else
int fd = ::open(filename, posix_mode, prot);
if (fd < 0)
More information about the Gcc-patches
mailing list