This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++ - ios::ate not working
- To: doko at cs dot tu-berlin dot de
- Subject: Re: libstdc++ - ios::ate not working
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sun, 21 Nov 1999 22:10:05 +0100
- CC: libstdc++ at sourceware dot debian dot org, gcc-bugs at gcc dot gnu dot org, 35628 at bugs dot debian dot org, ujr at physik dot phy dot tu-dresden dot de, gcc-patches at gcc dot gnu dot org
- References: <14377.45118.433056.889146@bolero>
> 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)