binpac: Added an option to quiet the status output from binpac.

This adds the -q command line flag to quiet the output.
It also fixes a small compiler warning.
This commit is contained in:
Seth Hall 2011-01-20 15:34:39 -05:00 committed by Tim Wojtulewicz
parent c2dbefab17
commit 1a15b968e6
4 changed files with 14 additions and 4 deletions

View file

@ -12,6 +12,7 @@
using namespace std; using namespace std;
extern bool FLAGS_pac_debug; extern bool FLAGS_pac_debug;
extern bool FLAGS_quiet;
extern vector<string> FLAGS_include_directories; extern vector<string> FLAGS_include_directories;
extern string input_filename; extern string input_filename;
extern int line_number; extern int line_number;

View file

@ -21,6 +21,7 @@ extern void switch_to_file(FILE* fp_input);
string input_filename; string input_filename;
bool FLAGS_pac_debug = false; bool FLAGS_pac_debug = false;
bool FLAGS_quiet = false;
string FLAGS_output_directory; string FLAGS_output_directory;
vector<string> FLAGS_include_directories; vector<string> FLAGS_include_directories;
@ -192,6 +193,7 @@ void usage()
fprintf(stderr, " <pac files> | pac-language input files\n"); fprintf(stderr, " <pac files> | pac-language input files\n");
fprintf(stderr, " -d <dir> | use given directory for compiler output\n"); fprintf(stderr, " -d <dir> | use given directory for compiler output\n");
fprintf(stderr, " -D | enable debugging output\n"); fprintf(stderr, " -D | enable debugging output\n");
fprintf(stderr, " -q | stay quiet\n");
fprintf(stderr, " -h | show command line help\n"); fprintf(stderr, " -h | show command line help\n");
fprintf(stderr, " -I <dir> | include <dir> in input file search path\n"); fprintf(stderr, " -I <dir> | include <dir> in input file search path\n");
exit(1); exit(1);
@ -203,7 +205,7 @@ int main(int argc, char* argv[])
extern char *malloc_options; extern char *malloc_options;
#endif #endif
int o; int o;
while ( (o = getopt(argc, argv, "DI:d:h")) != -1 ) while ( (o = getopt(argc, argv, "DqI:d:h")) != -1 )
{ {
switch(o) switch(o)
{ {
@ -214,6 +216,10 @@ int main(int argc, char* argv[])
malloc_options = "A"; malloc_options = "A";
#endif #endif
break; break;
case 'q':
FLAGS_quiet = true;
break;
case 'I': case 'I':
// Add to FLAGS_include_directories // Add to FLAGS_include_directories

View file

@ -313,7 +313,8 @@ void switch_to_file(const char *filename)
input_filename = string(filename); input_filename = string(filename);
line_number = 1; line_number = 1;
switch_to_file(yyin); switch_to_file(yyin);
fprintf(stderr, "switching to file %s\n", input_filename.c_str()); if ( !FLAGS_quiet )
fprintf(stderr, "switching to file %s\n", input_filename.c_str());
} }
void include_file(const char *filename) void include_file(const char *filename)

View file

@ -94,7 +94,8 @@ void TypeDecl::GenCode(Output* out_h, Output* out_cc)
if ( type_->tot() == Type::EXTERN || type_->tot() == Type::STRING ) if ( type_->tot() == Type::EXTERN || type_->tot() == Type::STRING )
return; return;
fprintf(stderr, "Generating code for %s\n", class_name().c_str()); if ( !FLAGS_quiet )
fprintf(stderr, "Generating code for %s\n", class_name().c_str());
if ( RequiresAnalyzerContext::compute(type_) ) if ( RequiresAnalyzerContext::compute(type_) )
{ {
@ -125,7 +126,8 @@ void TypeDecl::GenCode(Output* out_h, Output* out_cc)
out_h->println(""); out_h->println("");
out_h->print("class %s", class_name().c_str()); out_h->print("class %s", class_name().c_str());
bool first = true; bool first = true;
foreach(i, vector<string>, &base_classes) vector<string>::iterator i;
for ( i = (&base_classes)->begin(); i != (&base_classes)->end(); ++i )
{ {
if ( first ) if ( first )
{ {