This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

Re: SS 20020521 ostream.tcc breaks ostream output


On Wed, May 22, 2002 at 11:03:27PM +0200, Paolo Carlini wrote:
> George Garvey wrote:
> 
> >   Tried sending this with gccbug, and it bounced, and I deleted it.
> >   A program that reads an input file, transforms one line, and writes
> >it out broke with this snapshot. I replaced just ostream.tcc with the
> >file from the 3.1 release and it worked again, on Linux.
> >
> Definitely, you should provide some details.
> 
> Anyway, the only difference between CVS' and 3.1's ostream.tcc, is the 
> following:
> 
>     http://gcc.gnu.org/ml/gcc-patches/2002-05/msg01205.html
> 
> which in a fact it's a little bit controversial, at the moment, since 
> changes the behaviour of libstdc++/6750 testcase.
> 
> Are you using getline, I suppose?
> 
   Yes. This is the loop, and this is the line that fails:
	if (temp_file.good()) {
We indent with tabs equal 3 spaces, so it looks a bit goofy. All but the
error display stuff should compile anywhere, and its pretty obvious.


static bool
replace_fix_ident(const string &code_directory,
		  const string &code_fix_directory, const char *file_name
		 ) {
	ifstream actual_file;

	bool replaced(false);
	string actual_name(code_directory);
	actual_name += '/';
	actual_name += file_name;
	string fix_name(code_fix_directory);
	fix_name += '/';
	fix_name += file_name;
	string fix_temp_name(fix_name);
	fix_temp_name += ".tmp";
	actual_file.open(actual_name.c_str());
	if (actual_file.good()) {
		char ident_buffer[512];

		bool have_ident(false);
		while (actual_file.getline(ident_buffer, sizeof(ident_buffer))) {
			if (strnsame(ident_buffer, "#\tident\t", 8)) {
				have_ident = true;

				break;
			}
		}
		actual_file.close();
		actual_file.clear();
		actual_file.open(fix_name.c_str());
	if (actual_file.good()) {
		ofstream temp_file;

		temp_file.open(fix_temp_name.c_str());
	if (temp_file.good()) {
		char buffer[4096];

		while (actual_file.getline(buffer, sizeof(buffer))) {
			if (have_ident  &&  strnsame(buffer, "#\tident\t", 8)) {
				temp_file << ident_buffer << '\n';
			} else {
				temp_file << buffer << '\n';
			}
		}
	if (actual_file.eof()) {
		actual_file.close();
	if (temp_file.good()) {
		temp_file.close();
	if (inXServices::File::remove(fix_name.c_str())) {
	if (! (replaced
				= inXServices::File::rename(fix_temp_name.c_str(), fix_name.c_str())
		)) {
		cerr
			<< "Unable to rename " << fix_temp_name << " to " << fix_name << '\n'
			<< '\t' << get_errno() << ": " << get_strerror() << endl;
	} } else {
		cerr
			<< "Unable to remove " << fix_name << '\n'
			<< '\t' << get_errno() << ": " << get_strerror() << endl;
		if (! inXServices::File::remove(fix_temp_name.c_str())) {
			cerr
				<< "Unable to remove " << fix_temp_name << '\n'
				<< '\t' << get_errno() << ": " << get_strerror() << endl;
		}
	} } else {
		cerr
			<< "Unable to write " << fix_temp_name << '\n'
			<< '\t' << get_errno() << ": " << get_strerror() << endl;
		temp_file.close();
		if (! inXServices::File::remove(fix_temp_name.c_str())) {
			cerr
				<< "Unable to remove " << fix_temp_name << '\n'
				<< '\t' << get_errno() << ": " << get_strerror() << endl;
		}
	} } else {
		cerr
			<< "Unable to read " << fix_name << '\n'
			<< '\t' << get_errno() << ": " << get_strerror() << endl;
		if (! inXServices::File::remove(fix_temp_name.c_str())) {
			cerr
				<< "Unable to remove " << fix_temp_name << '\n'
				<< '\t' << get_errno() << ": " << get_strerror() << endl;
		}
	} } else {
		cerr
			<< "Unable to create " << fix_temp_name << '\n'
			<< '\t' << get_errno() << ": " << get_strerror() << endl;
		if (! inXServices::File::remove(fix_temp_name.c_str())) {
			cerr
				<< "Unable to remove " << fix_temp_name << '\n'
				<< '\t' << get_errno() << ": " << get_strerror() << endl;
		}
	} } else {
		cerr
			<< "Unable to open " << fix_name << '\n'
			<< '\t' << get_errno() << ": " << get_strerror() << endl;
	} } else {
		cerr
			<< "Unable to open " << actual_name << '\n'
			<< '\t' << get_errno() << ": " << get_strerror() << endl;
	}
	return replaced;
}


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