/* */
/* */
/* */
-/* (C) 2005-2008, Ullrich von Bassewitz */
+/* (C) 2005-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
case CFGTOK_IDENT:
/* An identifier - search an export with the given name */
- Sym = FindExport (GetStringId (CfgSVal));
+ Sym = FindExport (GetStrBufId (&CfgSVal));
if (Sym == 0) {
- CfgError ("Unknown symbol in expression: `%s'", CfgSVal);
+ CfgError ("Unknown symbol in expression: `%s'",
+ SB_GetConstBuf (&CfgSVal));
}
/* We can only handle constants */
if (!IsConstExport (Sym)) {
- CfgError ("Value for symbol `%s' is not constant", CfgSVal);
+ CfgError ("Value for symbol `%s' is not constant",
+ SB_GetConstBuf (&CfgSVal));
}
/* Use the symbol value */
case CFGTOK_STRCON:
/* A string constant */
- SB_CopyStr (&E->SVal, CfgSVal);
+ SB_Copy (&E->SVal, &CfgSVal);
E->Type = ceString;
CfgNextTok ();
break;
/* */
/* */
/* */
-/* (C) 1998-2008 Ullrich von Bassewitz */
+/* (C) 1998-2010 Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
static Memory* CfgGetMemory (unsigned Name)
/* Find the memory are with the given name. Print an error on an invalid name */
{
- Memory* M = CfgFindMemory (Name);
+ Memory* M = CfgFindMemory (Name);
if (M == 0) {
CfgError ("Invalid memory area `%s'", GetString (Name));
}
while (CfgTok == CFGTOK_IDENT) {
/* Create a new entry on the heap */
- Memory* M = NewMemory (GetStringId (CfgSVal));
+ Memory* M = NewMemory (GetStrBufId (&CfgSVal));
/* Skip the name and the following colon */
CfgNextTok ();
FlagAttr (&M->Attr, MA_FILE, "FILE");
CfgAssureStr ();
/* Get the file entry and insert the memory area */
- FileInsert (GetFile (GetStringId (CfgSVal)), M);
+ FileInsert (GetFile (GetStrBufId (&CfgSVal)), M);
CfgNextTok ();
break;
CfgAssureStr ();
/* Search for the file, it must exist */
- F = FindFile (GetStringId (CfgSVal));
+ F = FindFile (GetStrBufId (&CfgSVal));
if (F == 0) {
- CfgError ("File `%s' not found in MEMORY section", CfgSVal);
+ CfgError ("File `%s' not found in MEMORY section",
+ SB_GetConstBuf (&CfgSVal));
}
/* Skip the token and the following colon */
SegDesc* S;
/* Create a new entry on the heap */
- S = NewSegDesc (GetStringId (CfgSVal));
+ S = NewSegDesc (GetStrBufId (&CfgSVal));
/* Skip the name and the following colon */
CfgNextTok ();
case CFGTOK_LOAD:
FlagAttr (&S->Attr, SA_LOAD, "LOAD");
- S->Load = CfgGetMemory (GetStringId (CfgSVal));
+ S->Load = CfgGetMemory (GetStrBufId (&CfgSVal));
CfgNextTok ();
break;
case CFGTOK_RUN:
FlagAttr (&S->Attr, SA_RUN, "RUN");
- S->Run = CfgGetMemory (GetStringId (CfgSVal));
+ S->Run = CfgGetMemory (GetStrBufId (&CfgSVal));
CfgNextTok ();
break;
/* We expect an identifier */
CfgAssureIdent ();
/* Convert the string into a string index */
- CfgSValId = GetStringId (CfgSVal);
+ CfgSValId = GetStrBufId (&CfgSVal);
/* Check if the export symbol is also defined as an import. */
if (O65GetImport (O65FmtDesc, CfgSValId) != 0) {
- CfgError ("Exported symbol `%s' cannot be an import", CfgSVal);
+ CfgError ("Exported symbol `%s' cannot be an import",
+ SB_GetConstBuf (&CfgSVal));
}
/* Check if we have this symbol defined already. The entry
* routine will check this also, but we get a more verbose
* error message when checking it here.
*/
if (O65GetExport (O65FmtDesc, CfgSValId) != 0) {
- CfgError ("Duplicate exported symbol: `%s'", CfgSVal);
+ CfgError ("Duplicate exported symbol: `%s'",
+ SB_GetConstBuf (&CfgSVal));
}
/* Insert the symbol into the table */
O65SetExport (O65FmtDesc, CfgSValId);
/* We expect an identifier */
CfgAssureIdent ();
/* Convert the string into a string index */
- CfgSValId = GetStringId (CfgSVal);
+ CfgSValId = GetStrBufId (&CfgSVal);
/* Check if the imported symbol is also defined as an export. */
if (O65GetExport (O65FmtDesc, CfgSValId) != 0) {
- CfgError ("Imported symbol `%s' cannot be an export", CfgSVal);
+ CfgError ("Imported symbol `%s' cannot be an export",
+ SB_GetConstBuf (&CfgSVal));
}
/* Check if we have this symbol defined already. The entry
* routine will check this also, but we get a more verbose
* error message when checking it here.
*/
if (O65GetImport (O65FmtDesc, CfgSValId) != 0) {
- CfgError ("Duplicate imported symbol: `%s'", CfgSVal);
+ CfgError ("Duplicate imported symbol: `%s'",
+ SB_GetConstBuf (&CfgSVal));
}
/* Insert the symbol into the table */
O65SetImport (O65FmtDesc, CfgSValId);
/* We expect an identifier */
CfgAssureIdent ();
/* Remember the value for later */
- SegName = GetStringId (CfgSVal);
+ SegName = GetStrBufId (&CfgSVal);
break;
case CFGTOK_LABEL:
/* We expect an identifier */
CfgAssureIdent ();
/* Remember the value for later */
- Label = GetStringId (CfgSVal);
+ Label = GetStrBufId (&CfgSVal);
break;
case CFGTOK_COUNT:
/* We expect an identifier */
CfgAssureIdent ();
/* Remember the value for later */
- Count = GetStringId (CfgSVal);
- break;
+ Count = GetStrBufId (&CfgSVal);
+ break;
case CFGTOK_TYPE:
/* Don't allow this twice */
Export* E;
/* Remember the name */
- unsigned Name = GetStringId (CfgSVal);
+ unsigned Name = GetStrBufId (&CfgSVal);
CfgNextTok ();
/* Support both, old and new syntax here. New syntax is a colon
/* Current token and attributes */
cfgtok_t CfgTok;
-char CfgSVal [CFG_MAX_IDENT_LEN+1];
+StrBuf CfgSVal = STATIC_STRBUF_INITIALIZER;
unsigned long CfgIVal;
/* Error location */
void CfgNextTok (void)
/* Read the next token from the input stream */
{
- unsigned I;
-
-
Again:
/* Skip whitespace */
while (isspace (C)) {
if (C == '_' || IsAlpha (C)) {
/* Read the identifier */
- I = 0;
+ SB_Clear (&CfgSVal);
while (C == '_' || IsAlNum (C)) {
- if (I < CFG_MAX_IDENT_LEN) {
- CfgSVal [I++] = C;
- }
+ SB_AppendChar (&CfgSVal, C);
NextChar ();
}
- CfgSVal [I] = '\0';
+ SB_Terminate (&CfgSVal);
CfgTok = CFGTOK_IDENT;
return;
}
case '\"':
NextChar ();
- I = 0;
+ SB_Clear (&CfgSVal);
while (C != '\"') {
if (C == EOF || C == '\n') {
CfgError ("Unterminated string");
}
- if (I < CFG_MAX_IDENT_LEN) {
- CfgSVal [I++] = C;
- }
+ SB_AppendChar (&CfgSVal, C);
NextChar ();
}
NextChar ();
- CfgSVal [I] = '\0';
+ SB_Terminate (&CfgSVal);
CfgTok = CFGTOK_STRCON;
break;
case 'O':
NextChar ();
if (OutputName) {
- strncpy (CfgSVal, OutputName, CFG_MAX_IDENT_LEN);
- CfgSVal [CFG_MAX_IDENT_LEN] = '\0';
+ SB_CopyStr (&CfgSVal, OutputName);
} else {
- CfgSVal [0] = '\0';
+ SB_Clear (&CfgSVal);
}
+ SB_Terminate (&CfgSVal);
CfgTok = CFGTOK_STRCON;
break;
if (CfgTok == CFGTOK_IDENT) {
/* Make it upper case */
- I = 0;
- while (CfgSVal [I]) {
- CfgSVal [I] = toupper (CfgSVal [I]);
- ++I;
- }
+ SB_ToUpper (&CfgSVal);
/* Linear search */
for (I = 0; I < Size; ++I) {
- if (strcmp (CfgSVal, Table [I].Ident) == 0) {
- CfgTok = Table [I].Tok;
+ if (SB_CompareStr (&CfgSVal, Table[I].Ident) == 0) {
+ CfgTok = Table[I].Tok;
return;
}
}