Changeset 7350330f for driver/cc1.cc


Ignore:
Timestamp:
Sep 27, 2023, 9:56:47 PM (8 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
ca20b07
Parents:
5a1ae14
Message:

formatting, remove unnecessary use of c_str(), add better debug printing for cc1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cc1.cc

    r5a1ae14 r7350330f  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun  9 11:36:44 2023
    13 // Update Count     : 423
     12// Last Modified On : Mon Sep 25 11:07:22 2023
     13// Update Count     : 427
    1414//
    1515
    1616#include <iostream>
    17 using std::cerr;
    18 using std::endl;
    1917#include <string>
    20 using std::string;
    2118#include <algorithm>                                                                    // find
    2219#include <cstdio>                                                                               // stderr, stdout, perror, fprintf
    2320#include <cstdlib>                                                                              // getenv, exit, mkstemp
     21using namespace std;
    2422#include <unistd.h>                                                                             // execvp, fork, unlink
    2523#include <sys/wait.h>                                                                   // wait
     
    5250        if ( dot == string::npos ) return;
    5351        const string * end = suffixes + NumSuffixes;
    54         if ( std::find( suffixes, end, arg.substr( dot + 1 ) ) != end ) {
     52        if ( find( suffixes, end, arg.substr( dot + 1 ) ) != end ) {
    5553                args[nargs++] = "-x";
    5654                args[nargs++] = "c";
     
    153151
    154152        #ifdef __DEBUG_H__
    155         cerr << "Stage1" << endl;
     153        cerr << "#########" << endl << "Stage1 " << string( 100, '#' ) << endl << "#########" << endl;
    156154        #endif // __DEBUG_H__
    157155        checkEnv1();                                                                            // arguments passed via environment variables
    158156        #ifdef __DEBUG_H__
     157        cerr << string( 100, '*' ) << endl;
    159158        for ( int i = 1; i < argc; i += 1 ) {
    160159                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    161160        } // for
     161        cerr << string( 100, '*' ) << endl;
    162162        #endif // __DEBUG_H__
    163163
     
    260260                } else {
    261261                        args[nargs++] = "-x";
    262                         args[nargs++] = ( *new string( lang.c_str() ) ).c_str();
     262                        args[nargs++] = ( *new string( lang ) ).c_str();
    263263                } // if
    264264                args[nargs++] = cpp_in;
     
    275275                } // for
    276276                cerr << endl;
     277                cerr << string( 100, '*' ) << endl;
    277278                #endif // __DEBUG_H__
    278279
     
    298299                } else {
    299300                        args[nargs++] = "-x";
    300                         args[nargs++] = ( *new string( lang.c_str() ) ).c_str();
     301                        args[nargs++] = ( *new string( lang ) ).c_str();
    301302                } // if
    302303                args[nargs++] = cpp_in;                                                 // input to cpp
     
    346347
    347348        #ifdef __DEBUG_H__
    348         cerr << "Stage2" << endl;
     349        cerr << "#########" << endl << "Stage2 " << string( 100, '#' ) << endl << "#########" << endl;
    349350        #endif // __DEBUG_H__
    350351        checkEnv2( cargs, ncargs );                                                     // arguments passed via environment variables
    351352        #ifdef __DEBUG_H__
     353        cerr << string( 100, '*' ) << endl;
    352354        for ( int i = 1; i < argc; i += 1 ) {
    353355                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    354356        } // for
     357        cerr << string( 100, '*' ) << endl;
    355358        #endif // __DEBUG_H__
    356359
     
    473476                if ( CFA_flag ) {                                                               // run cfa-cpp ?
    474477                        if ( o_file.size() != 0 ) {                                     // location for output
    475                                 cargs[ncargs++] = ( *new string( o_file.c_str() ) ).c_str();
     478                                cargs[ncargs++] = ( *new string( o_file ) ).c_str();
    476479                        } // if
    477480                } else {
     
    571574int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
    572575        #ifdef __DEBUG_H__
    573         for ( int i = 0; env[i] != nullptr; i += 1 ) {
    574                 cerr << env[i] << endl;
    575         } // for
     576        cerr << "#########" << endl << "main cc1 " << string( 100, '#' ) << endl << "#########" << endl;
    576577        #endif // __DEBUG_H__
    577578
Note: See TracChangeset for help on using the changeset viewer.