Make much more usage of dynamic strings (StrBufs) instead of char* and

friends. Since names and other strings are now StrBufs in many places, code
for output had to be changed.
Added support for string literals to StrBuf.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3825 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2008-03-31 20:54:45 +00:00
parent 6a7e844500
commit 9174f65e54
78 changed files with 1228 additions and 864 deletions

View File

@@ -6,8 +6,8 @@
/* */
/* */
/* */
/* (C) 1998-2003 Ullrich von Bassewitz */
/* R<EFBFBD>merstrasse 52 */
/* (C) 1998-2008 Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
@@ -36,9 +36,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
/* common */
#include "cmdline.h"
#include "strbuf.h"
/* ld65 */
#include "error.h"
@@ -54,12 +55,17 @@
void Warning (const char* Format, ...)
/* Print a warning message */
{
StrBuf S = STATIC_STRBUF_INITIALIZER;
va_list ap;
va_start (ap, Format);
fprintf (stderr, "%s: Warning: ", ProgName);
vfprintf (stderr, Format, ap);
putc ('\n', stderr);
SB_VPrintf (&S, Format, ap);
va_end (ap);
SB_Terminate (&S);
fprintf (stderr, "%s: Warning: %s\n", ProgName, SB_GetConstBuf (&S));
SB_Done (&S);
}
@@ -67,12 +73,18 @@ void Warning (const char* Format, ...)
void Error (const char* Format, ...)
/* Print an error message and die */
{
StrBuf S = STATIC_STRBUF_INITIALIZER;
va_list ap;
va_start (ap, Format);
fprintf (stderr, "%s: Error: ", ProgName);
vfprintf (stderr, Format, ap);
putc ('\n', stderr);
SB_VPrintf (&S, Format, ap);
va_end (ap);
SB_Terminate (&S);
fprintf (stderr, "%s: Error: %s\n", ProgName, SB_GetConstBuf (&S));
SB_Done (&S);
exit (EXIT_FAILURE);
}
@@ -81,14 +93,20 @@ void Error (const char* Format, ...)
void Internal (const char* Format, ...)
/* Print an internal error message and die */
{
StrBuf S = STATIC_STRBUF_INITIALIZER;
va_list ap;
va_start (ap, Format);
fprintf (stderr, "%s: Internal error: ", ProgName);
vfprintf (stderr, Format, ap);
putc ('\n', stderr);
SB_VPrintf (&S, Format, ap);
va_end (ap);
SB_Terminate (&S);
fprintf (stderr, "%s: Internal Error: %s\n", ProgName, SB_GetConstBuf (&S));
SB_Done (&S);
exit (EXIT_FAILURE);
}