Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    r4f5a8a2 r2026bb6  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 10 08:44:15 2019
    13 // Update Count     : 311
     12// Last Modified On : Sun Feb 10 08:28:09 2019
     13// Update Count     : 281
    1414//
    1515
     
    2020#include <string>                                                                               // STL version
    2121#include <string.h>                                                                             // strcmp
    22 #include <algorithm>                                                                    // find
    2322
    2423#include <sys/types.h>
     
    2726#include "Common/SemanticError.h"
    2827#include "config.h"                                                                             // configure info
    29 
    3028
    3129using std::cerr;
     
    4240} // prefix
    4341
    44 bool suffix( string arg ) {
    45         enum { NumSuffixes = 3 };
    46         static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
     42enum { NumSuffixes = 2 };
     43const string suffixes[NumSuffixes] = { "cfa", "hfa", };
     44
     45bool suffix( string arg, const char * args[], int & nargs ) {
    4746        //std::cerr << arg << std::endl;
    4847        size_t dot = arg.find_last_of( "." );
    4948        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    5049        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;
    5361} // suffix
    5462
    5563
    56 void shuffle( const char * args[], int S, int E, int N ) {
     64void shuffle( const char *args[], int S, int E, int N ) {
    5765        // S & E index 1 passed the end so adjust with -1
    5866        #ifdef __DEBUG_H__
     
    6775} // shuffle
    6876
    69 static inline bool dirExists( const string & path ) {
     77static inline bool dirExists(const string & path) {
    7078    struct stat info;
    7179    if(stat( path.c_str(), &info ) != 0)
     
    8088#define str(s) #s
    8189
    82 int main( int argc, char * argv[] ) {
     90int main( int argc, char *argv[] ) {
    8391        string Version( CFA_VERSION_LONG );                                     // current version number from CONFIG
    8492        string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
     
    96104        string compiler_name;                                                           // name of C compiler
    97105
    98         bool x_flag = false;                                                            // -x flag
    99106        bool nonoptarg = false;                                                         // indicates non-option argument specified
    100107        bool link = true;                                                                       // linking as well as compiling
    101108        bool verbose = false;                                                           // -v flag
    102         bool quiet = false;                                                                     // -quiet flag
    103         bool debug = true;                                                                      // -debug flag
    104         bool nolib = false;                                                                     // -nolib flag
    105         bool help = false;                                                                      // -help flag
     109        bool quiet = false;                                                             // -quiet flag
     110        bool debug = true;                                                              // -debug flag
     111        bool nolib = false;                                                             // -nolib flag
     112        bool help = false;                                                              // -help flag
    106113        bool CFA_flag = false;                                                          // -CFA flag
    107114        bool cpp_flag = false;                                                          // -E or -M flag, preprocessor only
     
    109116        bool noincstd_flag = false;                                                     // -no-include-stdhdr= flag
    110117        bool debugging __attribute(( unused )) = false;         // -g flag
    111         bool m32 = false;                                                                       // -m32 flag
    112         bool m64 = false;                                                                       // -m64 flag
     118        bool m32 = false;                                    // -m32 flag
     119        bool m64 = false;                                    // -m64 flag
    113120        bool intree = false;
    114121
     
    191198                                args[nargs] = argv[i];                                  // pass the argument along
    192199                                nargs += 1;
    193                         } else if ( prefix( arg, "-x" ) ) {                     // file suffix ?
    194                                 string lang;
    195                                 args[nargs] = argv[i];                                  // pass the argument along
    196                                 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 along
    202                                         nargs += 1;
    203                                 } else {
    204                                         lang = arg.substr( 2 );
    205                                 } // if
    206                                 x_flag = lang != "none";
    207200                        } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) {
    208201                                std_flag = true;                                                // -std=XX provided
     
    290283                        } // if
    291284                } 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
    299286                        args[nargs] = argv[i];                                          // concatenate file
    300287                        nargs += 1;
    301                         if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
     288                        if ( cfa ) {
    302289                                args[nargs] = "-x";
    303290                                nargs += 1;
     
    308295                } // if
    309296        } // for
     297
     298    args[nargs] = "-x";                                                                 // turn off language
     299    nargs += 1;
     300    args[nargs] = "none";
     301    nargs += 1;
    310302
    311303        #ifdef __x86_64__
Note: See TracChangeset for help on using the changeset viewer.