This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] basic_file_stdio.cc changes for 9425 and 9439


Hi everyone...

Yes, I'm trying to fix both those reports at the same time ;) ...

Seriously, I think I have nailed down the underlying problem,
and, if you all agree with my analysis, the final patch is really
pretty close...

In a nutshell, I propose changing basic_file_stdio.cc in this way:

===================================
--- basic_file_stdio.cc.orig 2003-02-03 22:06:52.000000000 +0100
+++ basic_file_stdio.cc 2003-02-03 22:08:52.000000000 +0100
@@ -203,15 +203,19 @@
__basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way,
ios_base::openmode /*__mode*/)
{
- fseek(_M_cfile, __off, __way);
- return ftell(_M_cfile);
+ if (!fseek(_M_cfile, __off, __way))
+ return ftell(_M_cfile);
+ else
+ return -1L;
}

streamoff
__basic_file<char>::seekpos(streamoff __pos, ios_base::openmode /*__mode*/)
{
- fseek(_M_cfile, __pos, ios_base::beg);
- return ftell(_M_cfile);
+ if (!fseek(_M_cfile, __pos, ios_base::beg))
+ return ftell(_M_cfile);
+ else
+ return -1L;
}
===================================

This would allow returning -1L not only in case of failure of ftell,
but also in the _interesting_ case of failure of fseek, which, I
briefly recall you all, does _not_ lead by itself to the failure
of a next ftell!

If we agree about this, then it's easy to implement strict tests on the
return value of seekoff (which calls __basic_file<char>::seekoff)
inside pbackfail (and, if needed, elsewhere for it and seekpos) thus
fixing rather easily both 9425 and 9439.

What do you think?

Thanks,
Paolo.


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