This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Fix libstdc++/12882
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 21 Nov 2003 18:41:17 +0100
- Subject: [Patch] Fix libstdc++/12882
Hi,
the fix for the PR itself is straightforward, and I'm going to commit it
very soon if nobody objects.
However, I'd like to keep the PR open since it now includes two different
enhancement requests (one from myself, one from Pétur), which I'd like to
work on:
1- Prefer fseeko/ftello to fseek/ftell on non-LFS platforms.
2- Use fstat64, if available, in showmanyc to return non trivial values
also for large files (the current zero is ok wrt the standard).
Actually, I wanted to implement 2 too in one sweep, but sadly fstat64 is not
"magically" visible at compile time without appropriate LFS defines
(that otherwise we are avoiding)
Paolo.
///////////
2003-11-21 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/12882 (partial)
* acinclude.m4 (GLIBCXX_CHECK_LFS): Check fseeko64
and ftello64 too.
* include/ext/stdio_sync_filebuf.h (seekoff): Use fseeko64
and ftello64 if available.
* aclocal.m4: Regenerate.
* configure: Ditto.
diff -urN libstdc++-v3-orig/acinclude.m4 libstdc++-v3/acinclude.m4
--- libstdc++-v3-orig/acinclude.m4 2003-10-28 00:11:52.000000000 +0100
+++ libstdc++-v3/acinclude.m4 2003-11-21 17:44:27.000000000 +0100
@@ -600,7 +600,10 @@
[#include <unistd.h>
#include <stdio.h>
],
- [fopen64("t", "w");
+ [FILE* fp;
+ fopen64("t", "w");
+ fseeko64(fp, 0, SEEK_CUR);
+ ftello64(fp);
lseek64(1, 0, SEEK_CUR);],
[glibcxx_cv_LFS=yes],
[glibcxx_cv_LFS=no])
diff -urN libstdc++-v3-orig/include/ext/stdio_sync_filebuf.h libstdc++-v3/include/ext/stdio_sync_filebuf.h
--- libstdc++-v3-orig/include/ext/stdio_sync_filebuf.h 2003-10-04 12:51:34.000000000 +0200
+++ libstdc++-v3/include/ext/stdio_sync_filebuf.h 2003-11-21 18:01:12.000000000 +0100
@@ -180,9 +180,13 @@
__whence = SEEK_CUR;
else
__whence = SEEK_END;
-
+#ifdef _GLIBCXX_USE_LFS
+ if (!fseeko64(_M_file, __off, __whence))
+ __ret = std::streampos(ftello64(_M_file));
+#else
if (!fseek(_M_file, __off, __whence))
__ret = std::streampos(std::ftell(_M_file));
+#endif
return __ret;
}