#include "cpu.h"
#include "print.h"
#include "xmalloc.h"
-#include "xsprintf.h"
/* cc65 */
#include "asmlabel.h"
#include "debugflag.h"
#include "global.h"
#include "hashstr.h"
+#include "strbuf.h"
#include "strutil.h"
#include "xmalloc.h"
-#include "xsprintf.h"
/* cc65 */
#include "asmlabel.h"
char Token[IDENTSIZE+10];
/* Format the line */
- char Buf [256];
- xvsprintf (Buf, sizeof (Buf), Format, ap);
+ StrBuf Buf = STATIC_STRBUF_INITIALIZER;
+ SB_VPrintf (&Buf, Format, ap);
/* Skip whitespace */
- L = SkipSpace (Buf);
+ L = SkipSpace (SB_GetConstBuf (&Buf));
/* Check which type of instruction we have */
E = 0; /* Assume no insn created */
if (E) {
CS_AddEntry (S, E);
}
+
+ /* Cleanup the string buffer */
+ DoneStrBuf (&Buf);
}
void Compile (const char* FileName)
/* Top level compile routine. Will setup things and call the parser. */
{
- char Buf[20];
- char DateStr[20];
- char TimeStr[20];
+ char DateStr[32];
+ char TimeStr[32];
time_t Time;
struct tm* TM;
*/
if (IS_Get (&Optimize)) {
long CodeSize = IS_Get (&CodeSizeFactor);
- DefineNumericMacro ("__OPT__", 1);
+ DefineNumericMacro ("__OPT__", 1);
if (CodeSize > 100) {
- DefineNumericMacro ("__OPT_i__", CodeSize);
- }
- if (IS_Get (&EnableRegVars)) {
- DefineNumericMacro ("__OPT_r__", 1);
- }
+ DefineNumericMacro ("__OPT_i__", CodeSize);
+ }
+ if (IS_Get (&EnableRegVars)) {
+ DefineNumericMacro ("__OPT_r__", 1);
+ }
if (IS_Get (&InlineStdFuncs)) {
- DefineNumericMacro ("__OPT_s__", 1);
- }
+ DefineNumericMacro ("__OPT_s__", 1);
+ }
}
/* __TIME__ and __DATE__ macros */
Time = time (0);
TM = localtime (&Time);
- strftime (Buf, sizeof (Buf), "%e %Y", TM);
- xsprintf (DateStr, sizeof (DateStr), "\"%s %s\"", MonthNames[TM->tm_mon], Buf);
+ xsprintf (DateStr, sizeof (DateStr), "\"%s %2d %d\"",
+ MonthNames[TM->tm_mon], TM->tm_mday, TM->tm_year + 1900);
strftime (TimeStr, sizeof (TimeStr), "\"%H:%M:%S\"", TM);
DefineTextMacro ("__DATE__", DateStr);
DefineTextMacro ("__TIME__", TimeStr);
/* common */
#include "check.h"
-#include "xsprintf.h"
+#include "strbuf.h"
/* cc65 */
#include "asmlabel.h"
* call to the function.
*/
{
- static char Buf[256];
+ static StrBuf Buf = STATIC_STRBUF_INITIALIZER;
/* Expr may have it's own offset, adjust Offs accordingly */
Offs += Expr->IVal;
case E_LOC_ABS:
/* Absolute: numeric address or const */
- xsprintf (Buf, sizeof (Buf), "$%04X", (int)(Offs & 0xFFFF));
+ SB_Printf (&Buf, "$%04X", (int)(Offs & 0xFFFF));
break;
case E_LOC_GLOBAL:
case E_LOC_STATIC:
/* Global or static variable */
if (Offs) {
- xsprintf (Buf, sizeof (Buf), "%s%+ld",
- SymGetAsmName (Expr->Sym), Offs);
+ SB_Printf (&Buf, "%s%+ld", SymGetAsmName (Expr->Sym), Offs);
} else {
- xsprintf (Buf, sizeof (Buf), "%s",
- SymGetAsmName (Expr->Sym));
+ SB_Printf (&Buf, "%s", SymGetAsmName (Expr->Sym));
}
break;
case E_LOC_REGISTER:
/* Register variable */
- xsprintf (Buf, sizeof (Buf), "regbank+%u",
- (unsigned)((Offs + Expr->Name) & 0xFFFFU));
+ SB_Printf (&Buf, "regbank+%u", (unsigned)((Offs + Expr->Name) & 0xFFFFU));
break;
case E_LOC_LITERAL:
/* Literal in the literal pool */
if (Offs) {
- xsprintf (Buf, sizeof (Buf), "%s%+ld",
- LocalLabelName (Expr->Name), Offs);
+ SB_Printf (&Buf, "%s%+ld", LocalLabelName (Expr->Name), Offs);
} else {
- xsprintf (Buf, sizeof (Buf), "%s",
- LocalLabelName (Expr->Name));
+ SB_Printf (&Buf, "%s", LocalLabelName (Expr->Name));
}
break;
}
/* Return a pointer to the static buffer */
- return Buf;
+ return SB_GetConstBuf (&Buf);
}