Changes in driver/cfa.cc [4f5a8a2:2026bb6]
- File:
-
- 1 edited
-
driver/cfa.cc (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
driver/cfa.cc
r4f5a8a2 r2026bb6 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Aug 10 08:44:15201913 // Update Count : 31112 // Last Modified On : Sun Feb 10 08:28:09 2019 13 // Update Count : 281 14 14 // 15 15 … … 20 20 #include <string> // STL version 21 21 #include <string.h> // strcmp 22 #include <algorithm> // find23 22 24 23 #include <sys/types.h> … … 27 26 #include "Common/SemanticError.h" 28 27 #include "config.h" // configure info 29 30 28 31 29 using std::cerr; … … 42 40 } // prefix 43 41 44 bool suffix( string arg ) { 45 enum { NumSuffixes = 3 }; 46 static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" }; 42 enum { NumSuffixes = 2 }; 43 const string suffixes[NumSuffixes] = { "cfa", "hfa", }; 44 45 bool suffix( string arg, const char * args[], int & nargs ) { 47 46 //std::cerr << arg << std::endl; 48 47 size_t dot = arg.find_last_of( "." ); 49 48 //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl; 50 49 if ( dot == string::npos ) return false; 51 const string * end = suffixes + NumSuffixes; 52 return std::find( suffixes, end, arg.substr( dot + 1 ) ) != end; 50 string sx = arg.substr( dot + 1 ); 51 for ( int i = 0; i < NumSuffixes; i += 1 ) { 52 if ( sx == suffixes[i] ) { 53 args[nargs] = "-x"; 54 nargs += 1; 55 args[nargs] = "c"; 56 nargs += 1; 57 return true; 58 } // if 59 } // for 60 return false; 53 61 } // suffix 54 62 55 63 56 void shuffle( const char * args[], int S, int E, int N ) {64 void shuffle( const char *args[], int S, int E, int N ) { 57 65 // S & E index 1 passed the end so adjust with -1 58 66 #ifdef __DEBUG_H__ … … 67 75 } // shuffle 68 76 69 static inline bool dirExists( const string & path) {77 static inline bool dirExists(const string & path) { 70 78 struct stat info; 71 79 if(stat( path.c_str(), &info ) != 0) … … 80 88 #define str(s) #s 81 89 82 int main( int argc, char * argv[] ) {90 int main( int argc, char *argv[] ) { 83 91 string Version( CFA_VERSION_LONG ); // current version number from CONFIG 84 92 string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) ); … … 96 104 string compiler_name; // name of C compiler 97 105 98 bool x_flag = false; // -x flag99 106 bool nonoptarg = false; // indicates non-option argument specified 100 107 bool link = true; // linking as well as compiling 101 108 bool verbose = false; // -v flag 102 bool quiet = false; // -quiet flag103 bool debug = true; // -debug flag104 bool nolib = false; // -nolib flag105 bool help = false; // -help flag109 bool quiet = false; // -quiet flag 110 bool debug = true; // -debug flag 111 bool nolib = false; // -nolib flag 112 bool help = false; // -help flag 106 113 bool CFA_flag = false; // -CFA flag 107 114 bool cpp_flag = false; // -E or -M flag, preprocessor only … … 109 116 bool noincstd_flag = false; // -no-include-stdhdr= flag 110 117 bool debugging __attribute(( unused )) = false; // -g flag 111 bool m32 = false; // -m32 flag112 bool m64 = false; // -m64 flag118 bool m32 = false; // -m32 flag 119 bool m64 = false; // -m64 flag 113 120 bool intree = false; 114 121 … … 191 198 args[nargs] = argv[i]; // pass the argument along 192 199 nargs += 1; 193 } else if ( prefix( arg, "-x" ) ) { // file suffix ?194 string lang;195 args[nargs] = argv[i]; // pass the argument along196 nargs += 1;197 if ( arg.length() == 2 ) { // separate argument ?198 i += 1;199 if ( i == argc ) continue; // next argument available ?200 lang = argv[i];201 args[nargs] = argv[i]; // pass the argument along202 nargs += 1;203 } else {204 lang = arg.substr( 2 );205 } // if206 x_flag = lang != "none";207 200 } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) { 208 201 std_flag = true; // -std=XX provided … … 290 283 } // if 291 284 } else { 292 bool cfa = suffix( arg ); // check suffix 293 if ( ! x_flag && cfa ) { // no explicit suffix and cfa suffix ? 294 args[nargs] = "-x"; 295 nargs += 1; 296 args[nargs] = "c"; 297 nargs += 1; 298 } // if 285 bool cfa = suffix( arg, args, nargs ); // check suffix 299 286 args[nargs] = argv[i]; // concatenate file 300 287 nargs += 1; 301 if ( ! x_flag && cfa ) { // no explicit suffix and cfa suffix ?288 if ( cfa ) { 302 289 args[nargs] = "-x"; 303 290 nargs += 1; … … 308 295 } // if 309 296 } // for 297 298 args[nargs] = "-x"; // turn off language 299 nargs += 1; 300 args[nargs] = "none"; 301 nargs += 1; 310 302 311 303 #ifdef __x86_64__
Note:
See TracChangeset
for help on using the changeset viewer.