diff --git a/src/cl65/main.c b/src/cl65/main.c index 0298dd601..cb161929c 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -1034,8 +1034,7 @@ static void OptConfig (const char* Opt attribute ((unused)), const char* Arg) static void OptColor(const char* Opt, const char* Arg) /* Handle the --color option */ { - ColorMode Mode = CP_Parse (Arg); - if (Mode == CM_INVALID) { + if (CP_Parse (Arg) == CM_INVALID) { Error ("Invalid argument to %s: %s", Opt, Arg); } else { CmdAddArg2 (&CA65, "--color", Arg); diff --git a/src/ld65/asserts.c b/src/ld65/asserts.c index bd51c66d0..7aa5a6aef 100644 --- a/src/ld65/asserts.c +++ b/src/ld65/asserts.c @@ -144,12 +144,12 @@ void CheckAssertions (void) case ASSERT_ACT_WARN: case ASSERT_ACT_LDWARN: - CfgWarning (Pos, "Assertion failed: %s", Message); + PWarning (Pos, "Assertion failed: %s", Message); break; case ASSERT_ACT_ERROR: case ASSERT_ACT_LDERROR: - CfgError (Pos, "Assertion failed: %s", Message); + PError (Pos, "Assertion failed: %s", Message); break; default: diff --git a/src/ld65/cfgexpr.c b/src/ld65/cfgexpr.c index 38246e1fa..f4a0f8462 100644 --- a/src/ld65/cfgexpr.c +++ b/src/ld65/cfgexpr.c @@ -109,7 +109,7 @@ static ExprNode* Factor (void) break; default: - CfgError (&CfgErrorPos, "Invalid expression: %d", CfgTok); + PError (&CfgErrorPos, "Invalid expression: %d", CfgTok); break; } @@ -213,7 +213,7 @@ long CfgConstExpr (void) /* Check that it's const */ if (!IsConstExpr (Expr)) { - CfgError (&CfgErrorPos, "Constant expression expected"); + PError (&CfgErrorPos, "Constant expression expected"); } /* Get the value */ @@ -238,7 +238,7 @@ long CfgCheckedConstExpr (long Min, long Max) /* Check the range */ if (Val < Min || Val > Max) { - CfgError (&CfgErrorPos, "Range error"); + PError (&CfgErrorPos, "Range error"); } /* Return the value */ diff --git a/src/ld65/config.c b/src/ld65/config.c index 4d3fc035f..f178fe550 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -228,7 +228,7 @@ static MemoryArea* CfgGetMemory (unsigned Name) { MemoryArea* M = CfgFindMemory (Name); if (M == 0) { - CfgError (&CfgErrorPos, "Invalid memory area `%s'", GetString (Name)); + PError (&CfgErrorPos, "Invalid memory area `%s'", GetString (Name)); } return M; } @@ -321,7 +321,7 @@ static MemoryArea* CreateMemoryArea (const FilePos* Pos, unsigned Name) /* Check for duplicate names */ MemoryArea* M = CfgFindMemory (Name); if (M) { - CfgError (&CfgErrorPos, + PError (&CfgErrorPos, "Memory area `%s' defined twice", GetString (Name)); } @@ -345,7 +345,7 @@ static SegDesc* NewSegDesc (unsigned Name) /* Check for duplicate names */ SegDesc* S = CfgFindSegDesc (Name); if (S) { - CfgError (&CfgErrorPos, "Segment `%s' defined twice", GetString (Name)); + PError (&CfgErrorPos, "Segment `%s' defined twice", GetString (Name)); } /* Allocate memory */ @@ -391,7 +391,7 @@ static void FlagAttr (unsigned* Flags, unsigned Mask, const char* Name) */ { if (*Flags & Mask) { - CfgError (&CfgErrorPos, "Attribute `%s' is already defined", Name); + PError (&CfgErrorPos, "Attribute `%s' is already defined", Name); } *Flags |= Mask; } @@ -402,7 +402,7 @@ static void AttrCheck (unsigned Attr, unsigned Mask, const char* Name) /* Check that a mandatory attribute was given */ { if ((Attr & Mask) == 0) { - CfgError (&CfgErrorPos, "Mandatory attribute `%s' is missing", Name); + PError (&CfgErrorPos, "Mandatory attribute `%s' is missing", Name); } } @@ -554,7 +554,7 @@ static void ParseFiles (void) /* The MEMORY section must preceed the FILES section */ if ((SectionsEncountered & SE_MEMORY) == 0) { - CfgError (&CfgErrorPos, "MEMORY must precede FILES"); + PError (&CfgErrorPos, "MEMORY must precede FILES"); } /* Parse all files */ @@ -568,7 +568,7 @@ static void ParseFiles (void) /* Search for the file, it must exist */ F = FindFile (GetStrBufId (&CfgSVal)); if (F == 0) { - CfgError (&CfgErrorPos, + PError (&CfgErrorPos, "File `%s' not found in MEMORY section", SB_GetConstBuf (&CfgSVal)); } @@ -595,7 +595,7 @@ static void ParseFiles (void) case CFGTOK_FORMAT: if (F->Format != BINFMT_DEFAULT) { /* We've set the format already! */ - CfgError (&CfgErrorPos, + PError (&CfgErrorPos, "Cannot set a file format twice"); } /* Read the format token */ @@ -667,7 +667,7 @@ static void ParseSegments (void) /* The MEMORY section must preceed the SEGMENTS section */ if ((SectionsEncountered & SE_MEMORY) == 0) { - CfgError (&CfgErrorPos, "MEMORY must precede SEGMENTS"); + PError (&CfgErrorPos, "MEMORY must precede SEGMENTS"); } while (CfgTok == CFGTOK_IDENT) { @@ -793,7 +793,7 @@ static void ParseSegments (void) ** separate run and load memory areas. */ if ((S->Flags & SF_ALIGN_LOAD) != 0 && (S->Load == S->Run)) { - CfgWarning (&CfgErrorPos, + PWarning (&CfgErrorPos, "ALIGN_LOAD attribute specified, but no separate " "LOAD and RUN memory areas assigned"); /* Remove the flag */ @@ -804,7 +804,7 @@ static void ParseSegments (void) ** load and run memory areas, because it's is never written to disk. */ if ((S->Flags & SF_BSS) != 0 && (S->Load != S->Run)) { - CfgWarning (&CfgErrorPos, + PWarning (&CfgErrorPos, "Segment with type `bss' has both LOAD and RUN " "memory areas assigned"); } @@ -812,7 +812,7 @@ static void ParseSegments (void) /* Don't allow read/write data to be put into a readonly area */ if ((S->Flags & SF_RO) == 0) { if (S->Run->Flags & MF_RO) { - CfgError (&CfgErrorPos, + PError (&CfgErrorPos, "Cannot put r/w segment `%s' in r/o memory area `%s'", GetString (S->Name), GetString (S->Run->Name)); } @@ -823,7 +823,7 @@ static void ParseSegments (void) ((S->Flags & SF_OFFSET) != 0) + ((S->Flags & SF_START) != 0); if (Count > 1) { - CfgError (&CfgErrorPos, + PError (&CfgErrorPos, "Only one of ALIGN, START, OFFSET may be used"); } @@ -936,7 +936,7 @@ static void ParseO65 (void) break; default: - CfgError (&CfgErrorPos, "Unexpected type token"); + PError (&CfgErrorPos, "Unexpected type token"); } /* Eat the attribute token */ CfgNextTok (); @@ -958,7 +958,7 @@ static void ParseO65 (void) case CFGTOK_OSA65: OS = O65OS_OSA65; break; case CFGTOK_CC65: OS = O65OS_CC65; break; case CFGTOK_OPENCBM: OS = O65OS_OPENCBM; break; - default: CfgError (&CfgErrorPos, "Unexpected OS token"); + default: PError (&CfgErrorPos, "Unexpected OS token"); } } CfgNextTok (); @@ -993,12 +993,12 @@ static void ParseO65 (void) /* Check for attributes that may not be combined */ if (OS == O65OS_CC65) { if ((AttrFlags & (atImport | atExport)) != 0 && ModuleId < 0x8000) { - CfgError (&CfgErrorPos, + PError (&CfgErrorPos, "OS type CC65 may not have imports or exports for ids < $8000"); } } else { if (AttrFlags & atID) { - CfgError (&CfgErrorPos, + PError (&CfgErrorPos, "Operating system does not support the ID attribute"); } } @@ -1071,7 +1071,7 @@ static void ParseXex (void) CfgNextTok (); /* Add to XEX */ if (XexAddInitAd (XexFmtDesc, InitMem, InitAd)) - CfgError (&CfgErrorPos, "INITAD already given for memory area"); + PError (&CfgErrorPos, "INITAD already given for memory area"); break; default: @@ -1290,7 +1290,7 @@ static void ParseConDes (void) /* Check if the condes has already attributes defined */ if (ConDesHasSegName(Type) || ConDesHasLabel(Type)) { - CfgError (&CfgErrorPos, + PError (&CfgErrorPos, "CONDES attributes for type %d are already defined", Type); } @@ -1559,7 +1559,7 @@ static void ParseSymbols (void) case CfgSymImport: /* An import must not have a value */ if (AttrFlags & atValue) { - CfgError (&CfgErrorPos, "Imports must not have a value"); + PError (&CfgErrorPos, "Imports must not have a value"); } /* Generate the import */ Imp = InsertImport (GenImport (Name, AddrSize)); @@ -1703,7 +1703,7 @@ static void ProcessSegments (void) ** in the segment. */ if ((S->Flags & SF_BSS) != 0 && S->Seg != 0 && !IsBSSType (S->Seg)) { - CfgWarning (GetSourcePos (S->LI), + PWarning (GetSourcePos (S->LI), "Segment `%s' with type `bss' contains initialized data", GetString (S->Name)); } @@ -1732,7 +1732,7 @@ static void ProcessSegments (void) /* Print a warning if the segment is not optional */ if ((S->Flags & SF_OPTIONAL) == 0) { - CfgWarning (&CfgErrorPos, + PWarning (&CfgErrorPos, "Segment `%s' does not exist", GetString (S->Name)); } @@ -1764,7 +1764,7 @@ static void ProcessSymbols (void) case CfgSymO65Export: /* Check if the export symbol is also defined as an import. */ if (O65GetImport (O65FmtDesc, Sym->Name) != 0) { - CfgError ( + PError ( GetSourcePos (Sym->LI), "Exported o65 symbol `%s' cannot also be an o65 import", GetString (Sym->Name) @@ -1776,7 +1776,7 @@ static void ProcessSymbols (void) ** error message when checking it here. */ if (O65GetExport (O65FmtDesc, Sym->Name) != 0) { - CfgError ( + PError ( GetSourcePos (Sym->LI), "Duplicate exported o65 symbol: `%s'", GetString (Sym->Name) @@ -1790,7 +1790,7 @@ static void ProcessSymbols (void) case CfgSymO65Import: /* Check if the import symbol is also defined as an export. */ if (O65GetExport (O65FmtDesc, Sym->Name) != 0) { - CfgError ( + PError ( GetSourcePos (Sym->LI), "Imported o65 symbol `%s' cannot also be an o65 export", GetString (Sym->Name) @@ -1802,7 +1802,7 @@ static void ProcessSymbols (void) ** error message when checking it here. */ if (O65GetImport (O65FmtDesc, Sym->Name) != 0) { - CfgError ( + PError ( GetSourcePos (Sym->LI), "Duplicate imported o65 symbol: `%s'", GetString (Sym->Name) @@ -1913,7 +1913,7 @@ unsigned CfgProcess (void) ** and mark the memory area as placed. */ if (!IsConstExpr (M->StartExpr)) { - CfgError (GetSourcePos (M->LI), + PError (GetSourcePos (M->LI), "Start address of memory area `%s' is not constant", GetString (M->Name)); } @@ -1938,13 +1938,13 @@ unsigned CfgProcess (void) /* Resolve the size expression */ if (!IsConstExpr (M->SizeExpr)) { - CfgError (GetSourcePos (M->LI), + PError (GetSourcePos (M->LI), "Size of memory area `%s' is not constant", GetString (M->Name)); } M->Size = GetExprVal (M->SizeExpr); if (M->Size >= 0x80000000) { - CfgError (GetSourcePos (M->LI), + PError (GetSourcePos (M->LI), "Size of memory area `%s' is negative: %ld", GetString (M->Name), (long)M->Size); } @@ -1968,14 +1968,14 @@ unsigned CfgProcess (void) if (S->Flags & (SF_OFFSET | SF_START)) { ++Overwrites; } else { - CfgError (GetSourcePos (M->LI), + PError (GetSourcePos (M->LI), "Segment `%s' of type `overwrite' requires either" " `START' or `OFFSET' attribute to be specified", GetString (S->Name)); } } else { if (Overwrites > 0) { - CfgError (GetSourcePos (M->LI), + PError (GetSourcePos (M->LI), "Segment `%s' is preceded by at least one segment" " of type `overwrite'", GetString (S->Name)); @@ -2002,7 +2002,7 @@ unsigned CfgProcess (void) /* Segment requires another alignment than configured ** in the linker. */ - CfgWarning (GetSourcePos (S->LI), + PWarning (GetSourcePos (S->LI), "Segment `%s' isn't aligned properly; the" " resulting executable might not be functional.", GetString (S->Name)); @@ -2017,7 +2017,7 @@ unsigned CfgProcess (void) ** that is somewhat suspicious. */ if (M->FillLevel == 0 && NewAddr > Addr) { - CfgWarning (GetSourcePos (S->LI), + PWarning (GetSourcePos (S->LI), "The first segment in memory area `%s' " "needs fill bytes for alignment.", GetString (M->Name)); @@ -2038,7 +2038,7 @@ unsigned CfgProcess (void) if (S->Flags & SF_OVERWRITE) { if (NewAddr < M->Start) { - CfgError (GetSourcePos (S->LI), + PError (GetSourcePos (S->LI), "Segment `%s' begins before memory area `%s'", GetString (S->Name), GetString (M->Name)); } else { @@ -2049,12 +2049,12 @@ unsigned CfgProcess (void) /* Offset already too large */ ++Overflows; if (S->Flags & SF_OFFSET) { - CfgWarning (GetSourcePos (S->LI), + PWarning (GetSourcePos (S->LI), "Segment `%s' offset is too small in `%s' by %lu byte%s", GetString (S->Name), GetString (M->Name), Addr - NewAddr, (Addr - NewAddr == 1) ? "" : "s"); } else { - CfgWarning (GetSourcePos (S->LI), + PWarning (GetSourcePos (S->LI), "Segment `%s' start address is too low in `%s' by %lu byte%s", GetString (S->Name), GetString (M->Name), Addr - NewAddr, (Addr - NewAddr == 1) ? "" : "s"); @@ -2101,7 +2101,7 @@ unsigned CfgProcess (void) if (FillLevel > M->Size && (M->Flags & MF_OVERFLOW) == 0) { ++Overflows; M->Flags |= MF_OVERFLOW; - CfgWarning (GetSourcePos (M->LI), + PWarning (GetSourcePos (M->LI), "Segment `%s' overflows memory area `%s' by %lu byte%s", GetString (S->Name), GetString (M->Name), FillLevel - M->Size, (FillLevel - M->Size == 1) ? "" : "s"); diff --git a/src/ld65/error.c b/src/ld65/error.c index 08f2a5dbe..8f3f5dfc7 100644 --- a/src/ld65/error.c +++ b/src/ld65/error.c @@ -348,7 +348,7 @@ void AddCfgNote (const FilePos* Pos, const char* Format, ...) -void CfgWarning (const FilePos* Pos, const char* Format, ...) +void PWarning (const FilePos* Pos, const char* Format, ...) /* Print a warning message adding file name and line number of a given file */ { /* Output the message */ @@ -366,7 +366,7 @@ void CfgWarning (const FilePos* Pos, const char* Format, ...) -void CfgError (const FilePos* Pos, const char* Format, ...) +void PError (const FilePos* Pos, const char* Format, ...) /* Print an error message adding file name and line number of a given file */ { /* Output the message */ diff --git a/src/ld65/error.h b/src/ld65/error.h index afbeba59b..c688302e8 100644 --- a/src/ld65/error.h +++ b/src/ld65/error.h @@ -81,10 +81,10 @@ void AddCfgNote (const FilePos* Pos, const char* Format, ...) attribute((format( ** See comment for AddNote() above. */ -void CfgWarning (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3))); +void PWarning (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3))); /* Print a warning message adding file name and line number of the config file */ -void CfgError (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3))); +void PError (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3))); /* Print an error message adding file name and line number of a given file */ diff --git a/src/ld65/exports.c b/src/ld65/exports.c index 5c5c7f29d..e3ad4f986 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -786,7 +786,7 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data) } else { for (J = 0; J < Count; ++J) { const LineInfo* LI = CollConstAt (&Imp->RefLines, J); - CfgWarning (GetSourcePos (LI), + PWarning (GetSourcePos (LI), "Unresolved external `%s'", Name); } diff --git a/src/ld65/scanner.c b/src/ld65/scanner.c index 4bbdd5d8c..5b7f46bd0 100644 --- a/src/ld65/scanner.c +++ b/src/ld65/scanner.c @@ -127,7 +127,7 @@ static void StrVal (void) case EOF: case '\n': - CfgError (&CfgErrorPos, "Unterminated string"); + PError (&CfgErrorPos, "Unterminated string"); break; case '%': @@ -137,7 +137,7 @@ static void StrVal (void) case EOF: case '\n': case '\"': - CfgError (&CfgErrorPos, "Unterminated `%%' escape sequence"); + PError (&CfgErrorPos, "Unterminated `%%' escape sequence"); break; case '%': @@ -155,7 +155,7 @@ static void StrVal (void) break; default: - CfgWarning (&CfgErrorPos, + PWarning (&CfgErrorPos, "Unknown escape sequence `%%%c'", C); SB_AppendChar (&CfgSVal, '%'); SB_AppendChar (&CfgSVal, C); @@ -212,7 +212,7 @@ Again: if (C == '$') { NextChar (); if (!isxdigit (C)) { - CfgError (&CfgErrorPos, "Hex digit expected"); + PError (&CfgErrorPos, "Hex digit expected"); } CfgIVal = 0; while (isxdigit (C)) { @@ -340,7 +340,7 @@ Again: break; default: - CfgError (&CfgErrorPos, "Invalid format specification"); + PError (&CfgErrorPos, "Invalid format specification"); } break; @@ -349,7 +349,7 @@ Again: break; default: - CfgError (&CfgErrorPos, "Invalid character `%c'", C); + PError (&CfgErrorPos, "Invalid character `%c'", C); } } @@ -360,7 +360,7 @@ void CfgConsume (cfgtok_t T, const char* Msg) /* Skip a token, print an error message if not found */ { if (CfgTok != T) { - CfgError (&CfgErrorPos, "%s", Msg); + PError (&CfgErrorPos, "%s", Msg); } CfgNextTok (); } @@ -407,7 +407,7 @@ void CfgAssureInt (void) /* Make sure the next token is an integer */ { if (CfgTok != CFGTOK_INTCON) { - CfgError (&CfgErrorPos, "Integer constant expected"); + PError (&CfgErrorPos, "Integer constant expected"); } } @@ -417,7 +417,7 @@ void CfgAssureStr (void) /* Make sure the next token is a string constant */ { if (CfgTok != CFGTOK_STRCON) { - CfgError (&CfgErrorPos, "String constant expected"); + PError (&CfgErrorPos, "String constant expected"); } } @@ -427,7 +427,7 @@ void CfgAssureIdent (void) /* Make sure the next token is an identifier */ { if (CfgTok != CFGTOK_IDENT) { - CfgError (&CfgErrorPos, "Identifier expected"); + PError (&CfgErrorPos, "Identifier expected"); } } @@ -437,7 +437,7 @@ void CfgRangeCheck (unsigned long Lo, unsigned long Hi) /* Check the range of CfgIVal */ { if (CfgIVal < Lo || CfgIVal > Hi) { - CfgError (&CfgErrorPos, "Range error"); + PError (&CfgErrorPos, "Range error"); } } @@ -462,12 +462,12 @@ void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name) } /* Not found */ - CfgError (&CfgErrorPos, "%s expected, got `%s'", Name, SB_GetConstBuf(&CfgSVal)); + PError (&CfgErrorPos, "%s expected, got `%s'", Name, SB_GetConstBuf(&CfgSVal)); return; } /* No identifier */ - CfgError (&CfgErrorPos, "%s expected", Name); + PError (&CfgErrorPos, "%s expected", Name); } @@ -488,7 +488,7 @@ void CfgBoolToken (void) } else { /* We expected an integer here */ if (CfgTok != CFGTOK_INTCON) { - CfgError (&CfgErrorPos, "Boolean value expected"); + PError (&CfgErrorPos, "Boolean value expected"); } CfgTok = (CfgIVal == 0)? CFGTOK_FALSE : CFGTOK_TRUE; }