From 1eff067ff90379c14c6a9770a76d6a3e9f99cd82 Mon Sep 17 00:00:00 2001 From: cuz Date: Sat, 10 Mar 2001 10:21:03 +0000 Subject: [PATCH] Moved verbose output to a shared module in the common/ directory. git-svn-id: svn://svn.cc65.org/cc65/trunk@619 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ar65/global.c | 4 ---- src/ar65/global.h | 4 ---- src/ar65/library.c | 11 ++++------- src/ar65/main.c | 5 +++-- src/ca65/expr.c | 5 +++-- src/ca65/global.c | 1 - src/ca65/global.h | 1 - src/ca65/main.c | 5 +++-- src/cc65/error.c | 18 ++++++++---------- src/cc65/global.c | 1 - src/cc65/global.h | 1 - src/cc65/main.c | 3 ++- src/cc65/optimize.c | 4 ++-- src/cc65/preproc.c | 5 ++--- src/cl65/main.c | 2 +- src/common/print.c | 5 ++--- src/common/print.h | 7 +++++-- src/da65/global.c | 1 - src/da65/global.h | 1 - src/da65/main.c | 1 + src/da65/output.c | 1 + src/ld65/bin.c | 15 +++++---------- src/ld65/config.c | 5 ++--- src/ld65/global.c | 1 - src/ld65/global.h | 1 - src/ld65/main.c | 5 +++-- src/ld65/o65.c | 9 +++------ src/ld65/segments.c | 7 +++---- 28 files changed, 53 insertions(+), 76 deletions(-) diff --git a/src/ar65/global.c b/src/ar65/global.c index 8bd122ca3..459dc83e7 100644 --- a/src/ar65/global.c +++ b/src/ar65/global.c @@ -43,7 +43,3 @@ -int Verbose = 0; /* Verbose operation flag */ - - - diff --git a/src/ar65/global.h b/src/ar65/global.h index 0a5b84194..c8021be86 100644 --- a/src/ar65/global.h +++ b/src/ar65/global.h @@ -44,10 +44,6 @@ -extern int Verbose; /* Verbose operation flag */ - - - /* End of global.h */ #endif diff --git a/src/ar65/library.c b/src/ar65/library.c index 21b9f072e..d92b8b255 100644 --- a/src/ar65/library.c +++ b/src/ar65/library.c @@ -42,6 +42,7 @@ #include "exprdefs.h" #include "filepos.h" #include "libdefs.h" +#include "print.h" #include "symdefs.h" #include "xmalloc.h" @@ -385,11 +386,9 @@ static void LibCheckExports (ObjData* O) unsigned Count = GetVar (&Exports); /* Read the exports */ - if (Verbose > 1) { - printf ("Module `%s' (%u exports):\n", O->Name, Count); - } + Print (stdout, 1, "Module `%s' (%u exports):\n", O->Name, Count); while (Count--) { - + unsigned char Tag; unsigned Len; char* Name; @@ -420,9 +419,7 @@ static void LibCheckExports (ObjData* O) SkipFilePos (&Exports); /* Insert the name into the hash table */ - if (Verbose > 1) { - printf (" %s\n", Name); - } + Print (stdout, 1, " %s\n", Name); ExpInsert (Name, O->Index); /* Free the name */ diff --git a/src/ar65/main.c b/src/ar65/main.c index 6cb8fa4bd..f098c8cb3 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -40,6 +40,7 @@ /* common */ #include "cmdline.h" +#include "print.h" #include "version.h" #include "global.h" @@ -79,7 +80,7 @@ int main (int argc, char* argv []) int I; /* Initialize the cmdline module */ - InitCmdLine (&argc, &argv, "ar65"); + InitCmdLine (&argc, &argv, "ar65"); /* We must have a file name */ if (ArgCount < 2) { @@ -112,7 +113,7 @@ int main (int argc, char* argv []) break; case 'v': - ++Verbose; + ++Verbosity; break; case 'x': diff --git a/src/ca65/expr.c b/src/ca65/expr.c index f6b412547..c0d8f8e46 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -38,6 +38,7 @@ /* common */ #include "check.h" #include "exprdefs.h" +#include "print.h" #include "tgttrans.h" #include "xmalloc.h" @@ -1036,7 +1037,7 @@ int IsConstExpr (ExprNode* Root) case EXPR_SYMBOL: Sym = Root->V.Sym; if (SymHasUserMark (Sym)) { - if (Verbose) { + if (Verbosity > 0) { DumpExpr (Root); } PError (GetSymPos (Sym), ERR_CIRCULAR_REFERENCE); @@ -1311,7 +1312,7 @@ static ExprNode* RemoveSyms (ExprNode* Expr, int MustClone) SymEntry* Sym = Expr->V.Sym; if (SymHasUserMark (Sym)) { /* Circular definition */ - if (Verbose) { + if (Verbosity) { DumpExpr (Expr); } PError (GetSymPos (Sym), ERR_CIRCULAR_REFERENCE); diff --git a/src/ca65/global.c b/src/ca65/global.c index 0bd7a54ee..1ea18ca2b 100644 --- a/src/ca65/global.c +++ b/src/ca65/global.c @@ -56,7 +56,6 @@ char LocalStart = '@'; /* This char starts local symbols */ unsigned char IgnoreCase = 0; /* Ignore case on identifiers? */ unsigned char AutoImport = 0; /* Mark unresolveds as import */ -unsigned char Verbose = 0; /* Verbose operation flag */ unsigned char SmartMode = 0; /* Smart mode */ unsigned char DbgSyms = 0; /* Add debug symbols */ unsigned char Listing = 0; /* Create listing file */ diff --git a/src/ca65/global.h b/src/ca65/global.h index 7288bb61c..f325e32f1 100644 --- a/src/ca65/global.h +++ b/src/ca65/global.h @@ -57,7 +57,6 @@ extern char LocalStart; /* This char starts local symbols */ extern unsigned char IgnoreCase; /* Ignore case on identifiers? */ extern unsigned char AutoImport; /* Mark unresolveds as import */ -extern unsigned char Verbose; /* Verbose operation flag */ extern unsigned char SmartMode; /* Smart mode */ extern unsigned char DbgSyms; /* Add debug symbols */ extern unsigned char Listing; /* Create listing file */ diff --git a/src/ca65/main.c b/src/ca65/main.c index b01b50166..61e72d885 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -41,6 +41,7 @@ /* common */ #include "chartype.h" #include "cmdline.h" +#include "print.h" #include "target.h" #include "tgttrans.h" #include "version.h" @@ -313,7 +314,7 @@ static void OptTarget (const char* Opt, const char* Arg) static void OptVerbose (const char* Opt, const char* Arg) /* Increase verbosity */ { - ++Verbose; + ++Verbosity; } @@ -636,7 +637,7 @@ int main (int argc, char* argv []) } /* Dump the data */ - if (Verbose >= 2) { + if (Verbosity >= 2) { SymDump (stdout); SegDump (); } diff --git a/src/cc65/error.c b/src/cc65/error.c index 2f443f28d..d6557c57c 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -37,6 +37,10 @@ #include #include +/* common */ +#include "print.h" + +/* cc65 */ #include "global.h" #include "input.h" #include "scanner.h" @@ -71,9 +75,7 @@ static void IntWarning (const char* Filename, unsigned Line, const char* Msg, va vfprintf (stderr, Msg, ap); fprintf (stderr, "\n"); - if (Verbose) { - fprintf (stderr, "Line: %s\n", line); - } + Print (stderr, 1, "Line: %s\n", line); ++WarningCount; } } @@ -109,9 +111,7 @@ static void IntError (const char* Filename, unsigned Line, const char* Msg, va_l vfprintf (stderr, Msg, ap); fprintf (stderr, "\n"); - if (Verbose) { - fprintf (stderr, "Line: %s\n", line); - } + Print (stderr, 1, "Line: %s\n", line); ++ErrorCount; if (ErrorCount > 10) { Fatal ("Too many errors"); @@ -154,9 +154,7 @@ void Fatal (const char* Format, ...) va_end (ap); fprintf (stderr, "\n"); - if (Verbose) { - fprintf (stderr, "Line: %s\n", line); - } + Print (stderr, 1, "Line: %s\n", line); exit (EXIT_FAILURE); } @@ -184,7 +182,7 @@ void Internal (char* Format, ...) void ErrorReport (void) /* Report errors (called at end of compile) */ { - if (ErrorCount == 0 && Verbose) { + if (ErrorCount == 0 && Verbosity > 0) { printf ("No errors.\n"); } } diff --git a/src/cc65/global.c b/src/cc65/global.c index fb9d9b0b1..97beb8ab5 100644 --- a/src/cc65/global.c +++ b/src/cc65/global.c @@ -54,7 +54,6 @@ unsigned char AllowRegVarAddr = 0; /* Allow taking addresses of register vars */ unsigned char RegVarsToCallStack= 0; /* Save reg variables on call stack */ unsigned char StaticLocals = 0; /* Make local variables static */ unsigned char SignedChars = 0; /* Make characters signed by default */ -unsigned char Verbose = 0; /* Verbose flag */ unsigned char AddSource = 0; /* Add source lines as comments */ unsigned char DebugInfo = 0; /* Add debug info to the obj */ unsigned char Debug = 0; /* Debug mode */ diff --git a/src/cc65/global.h b/src/cc65/global.h index c48d38155..593e2f0f2 100644 --- a/src/cc65/global.h +++ b/src/cc65/global.h @@ -55,7 +55,6 @@ extern unsigned char AllowRegVarAddr; /* Allow taking addresses of register vars extern unsigned char RegVarsToCallStack; /* Save reg variables on call stack */ extern unsigned char StaticLocals; /* Make local variables static */ extern unsigned char SignedChars; /* Make characters signed by default */ -extern unsigned char Verbose; /* Verbose flag */ extern unsigned char AddSource; /* Add source lines as comments */ extern unsigned char DebugInfo; /* Add debug info to the obj */ extern unsigned char Debug; /* Debug mode */ diff --git a/src/cc65/main.c b/src/cc65/main.c index 1b9735e90..73f8382c9 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -43,6 +43,7 @@ #include "chartype.h" #include "cmdline.h" #include "fname.h" +#include "print.h" #include "target.h" #include "tgttrans.h" #include "version.h" @@ -410,7 +411,7 @@ static void OptTarget (const char* Opt, const char* Arg) static void OptVerbose (const char* Opt, const char* Arg) /* Increase verbosity */ { - ++Verbose; + ++Verbosity; } diff --git a/src/cc65/optimize.c b/src/cc65/optimize.c index c714cf96f..4a4a07952 100644 --- a/src/cc65/optimize.c +++ b/src/cc65/optimize.c @@ -36,12 +36,12 @@ #include #include #include -//#include /* common */ #include "attrib.h" #include "chartype.h" #include "check.h" +#include "print.h" #include "xmalloc.h" #include "xsprintf.h" @@ -4627,7 +4627,7 @@ void OptDoOpt (void) for (I = 0; I < sizeof(OptFuncs)/sizeof(OptFuncs[0]); ++I, Flags <<= 1) { if ((OptDisable & Flags) == 0) { OptFuncs[I] (); - } else if (Verbose || Debug) { + } else if (Verbosity > 0 || Debug) { printf ("Optimizer pass %u skipped\n", I); } } diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index 3449a41be..5c652aad4 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -8,6 +8,7 @@ /* common */ #include "chartype.h" +#include "print.h" #include "xmalloc.h" /* cc65 */ @@ -916,8 +917,6 @@ void Preprocess (void) Done: xlateline (); - if (Verbose > 1) { - printf ("line: %s\n", line); - } + Print (stdout, 2, "line: %s\n", line); } diff --git a/src/cl65/main.c b/src/cl65/main.c index bb2a87e59..17f816036 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -743,7 +743,7 @@ int main (int argc, char* argv []) /* Our default target is the C64 instead of "none" */ Target = TGT_C64; - + /* Check the parameters */ I = 1; while (I < ArgCount) { diff --git a/src/common/print.c b/src/common/print.c index 52080e7b0..48004d226 100644 --- a/src/common/print.c +++ b/src/common/print.c @@ -33,7 +33,6 @@ -#include #include /* common */ @@ -57,7 +56,7 @@ unsigned char Verbosity = 0; /* Verbose operation flag */ -void Print (unsigned V, const char* Format, ...) +void Print (FILE* F, unsigned V, const char* Format, ...) /* Output according to Verbosity */ { va_list ap; @@ -70,7 +69,7 @@ void Print (unsigned V, const char* Format, ...) /* Output */ va_start (ap, Format); - vprintf (Format, ap); + vfprintf (F, Format, ap); va_end (ap); } diff --git a/src/common/print.h b/src/common/print.h index 4def4c90d..cd5a1d20d 100644 --- a/src/common/print.h +++ b/src/common/print.h @@ -38,13 +38,15 @@ +#include + /* common */ #include "attrib.h" /*****************************************************************************/ -/* Data */ +/* Data */ /*****************************************************************************/ @@ -59,7 +61,8 @@ extern unsigned char Verbosity; /* Verbose operation flag */ -void Print (unsigned V, const char* Format, ...) attribute ((format (printf, 2, 3))); +void Print (FILE* F, unsigned V, const char* Format, ...) + attribute ((format (printf, 3, 4))); /* Output according to Verbosity */ diff --git a/src/da65/global.c b/src/da65/global.c index c7833a4fc..d3e36dc9d 100644 --- a/src/da65/global.c +++ b/src/da65/global.c @@ -52,7 +52,6 @@ const char OutExt[] = ".dis"; /* Output file extension */ const char CfgExt[] = ".cfg"; /* Config file extension */ /* Flags and other command line stuff */ -unsigned char Verbosity = 4; /* Verbosity of the output file */ unsigned char FormFeeds = 0; /* Add form feeds to the output? */ unsigned char PassCount = 2; /* How many passed do we do? */ unsigned long StartAddr = 0xC000; /* Start/load address of the program */ diff --git a/src/da65/global.h b/src/da65/global.h index 4dcef7077..7ebd28dac 100644 --- a/src/da65/global.h +++ b/src/da65/global.h @@ -53,7 +53,6 @@ extern const char OutExt[]; /* Output file extension */ extern const char CfgExt[]; /* Config file extension */ /* Flags and other command line stuff */ -extern unsigned char Verbosity; /* Verbosity of the output file */ extern unsigned char FormFeeds; /* Add form feeds to the output? */ extern unsigned char PassCount; /* How many passed do we do? */ extern unsigned long StartAddr; /* Start/load address of the program */ diff --git a/src/da65/main.c b/src/da65/main.c index cf33b8188..916afbdfb 100644 --- a/src/da65/main.c +++ b/src/da65/main.c @@ -43,6 +43,7 @@ #include "abend.h" #include "cmdline.h" #include "fname.h" +#include "print.h" #include "version.h" /* da65 */ diff --git a/src/da65/output.c b/src/da65/output.c index 6f3e3f963..985fd4ac2 100644 --- a/src/da65/output.c +++ b/src/da65/output.c @@ -40,6 +40,7 @@ #include /* common */ +#include "print.h" #include "version.h" /* da65 */ diff --git a/src/ld65/bin.c b/src/ld65/bin.c index f6f7425fa..7f4b08551 100644 --- a/src/ld65/bin.c +++ b/src/ld65/bin.c @@ -38,6 +38,7 @@ #include /* common */ +#include "print.h" #include "xmalloc.h" /* ld65 */ @@ -133,9 +134,7 @@ static void BinWriteMem (BinDesc* D, Memory* M) SegDesc* S = N->Seg; /* Keep the user happy */ - if (Verbose) { - printf (" Writing `%s'\n", S->Name); - } + Print (stdout, 1, " Writing `%s'\n", S->Name); /* Writes do only occur in the load area and not for BSS segments */ DoWrite = (S->Flags & SF_BSS) == 0 && /* No BSS segment */ @@ -143,7 +142,7 @@ static void BinWriteMem (BinDesc* D, Memory* M) S->Seg->Dumped == 0; /* Not already written */ /* Output the DoWrite flag for debugging */ - if (Verbose > 1) { + if (Verbosity > 1) { PrintBoolVal ("bss", S->Flags & SF_BSS); PrintBoolVal ("LoadArea", S->Load == M); PrintBoolVal ("Dumped", S->Seg->Dumped); @@ -253,16 +252,12 @@ void BinWriteTarget (BinDesc* D, struct File* F) } /* Keep the user happy */ - if (Verbose) { - printf ("Opened `%s'...\n", F->Name); - } + Print (stdout, 1, "Opened `%s'...\n", F->Name); /* Dump all memory areas */ M = F->MemList; while (M) { - if (Verbose) { - printf (" Dumping `%s'\n", M->Name); - } + Print (stdout, 1, " Dumping `%s'\n", M->Name); BinWriteMem (D, M); M = M->FNext; } diff --git a/src/ld65/config.c b/src/ld65/config.c index be31d6fdb..902db00a8 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -41,6 +41,7 @@ /* common */ #include "check.h" #include "bitops.h" +#include "print.h" #include "xmalloc.h" /* ld65 */ @@ -1405,9 +1406,7 @@ void CfgWriteTarget (void) MemListNode* N; /* Debugging */ - if (Verbose > 1) { - printf ("Skipping `%s'...\n", M->Name); - } + Print (stdout, 2, "Skipping `%s'...\n", M->Name); /* Walk throught the segments */ N = M->SegList; diff --git a/src/ld65/global.c b/src/ld65/global.c index fe27c6033..1a624cade 100644 --- a/src/ld65/global.c +++ b/src/ld65/global.c @@ -47,7 +47,6 @@ const char* OutputName = "a.out"; /* Name of output file */ unsigned long StartAddr = 0x200; /* Start address */ -unsigned char Verbose = 0; /* Verbose operation flag */ unsigned char VerboseMap = 0; /* Verbose map file */ const char* MapFileName = 0; /* Name of the map file */ const char* LabelFileName = 0; /* Name of the label file */ diff --git a/src/ld65/global.h b/src/ld65/global.h index 95309abcc..288a9d917 100644 --- a/src/ld65/global.h +++ b/src/ld65/global.h @@ -48,7 +48,6 @@ extern const char* OutputName; /* Name of output file */ extern unsigned long StartAddr; /* Start address */ -extern unsigned char Verbose; /* Verbose operation flag */ extern unsigned char VerboseMap; /* Verbose map file */ extern const char* MapFileName; /* Name of the map file */ extern const char* LabelFileName; /* Name of the label file */ diff --git a/src/ld65/main.c b/src/ld65/main.c index 6bc07dac0..ebc05846d 100644 --- a/src/ld65/main.c +++ b/src/ld65/main.c @@ -42,6 +42,7 @@ #include "cmdline.h" #include "libdefs.h" #include "objdefs.h" +#include "print.h" #include "target.h" #include "version.h" #include "xmalloc.h" @@ -351,7 +352,7 @@ int main (int argc, char* argv []) case 'v': switch (Arg [2]) { case 'm': VerboseMap = 1; break; - case '\0': ++Verbose; break; + case '\0': ++Verbosity; break; default: UnknownOption (Arg); } break; @@ -426,7 +427,7 @@ int main (int argc, char* argv []) } /* Dump the data for debugging */ - if (Verbose > 1) { + if (Verbosity > 1) { SegDump (); ConDesDump (); } diff --git a/src/ld65/o65.c b/src/ld65/o65.c index c1441037b..841e6df6c 100644 --- a/src/ld65/o65.c +++ b/src/ld65/o65.c @@ -40,6 +40,7 @@ /* common */ #include "check.h" +#include "print.h" #include "version.h" #include "xmalloc.h" @@ -575,9 +576,7 @@ static void O65WriteSeg (O65Desc* D, SegDesc** Seg, unsigned Count, int DoWrite) S = Seg [I]; /* Keep the user happy */ - if (Verbose) { - printf (" Writing `%s'\n", S->Name); - } + Print (stdout, 1, " Writing `%s'\n", S->Name); /* Write this segment */ if (DoWrite) { @@ -1018,9 +1017,7 @@ void O65WriteTarget (O65Desc* D, File* F) } /* Keep the user happy */ - if (Verbose) { - printf ("Opened `%s'...\n", F->Name); - } + Print (stdout, 1, "Opened `%s'...\n", F->Name); /* Define some more options: A timestamp and the linker version */ T = time (0); diff --git a/src/ld65/segments.c b/src/ld65/segments.c index aa0251c38..3e49facb7 100644 --- a/src/ld65/segments.c +++ b/src/ld65/segments.c @@ -40,6 +40,7 @@ #include "check.h" #include "exprdefs.h" #include "hashstr.h" +#include "print.h" #include "segdefs.h" #include "symdefs.h" #include "xmalloc.h" @@ -229,10 +230,8 @@ Section* ReadSection (FILE* F, ObjData* O) Type = Read8 (F); /* Print some data */ - if (Verbose > 1) { - printf ("Module `%s': Found segment `%s', size = %lu, align = %u, type = %u\n", - GetObjFileName (O), Name, Size, Align, Type); - } + Print (stdout, 1, "Module `%s': Found segment `%s', size = %lu, align = %u, type = %u\n", + GetObjFileName (O), Name, Size, Align, Type); /* Get the segment for this section */ S = GetSegment (Name, Type, GetObjFileName (O)); -- 2.39.5