]> git.sur5r.net Git - cc65/blobdiff - src/cc65/dataseg.c
Merge remote-tracking branch 'upstream/master' into a5200
[cc65] / src / cc65 / dataseg.c
index bcc51d2a7ae48e8542711aa05c3d71325facad2c..40ec6f7939cbe574bd67837045654b19e9b2a27d 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                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                                    */
 /*****************************************************************************/
 
 
@@ -54,11 +55,11 @@ DataSeg* NewDataSeg (const char* Name, SymEntry* Func)
 /* 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 */
@@ -75,13 +76,13 @@ void DS_Append (DataSeg* Target, const DataSeg* Source)
     /* 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 */
@@ -94,8 +95,19 @@ void DS_AddLine (DataSeg* S, const char* Format, va_list ap)
 
 
 
-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;
 
@@ -104,21 +116,17 @@ void DS_Output (const DataSeg* S, FILE* F)
 
     /* 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");
 }
-
-
-
-