#include <ctype.h>
/* common */
+#include "chartype.h"
#include "xsprintf.h"
/* ld65 */
/* Current token and attributes */
-unsigned CfgTok;
+cfgtok_t CfgTok;
char CfgSVal [CFG_MAX_IDENT_LEN+1];
unsigned long CfgIVal;
xvsprintf (Buf, sizeof (Buf), Format, ap);
va_end (ap);
- Warning ("%s(%u): %s", CfgName, CfgErrorLine, Buf);
+ Warning ("%s(%u): %s", CfgGetName(), CfgErrorLine, Buf);
}
xvsprintf (Buf, sizeof (Buf), Format, ap);
va_end (ap);
- Error ("%s(%u): %s", CfgName, CfgErrorLine, Buf);
+ Error ("%s(%u): %s", CfgGetName(), CfgErrorLine, Buf);
}
/* Read from buffer */
C = (unsigned char)(*CfgBuf);
if (C == 0) {
- C = EOF;
+ C = EOF;
} else {
++CfgBuf;
}
CfgErrorCol = InputCol;
/* Identifier? */
- if (C == '_' || isalpha (C)) {
+ if (C == '_' || IsAlpha (C)) {
/* Read the identifier */
I = 0;
- while (C == '_' || isalnum (C)) {
+ while (C == '_' || IsAlNum (C)) {
if (I < CFG_MAX_IDENT_LEN) {
CfgSVal [I++] = C;
}
case ':':
NextChar ();
CfgTok = CFGTOK_COLON;
- break;
+ break;
case '\"':
NextChar ();
CfgSVal [0] = '\0';
}
CfgTok = CFGTOK_STRCON;
- break;
+ break;
case 'S':
NextChar ();
-void CfgConsume (unsigned T, const char* Msg)
+void CfgConsume (cfgtok_t T, const char* Msg)
/* Skip a token, print an error message if not found */
{
if (CfgTok != T) {
/* Linear search */
for (I = 0; I < Size; ++I) {
- if (strcmp (CfgSVal, Table [I].Ident) == 0) {
+ if (strcmp (CfgSVal, Table [I].Ident) == 0) {
CfgTok = Table [I].Tok;
return;
}
const char* CfgGetName (void)
/* Get the name of the config file */
{
- return CfgName? CfgName : "";
+ if (CfgName) {
+ return CfgName;
+ } else if (CfgBuf) {
+ return "[builtin config]";
+ } else {
+ return "";
+ }
}
+