Changeset e0bd0f9 for src


Ignore:
Timestamp:
Aug 22, 2019, 11:21:56 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2c60af75
Parents:
7d01cf44
Message:

remove -F flag and fix usage message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r7d01cf44 re0bd0f9  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun  5 20:35:13 2019
    13 // Update Count     : 601
     12// Last Modified On : Thu Aug 22 13:06:18 2019
     13// Update Count     : 605
    1414//
    1515
     
    9898static std::string PreludeDirector = "";
    9999
    100 static void parse_cmdline( int argc, char *argv[], const char *& filename );
     100static void parse_cmdline( int argc, char *argv[] );
    101101static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
    102102static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
     
    171171        FILE * input;                                                                           // use FILE rather than istream because yyin is FILE
    172172        ostream * output = & cout;
    173         const char * filename = nullptr;
    174173        list< Declaration * > translationUnit;
    175174
     
    183182        // } // for
    184183
    185         parse_cmdline( argc, argv, filename );                          // process command-line arguments
     184        parse_cmdline( argc, argv );                                            // process command-line arguments
    186185        CodeGen::FixMain::setReplaceMain( !nomainp );
    187186
     
    190189                if ( optind < argc ) {                                                  // any commands after the flags ? => input file name
    191190                        input = fopen( argv[ optind ], "r" );
    192                         assertf( input, "cannot open %s\n", argv[ optind ] );
    193                         // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
    194                         if ( filename == nullptr ) filename = argv[ optind ];
    195                         // prelude filename comes in differently
    196                         if ( libcfap ) filename = "prelude.cfa";
     191                        assertf( input, "cannot open %s because %s\n", argv[ optind ], strerror( errno ) );
    197192                        optind += 1;
    198193                } else {                                                                                // no input file name
    199194                        input = stdin;
    200                         // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass
    201                         // a fake name along
    202                         if ( filename == nullptr ) filename = "stdin";
    203195                } // if
    204196
     
    438430
    439431
    440 static const char optstring[] = ":hlLmNnpP:S:twW:D:F:";
     432static const char optstring[] = ":hlLmNnpP:S:twW:D:";
    441433
    442434enum { PreludeDir = 128 };
     
    456448        { "", no_argument, nullptr, 0 },                                        // -W
    457449        { "", no_argument, nullptr, 0 },                                        // -D
    458         { "", no_argument, nullptr, 0 },                                        // -F
    459450        { nullptr, 0, nullptr, 0 }
    460451}; // long_opts
     
    475466        "",                                                                                                     // -W
    476467        "",                                                                                                     // -D
    477         "",                                                                                                     // -F
    478468}; // description
    479469
     
    510500
    511501static void usage( char *argv[] ) {
    512     cout << "Usage: " << argv[0] << " options are:" << endl;
     502    cout << "Usage: " << argv[0] << " [options] [input-file (default stdin)] [output-file (default stdout)], where options are:" << endl;
    513503        int i = 0, j = 1;                                                                       // j skips starting colon
    514504        for ( ; long_opts[i].name != 0 && optstring[j] != '\0'; i += 1, j += 1 ) {
     
    536526} // usage
    537527
    538 static void parse_cmdline( int argc, char * argv[], const char *& filename ) {
     528static void parse_cmdline( int argc, char * argv[] ) {
    539529        opterr = 0;                                                                                     // (global) prevent getopt from printing error messages
    540530
     
    607597                  case 'D':                                                                             // ignore -Dxxx, forwarded by cpp, hidden
    608598                        break;
    609                   case 'F':                                                                             // source file-name without suffix, hidden
    610                         filename = optarg;
    611                         break;
    612599                  case '?':                                                                             // unknown option
    613600                        if ( optopt ) {                                                         // short option ?
Note: See TracChangeset for help on using the changeset viewer.