From 0fcbb73439bbefad8129ecd25c6d2eca6963727a Mon Sep 17 00:00:00 2001 From: cuz Date: Fri, 12 Oct 2001 18:21:56 +0000 Subject: [PATCH] Use a function pointer instead of a flag git-svn-id: svn://svn.cc65.org/cc65/trunk@1046 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/codeseg.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/cc65/codeseg.c b/src/cc65/codeseg.c index a846296a5..0ba5e0466 100644 --- a/src/cc65/codeseg.c +++ b/src/cc65/codeseg.c @@ -160,7 +160,8 @@ static void CS_RemoveLabelFromHash (CodeSeg* S, CodeLabel* L) -static CodeLabel* CS_AddLabelInternal (CodeSeg* S, const char* Name, int UserCode) +static CodeLabel* CS_AddLabelInternal (CodeSeg* S, const char* Name, + void (*ErrorFunc) (const char*, ...)) /* Add a code label for the next instruction to follow */ { /* Calculate the hash from the name */ @@ -173,11 +174,7 @@ static CodeLabel* CS_AddLabelInternal (CodeSeg* S, const char* Name, int UserCod if (L) { /* We found it - be sure it does not already have an owner */ if (L->Owner) { - if (UserCode) { - Error ("ASM label `%s' is already defined", Name); - } else { - Internal ("CS_AddLabelInternal: Label `%s' already defined", Name); - } + ErrorFunc ("ASM label `%s' is already defined", Name); } } else { /* Not found - create a new one */ @@ -186,11 +183,7 @@ static CodeLabel* CS_AddLabelInternal (CodeSeg* S, const char* Name, int UserCod /* Safety. This call is quite costly, but safety is better */ if (CollIndex (&S->Labels, L) >= 0) { - if (UserCode) { - Error ("ASM label `%s' is already defined", Name); - } else { - Internal ("CS_AddLabelInternal: Label `%s' already defined", Name); - } + ErrorFunc ("ASM label `%s' is already defined", Name); } /* We do now have a valid label. Remember it for later */ @@ -281,7 +274,7 @@ static CodeEntry* ParseInsn (CodeSeg* S, LineInfo* LI, const char* L) L = SkipSpace (L+1); /* Add the label */ - CS_AddLabelInternal (S, Mnemo, 1); + CS_AddLabelInternal (S, Mnemo, Error); /* If we have reached end of line, bail out, otherwise a mnemonic * may follow. @@ -735,7 +728,7 @@ unsigned CS_GetEntryIndex (CodeSeg* S, struct CodeEntry* E) CodeLabel* CS_AddLabel (CodeSeg* S, const char* Name) /* Add a code label for the next instruction to follow */ { - return CS_AddLabelInternal (S, Name, 0); + return CS_AddLabelInternal (S, Name, Internal); } -- 2.39.2