Index: src/driver/cc1.cc
===================================================================
--- src/driver/cc1.cc	(revision e3215c5bb07cd38ca72ccb2ce6de6057811328c5)
+++ src/driver/cc1.cc	(revision dffaeac743b46e961ffdca195bffbf80bff2d6ad)
@@ -10,6 +10,6 @@
 // Created On       : Fri Aug 26 14:23:51 2005
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat May 12 16:11:53 2018
-// Update Count     : 94
+// Last Modified On : Fri Jul 13 17:40:10 2018
+// Update Count     : 110
 //
 
@@ -44,4 +44,19 @@
 } // prefix
 
+enum { NumSuffixes = 2 };
+const string suffixes[NumSuffixes] = { "cfa", "hfa", };
+
+bool suffix( string arg ) {
+	//std::cerr << arg << std::endl;
+	size_t dot = arg.find_last_of( "." );
+	//std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
+	if ( dot == string::npos ) return false;
+	string sx = arg.substr( dot + 1 );
+	for ( int i = 0; i < NumSuffixes; i += 1 ) {
+		if ( sx == suffixes[i] ) return true;
+	} // for
+	return false;
+} // suffix
+
 
 void checkEnv( const char *args[], int &nargs ) {
@@ -51,7 +66,7 @@
 	if ( value != NULL ) {
 		compiler_name = value;
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "env arg:\"" << compiler_name << "\"" << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 	} // if
 
@@ -59,7 +74,7 @@
 	if ( value != NULL ) {
 		args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "env arg:\"" << args[nargs] << "\"" << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 		nargs += 1;
 	} // if
@@ -68,7 +83,7 @@
 	if ( value != NULL ) {
 		args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "env arg:\"" << args[nargs] << "\"" << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 		nargs += 1;
 	} // if
@@ -115,7 +130,7 @@
 	signal( SIGTERM, sigTermHandler );
 
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	cerr << "Stage1" << endl;
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	// process all the arguments
@@ -124,11 +139,11 @@
 
 	for ( i = 1; i < argc; i += 1 ) {
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 		arg = argv[i];
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "arg:\"" << arg << "\"" << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 		if ( prefix( arg, "-" ) ) {
 			// strip g++ flags that are inappropriate or cause duplicates in subsequent passes
@@ -164,15 +179,15 @@
 				ncargs += 1;
 				i += 1;									// and the argument
-			} else if ( prefix( arg, D__GCC_X__ ) ) {
-				args[nargs] = "-x";
-				nargs += 1;
-				args[nargs] = ( *new string( arg.substr( D__GCC_X__.size() ) ) ).c_str(); // pass the flag along
-				nargs += 1;
-			} else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_X__.substr(2) ) ) {
-				args[nargs] = "-x";
-				nargs += 1;
-				args[nargs] = ( *new string( string( argv[i + 1] ).substr( D__GCC_X__.size() - 2 ) ) ).c_str(); // pass the flag along
-				nargs += 1;
-				i += 1;									// and the argument
+			// } else if ( prefix( arg, D__GCC_X__ ) ) {
+			// 	args[nargs] = "-x";
+			// 	nargs += 1;
+			// 	args[nargs] = ( *new string( arg.substr( D__GCC_X__.size() ) ) ).c_str(); // pass the flag along
+			// 	nargs += 1;
+			// } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_X__.substr(2) ) ) {
+			// 	args[nargs] = "-x";
+			// 	nargs += 1;
+			// 	args[nargs] = ( *new string( string( argv[i + 1] ).substr( D__GCC_X__.size() - 2 ) ) ).c_str(); // pass the flag along
+			// 	nargs += 1;
+			// 	i += 1;									// and the argument
 			} else if ( prefix( arg, D__GCC_BPREFIX__ ) ) {
 				bprefix = arg.substr( D__GCC_BPREFIX__.size() );
@@ -196,7 +211,7 @@
 					args[nargs] = argv[i];				// pass the argument along
 					nargs += 1;
-#ifdef __DEBUG_H__
+					#ifdef __DEBUG_H__
 					cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
-#endif // __DEBUG_H__
+					#endif // __DEBUG_H__
 				} else if ( arg == "-MD" || arg == "-MMD" ) {
 					args[nargs] = "-MF";				// insert before file
@@ -205,7 +220,7 @@
 					args[nargs] = argv[i];				// pass the argument along
 					nargs += 1;
-#ifdef __DEBUG_H__
+					#ifdef __DEBUG_H__
 					cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
-#endif // __DEBUG_H__
+					#endif // __DEBUG_H__
 				} // if
 			} // if
@@ -213,12 +228,12 @@
 			if ( cpp_in == NULL ) {
 				cpp_in = argv[i];
-#ifdef __DEBUG_H__
+				#ifdef __DEBUG_H__
 				cerr << "cpp_in:\"" << cpp_in << "\"" << endl;
-#endif // __DEBUG_H__
+				#endif // __DEBUG_H__
 			} else if ( cpp_out == NULL ) {
 				cpp_out = argv[i];
-#ifdef __DEBUG_H__
+				#ifdef __DEBUG_H__
 				cerr << "cpp_out:\"" << cpp_out << "\""<< endl;
-#endif // __DEBUG_H__
+				#endif // __DEBUG_H__
 			} else {
 				cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl;
@@ -228,5 +243,5 @@
 	} // for
 
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	cerr << "args:";
 	for ( i = 1; i < nargs; i += 1 ) {
@@ -236,5 +251,5 @@
 	if ( cpp_out != NULL ) cerr << " " << cpp_out;
 	cerr << endl;
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	if ( cpp_in == NULL ) {
@@ -258,5 +273,5 @@
 		args[nargs] = NULL;								// terminate argument list
 
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "nargs: " << nargs << endl;
 		for ( i = 0; args[i] != NULL; i += 1 ) {
@@ -264,5 +279,5 @@
 		} // for
 		cerr << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 
 		execvp( args[0], (char *const *)args );			// should not return
@@ -279,7 +294,7 @@
 	} // if
 
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	cerr << "tmpname:" << tmpname << " tmpfilefd:" << tmpfilefd << endl;
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	// Run the C preprocessor and save the output in tmpfile.
@@ -295,9 +310,15 @@
 
 		args[0] = compiler_name.c_str();
+		if ( suffix( cpp_in ) ) {
+			args[nargs] = "-x";
+			nargs += 1;
+			args[nargs] = "c";
+			nargs += 1;
+		} // if
 		args[nargs] = cpp_in;							// input to cpp
 		nargs += 1;
 		args[nargs] = NULL;								// terminate argument list
 
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "cpp nargs: " << nargs << endl;
 		for ( i = 0; args[i] != NULL; i += 1 ) {
@@ -305,5 +326,5 @@
 		} // for
 		cerr << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 
 		execvp( args[0], (char *const *)args );			// should not return
@@ -314,7 +335,7 @@
 	wait( &code );										// wait for child to finish
 
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	cerr << "return code from cpp:" << WEXITSTATUS(code) << endl;
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	if ( WIFSIGNALED(code) != 0 ) {						// child failed ?
@@ -352,5 +373,5 @@
 		cargs[ncargs] = NULL;							// terminate argument list
 
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl;
 		for ( i = 0; cargs[i] != NULL; i += 1 ) {
@@ -358,5 +379,5 @@
 		} // for
 		cerr << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 
 		execvp( cargs[0], (char * const *)cargs );		// should not return
@@ -367,7 +388,7 @@
 	wait( &code );										// wait for child to finish
 
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	cerr << "return code from cfa-cpp:" << WEXITSTATUS(code) << endl;
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	// Must unlink here because file must exist across execvp.
@@ -393,7 +414,7 @@
 	int nargs = 1;										// number of arguments in args list; 0 => command name
 
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	cerr << "Stage2" << endl;
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	// process all the arguments
@@ -402,17 +423,17 @@
 
 	for ( i = 1; i < argc; i += 1 ) {
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 		arg = argv[i];
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 		cerr << "arg:\"" << arg << "\"" << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 		if ( prefix( arg, "-" ) ) {
 			// strip inappropriate flags
 
 			if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" ||
-				 // Currently CFA does not suppose precompiled .h files.
-				 prefix( arg, "--output-pch" ) ) {
+				// Currently CFA does not suppose precompiled .h files.
+				prefix( arg, "--output-pch" ) ) {
 
 				// strip inappropriate flags with an argument
@@ -420,7 +441,7 @@
 			} else if ( arg == "-auxbase" || arg == "-auxbase-strip" || arg == "-dumpbase" ) {
 				i += 1;
-#ifdef __DEBUG_H__
+				#ifdef __DEBUG_H__
 				cerr << "arg:\"" << argv[i] << "\"" << endl;
-#endif // __DEBUG_H__
+				#endif // __DEBUG_H__
 
 				// all other flags
@@ -433,7 +454,7 @@
 					args[nargs] = argv[i];				// pass the argument along
 					nargs += 1;
-#ifdef __DEBUG_H__
+		#ifdef __DEBUG_H__
 					cerr << "arg:\"" << argv[i] << "\"" << endl;
-#endif // __DEBUG_H__
+		#endif // __DEBUG_H__
 				} // if
 			} // if
@@ -441,7 +462,7 @@
 			if ( cpp_in == NULL ) {
 				cpp_in = argv[i];
-#ifdef __DEBUG_H__
+				#ifdef __DEBUG_H__
 				cerr << "cpp_in:\"" << cpp_in << "\"" << endl;
-#endif // __DEBUG_H__
+				#endif // __DEBUG_H__
 			} else {
 				cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl;
@@ -451,5 +472,5 @@
 	} // for
 
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	cerr << "args:";
 	for ( i = 1; i < nargs; i += 1 ) {
@@ -458,5 +479,5 @@
 	cerr << endl;
 	if ( cpp_in != NULL ) cerr << " " << cpp_in;
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	args[0] = compiler_name.c_str();
@@ -467,5 +488,5 @@
 	args[nargs] = NULL;									// terminate argument list
 
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	cerr << "stage2 nargs: " << nargs << endl;
 	for ( i = 0; args[i] != NULL; i += 1 ) {
@@ -473,5 +494,5 @@
 	} // for
 	cerr << endl;
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	execvp( args[0], (char * const *)args );			// should not return
@@ -482,9 +503,9 @@
 
 int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
-#ifdef __DEBUG_H__
+	#ifdef __DEBUG_H__
 	for ( int i = 0; env[i] != NULL; i += 1 ) {
 		cerr << env[i] << endl;
 	} // for
-#endif // __DEBUG_H__
+	#endif // __DEBUG_H__
 
 	string arg = argv[1];
