/*****************************************************************************/
/* */
-/* dataseg.c */
+/* dataseg.c */
/* */
-/* Data segment structure */
+/* Data segment structure */
/* */
/* */
/* */
-/* (C) 2001 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@cc65.org */
+/* (C) 2001-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include "xsprintf.h"
/* cc65 */
-#include "error.h"
#include "dataseg.h"
+#include "error.h"
+#include "output.h"
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
/* Create a new data segment, initialize and return it */
{
/* Allocate memory */
- DataSeg* S = xmalloc (sizeof (DataSeg));
+ DataSeg* S = xmalloc (sizeof (DataSeg));
/* Initialize the fields */
- S->SegName = xstrdup (Name);
- S->Func = Func;
+ S->SegName = xstrdup (Name);
+ S->Func = Func;
InitCollection (&S->Lines);
/* Return the new struct */
/* Append all lines from Source to Target */
unsigned Count = CollCount (&Source->Lines);
for (I = 0; I < Count; ++I) {
- CollAppend (&Target->Lines, xstrdup (CollConstAt (&Source->Lines, I)));
+ CollAppend (&Target->Lines, xstrdup (CollConstAt (&Source->Lines, I)));
}
}
-void DS_AddLine (DataSeg* S, const char* Format, va_list ap)
+void DS_AddVLine (DataSeg* S, const char* Format, va_list ap)
/* Add a line to the given data segment */
{
/* Format the line */
-void DS_Output (const DataSeg* S, FILE* F)
-/* Output the data segment data to a file */
+void DS_AddLine (DataSeg* S, const char* Format, ...)
+/* Add a line to the given data segment */
+{
+ va_list ap;
+ va_start (ap, Format);
+ DS_AddVLine (S, Format, ap);
+ va_end (ap);
+}
+
+
+
+void DS_Output (const DataSeg* S)
+/* Output the data segment data to the output file */
{
unsigned I;
/* If the segment is actually empty, bail out */
if (Count == 0) {
- return;
+ return;
}
/* Output the segment directive */
- fprintf (F, ".segment\t\"%s\"\n\n", S->SegName);
+ WriteOutput (".segment\t\"%s\"\n\n", S->SegName);
/* Output all entries */
for (I = 0; I < Count; ++I) {
- fprintf (F, "%s\n", (const char*) CollConstAt (&S->Lines, I));
+ WriteOutput ("%s\n", (const char*) CollConstAt (&S->Lines, I));
}
/* Add an additional newline after the segment output */
- fprintf (F, "\n");
+ WriteOutput ("\n");
}
-
-
-
-