f77 source file overwrite fix

eric j. haug ejh at slu70.UUCP
Tue Feb 5 10:09:41 AEST 1985


Subject:  f77 overwrites source files
Index:	src/cmd/f77 / driver.c 2.9bsd

Description:
	f77 does not check to see if the user would overwrite his source
	file.
Repeat-By:
	f77 -o f.f f.f
Fix:
	Change the code to check the last two characters of the target. And
	complain if it is one of "cefros".

Somewhere in main() where the variables are declared add
int dotpos;
Then in the switch looking for case 'o' add the following:

	aoutname = *++argv;
	--argc;
	/* non portable hack -- dotpos is an int */
	if ((dotpos = dotchar(aoutname)) != NO ) {
		if (dotpos == 'f' || dotpos == 'c' ||
			dotpos == 's' || dotpos == 'r' ||
			dotpos == 'e' || dotpos == 'o') {
			fprintf(diagfile,
				"It does not seem sensible to name the output %s\n",
					aoutname);
			done(1);
		}
	}
	break;

There are a few extra lines included in the above, to indicate context.
Sorry i did not choose to fix the other character with integer comparisons.



More information about the Comp.bugs.2bsd mailing list