From abcc981253f0889cbfb2d6784562a4466ea9cb6e Mon Sep 17 00:00:00 2001 From: cuz Date: Sat, 4 Jan 2003 16:59:51 +0000 Subject: [PATCH] Move the Debug flag into a new module "debugflag" in the common directory. Remove the const qualifier from the argument of xfree(). git-svn-id: svn://svn.cc65.org/cc65/trunk@1877 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/macpack.c | 6 ++--- src/ca65/scanner.c | 4 +-- src/ca65/scanner.h | 4 +-- src/cc65/codeent.c | 1 + src/cc65/codeseg.c | 1 + src/cc65/compile.c | 1 + src/cc65/expr.c | 5 ++-- src/cc65/global.c | 1 - src/cc65/global.h | 1 - src/cc65/main.c | 5 ++-- src/cc65/symtab.c | 1 + src/common/debugflag.c | 50 ++++++++++++++++++++++++++++++++++ src/common/debugflag.h | 55 ++++++++++++++++++++++++++++++++++++++ src/common/make/gcc.mak | 1 + src/common/make/watcom.mak | 1 + src/common/segdefs.h | 2 +- src/common/xmalloc.c | 7 ++--- src/common/xmalloc.h | 2 +- src/ld65/exports.c | 2 +- src/ld65/exports.h | 2 +- 20 files changed, 132 insertions(+), 20 deletions(-) create mode 100644 src/common/debugflag.c create mode 100644 src/common/debugflag.h diff --git a/src/ca65/macpack.c b/src/ca65/macpack.c index 0d968edba..02875d0b3 100644 --- a/src/ca65/macpack.c +++ b/src/ca65/macpack.c @@ -50,7 +50,7 @@ /* Predefined packages */ -static const char MacGeneric [] = /* Generic macros */ +static char MacGeneric [] = /* Generic macros */ ".macro add Arg1, Arg2\n" " clc\n" " .if .paramcount = 2\n" @@ -70,7 +70,7 @@ static const char MacGeneric [] = /* Generic macros */ -static const char MacLongBranch [] = /* Long branch macros */ +static char MacLongBranch [] = /* Long branch macros */ ".macro jeq Target\n" " .if .match(Target, 0)\n" " bne *+5\n" @@ -163,7 +163,7 @@ static const char MacLongBranch [] = /* Long branch macros */ /* Table with pointers to the different packages */ -static const char* MacPackages [] = { +static char* MacPackages [] = { MacGeneric, MacLongBranch, }; diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 537c35ec4..22bba99a9 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -95,7 +95,7 @@ struct InputFile_ { /* Struct to handle textual input data */ typedef struct InputData_ InputData; struct InputData_ { - const char* Data; /* Pointer to the data */ + char* Data; /* Pointer to the data */ const char* Pos; /* Pointer to current position */ int Malloced; /* Memory was malloced */ enum Token Tok; /* Last token */ @@ -370,7 +370,7 @@ void DoneInputFile (void) -void NewInputData (const char* Data, int Malloced) +void NewInputData (char* Data, int Malloced) /* Add a chunk of input data to the input stream */ { InputData* I; diff --git a/src/ca65/scanner.h b/src/ca65/scanner.h index eb214ab09..c10d69e3b 100644 --- a/src/ca65/scanner.h +++ b/src/ca65/scanner.h @@ -186,7 +186,7 @@ enum Token { TOK_P816, TOK_PAGELENGTH, TOK_PARAMCOUNT, - TOK_PC02, + TOK_PC02, TOK_POPSEG, TOK_PROC, TOK_PUSHSEG, @@ -240,7 +240,7 @@ void NewInputFile (const char* Name); void DoneInputFile (void); /* Close the current input file */ -void NewInputData (const char* Data, int Malloced); +void NewInputData (char* Data, int Malloced); /* Add a chunk of input data to the input stream */ void LocaseSVal (void); diff --git a/src/cc65/codeent.c b/src/cc65/codeent.c index 0a78fc858..b4a567b72 100644 --- a/src/cc65/codeent.c +++ b/src/cc65/codeent.c @@ -39,6 +39,7 @@ /* common */ #include "chartype.h" #include "check.h" +#include "debugflag.h" #include "xmalloc.h" #include "xsprintf.h" diff --git a/src/cc65/codeseg.c b/src/cc65/codeseg.c index 06260ff3a..ec229880c 100644 --- a/src/cc65/codeseg.c +++ b/src/cc65/codeseg.c @@ -39,6 +39,7 @@ /* common */ #include "chartype.h" #include "check.h" +#include "debugflag.h" #include "global.h" #include "hashstr.h" #include "strutil.h" diff --git a/src/cc65/compile.c b/src/cc65/compile.c index f194cb1aa..596988036 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -37,6 +37,7 @@ #include /* common */ +#include "debugflag.h" #include "version.h" #include "xmalloc.h" #include "xsprintf.h" diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 613721430..c375e0220 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -11,6 +11,7 @@ /* common */ #include "check.h" +#include "debugflag.h" #include "xmalloc.h" /* cc65 */ @@ -1628,11 +1629,11 @@ int hie10 (ExprDesc* lval) /* If the expression is already a pointer to function, the * additional dereferencing operator must be ignored. */ - if (IsTypeFuncPtr (lval->Type)) { + if (IsTypeFuncPtr (lval->Type)) { /* Expression not storable */ return 0; } else { - if (IsClassPtr (lval->Type)) { + if (IsClassPtr (lval->Type)) { lval->Type = Indirect (lval->Type); } else { Error ("Illegal indirection"); diff --git a/src/cc65/global.c b/src/cc65/global.c index 798c8569f..51cddb511 100644 --- a/src/cc65/global.c +++ b/src/cc65/global.c @@ -59,7 +59,6 @@ unsigned char StaticLocals = 0; /* Make local variables static */ unsigned char SignedChars = 0; /* Make characters signed by default */ 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 */ unsigned char CreateDep = 0; /* Create a dependency file */ unsigned char CheckStack = 0; /* Generate stack overflow checks */ diff --git a/src/cc65/global.h b/src/cc65/global.h index b7cc5a5dc..ff8f3bc91 100644 --- a/src/cc65/global.h +++ b/src/cc65/global.h @@ -60,7 +60,6 @@ extern unsigned char StaticLocals; /* Make local variables static */ extern unsigned char SignedChars; /* Make characters signed by default */ 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 */ extern unsigned char CreateDep; /* Create a dependency file */ extern unsigned char CheckStack; /* Generate stack overflow checks */ diff --git a/src/cc65/main.c b/src/cc65/main.c index f6686765d..8b1dc23b1 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -42,6 +42,7 @@ #include "abend.h" #include "chartype.h" #include "cmdline.h" +#include "debugflag.h" #include "fname.h" #include "print.h" #include "segdefs.h" @@ -401,10 +402,10 @@ static void OptDataName (const char* Opt attribute ((unused)), const char* Arg) static void OptDebug (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) + const char* Arg attribute ((unused))) /* Compiler debug mode */ { - Debug = 1; + ++Debug; } diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index dac4344b7..cc8dcc106 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -40,6 +40,7 @@ /* common */ #include "check.h" +#include "debugflag.h" #include "hashstr.h" #include "xmalloc.h" diff --git a/src/common/debugflag.c b/src/common/debugflag.c new file mode 100644 index 000000000..991f42b3a --- /dev/null +++ b/src/common/debugflag.c @@ -0,0 +1,50 @@ +/*****************************************************************************/ +/* */ +/* debugflag.c */ +/* */ +/* Global debug flag */ +/* */ +/* */ +/* */ +/* (C) 2002 Ullrich von Bassewitz */ +/* Wacholderweg 14 */ +/* D-70597 Stuttgart */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +/* common */ +#include "debugflag.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +unsigned char Debug = 0; /* Debug mode */ + + + diff --git a/src/common/debugflag.h b/src/common/debugflag.h new file mode 100644 index 000000000..e443b6029 --- /dev/null +++ b/src/common/debugflag.h @@ -0,0 +1,55 @@ +/*****************************************************************************/ +/* */ +/* debugflag.h */ +/* */ +/* Global debug flag */ +/* */ +/* */ +/* */ +/* (C) 2002 Ullrich von Bassewitz */ +/* Wacholderweg 14 */ +/* D-70597 Stuttgart */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef DEBUGFLAG_H +#define DEBUGFLAG_H + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +extern unsigned char Debug; /* Debug mode */ + + + +/* End of debugflag.h */ +#endif + + + diff --git a/src/common/make/gcc.mak b/src/common/make/gcc.mak index beec9ebd1..56691fb91 100644 --- a/src/common/make/gcc.mak +++ b/src/common/make/gcc.mak @@ -15,6 +15,7 @@ OBJS = abend.o \ check.o \ cmdline.o \ coll.o \ + debugflag.o \ exprdefs.o \ filepos.o \ fname.o \ diff --git a/src/common/make/watcom.mak b/src/common/make/watcom.mak index f71b1d513..51551a6b3 100644 --- a/src/common/make/watcom.mak +++ b/src/common/make/watcom.mak @@ -47,6 +47,7 @@ OBJS = abend.obj \ check.obj \ cmdline.obj \ coll.obj \ + debugflag.obj \ exprdefs.obj \ filepos.obj \ fname.obj \ diff --git a/src/common/segdefs.h b/src/common/segdefs.h index 9fe2f0d2b..2d4e4ba8e 100644 --- a/src/common/segdefs.h +++ b/src/common/segdefs.h @@ -75,7 +75,7 @@ /* Segment definition */ typedef struct SegDef SegDef; struct SegDef { - const char* Name; /* Segment name */ + char* Name; /* Segment name */ unsigned Type; /* Segment type, see above */ }; diff --git a/src/common/xmalloc.c b/src/common/xmalloc.c index 8b14d1ff5..673f6e69d 100644 --- a/src/common/xmalloc.c +++ b/src/common/xmalloc.c @@ -37,12 +37,13 @@ #include #include "abend.h" +#include "debugflag.h" #include "xmalloc.h" /*****************************************************************************/ -/* code */ +/* code */ /*****************************************************************************/ @@ -81,10 +82,10 @@ void* xrealloc (void* P, size_t Size) -void xfree (const void* Block) +void xfree (void* Block) /* Free the block, do some debugging */ { - free ((void*) Block); + free (Block); } diff --git a/src/common/xmalloc.h b/src/common/xmalloc.h index 4a9597fad..e041b9b1f 100644 --- a/src/common/xmalloc.h +++ b/src/common/xmalloc.h @@ -54,7 +54,7 @@ void* xmalloc (size_t Size); void* xrealloc (void* P, size_t Size); /* Reallocate a memory block, check for out of memory */ -void xfree (const void* Block); +void xfree (void* Block); /* Free the block, do some debugging */ char* xstrdup (const char* S); diff --git a/src/ld65/exports.c b/src/ld65/exports.c index 7761a078a..1978f22a6 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -114,7 +114,7 @@ void InsertImport (Import* I) unsigned HashVal; /* As long as the import is not inserted, V.Name is valid */ - const char* Name = I->V.Name; + char* Name = I->V.Name; /* Create a hash value for the given name */ HashVal = HashStr (Name) % HASHTAB_SIZE; diff --git a/src/ld65/exports.h b/src/ld65/exports.h index cad0313c0..4a2c8751d 100644 --- a/src/ld65/exports.h +++ b/src/ld65/exports.h @@ -65,7 +65,7 @@ struct Import { FilePos Pos; /* File position of reference */ union { struct Export* Exp; /* Matching export for this import */ - const char* Name; /* Name if not in table */ + char* Name; /* Name if not in table */ } V; unsigned char Type; /* Type of import */ }; -- 2.39.5