]> git.sur5r.net Git - cc65/commitdiff
Use a separate structure for file infos instead of just the name.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 23 May 2001 21:32:57 +0000 (21:32 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 23 May 2001 21:32:57 +0000 (21:32 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@749 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ld65/fileinfo.c [new file with mode: 0644]
src/ld65/fileinfo.h [new file with mode: 0644]
src/ld65/lineinfo.c
src/ld65/lineinfo.h
src/ld65/make/gcc.mak
src/ld65/make/watcom.mak
src/ld65/objdata.c
src/ld65/objdata.h
src/ld65/objfile.c

diff --git a/src/ld65/fileinfo.c b/src/ld65/fileinfo.c
new file mode 100644 (file)
index 0000000..e8e31b4
--- /dev/null
@@ -0,0 +1,79 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                               fileinfo.c                                 */
+/*                                                                           */
+/*                       sOURCE FILE INFO STRUCTURE                         */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2001      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@cc65.org                                                 */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+/* common */
+#include "xmalloc.h"
+
+/* ld65 */
+#include "fileio.h"
+#include "fileinfo.h"
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+static FileInfo* NewFileInfo (void)
+/* Allocate and initialize a new FileInfo struct and return it */
+{
+    /* Allocate memory */
+    FileInfo* FI = xmalloc (sizeof (FileInfo));
+
+    /* Return the new struct */
+    return FI;
+}
+
+
+
+FileInfo* ReadFileInfo (FILE* F, ObjData* O)
+/* Read a file info from a file and return it */
+{
+    /* Allocate a new FileInfo structure */
+    FileInfo* FI = NewFileInfo ();
+
+    /* Read the fields from the file */
+    FI->MTime = Read32 (F);
+    FI->Size  = Read32 (F);
+    FI->Name  = ReadStr (F);
+
+    /* Return the new struct */
+    return FI;
+}
+
+
+
diff --git a/src/ld65/fileinfo.h b/src/ld65/fileinfo.h
new file mode 100644 (file)
index 0000000..162e95d
--- /dev/null
@@ -0,0 +1,82 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                               fileinfo.h                                 */
+/*                                                                           */
+/*                       Source file info structure                         */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2001      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@cc65.org                                                 */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef FILEINFO_H
+#define FILEINFO_H
+
+
+
+#include <stdio.h>
+
+/* common */
+#include "coll.h"
+#include "filepos.h"
+
+/* ld65 */
+#include "objdata.h"
+
+
+
+/*****************************************************************************/
+/*                                  Data                                    */
+/*****************************************************************************/
+
+
+
+typedef struct FileInfo FileInfo;
+struct FileInfo {
+    unsigned long   MTime;                /* Time of last modification */
+    unsigned long   Size;                 /* Size of the file */
+    char*           Name;                        /* File name */
+};
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+FileInfo* ReadFileInfo (FILE* F, ObjData* O);
+/* Read a file info from a file and return it */
+
+
+
+/* End of fileinfo.h */
+#endif
+
+
+
index 5cc2e19e1dcf642134707fdbb12e7d0178d65eac..1811e5a01950b6c294a9a9a50264101a691f8f05 100644 (file)
@@ -34,6 +34,7 @@
 
 
 /* common */
+#include "check.h"
 #include "xmalloc.h"
 
 /* ld65 */
@@ -55,6 +56,7 @@ static LineInfo* NewLineInfo (void)
     LineInfo* LI = xmalloc (sizeof (LineInfo));
 
     /* Initialize the fields */
+    LI->File = 0;
     InitFilePos (&LI->Pos);
     InitCollection (&LI->Fragments);
 
@@ -73,6 +75,10 @@ LineInfo* ReadLineInfo (FILE* F, ObjData* O)
     /* Read the file position */
     ReadFilePos (F, &LI->Pos);
 
+    /* Resolve the file index to a pointer to FileInfo struct */
+    CHECK (LI->Pos.Name < O->FileCount);
+    LI->File = O->Files[LI->Pos.Name];
+
     /* Return the new LineInfo */
     return LI;
 }
index 98138c47c732f413bb53c8ba75717a031d6444a5..8a40126f328e695fc4e3d4d704249f37838cadc5 100644 (file)
@@ -55,8 +55,9 @@
 
 typedef struct LineInfo LineInfo;
 struct LineInfo {
-    FilePos         Pos;                  /* File position */
-    Collection      Fragments;            /* Fragments for this line */
+    struct FileInfo*    File;                /* File struct for this line */
+    FilePos             Pos;                  /* File position */
+    Collection          Fragments;            /* Fragments for this line */
 };
 
 
index f48fc8bc5758de66decc952de61ca3e211651085..3dfdd26708da49ca755e0fef1b8a246d90a52d6c 100644 (file)
@@ -27,6 +27,7 @@ OBJS =        bin.o           \
        exports.o       \
        expr.o          \
        extsyms.o       \
+       fileinfo.o      \
        fileio.o        \
        fragment.o      \
        global.o        \
index 0a9c6658554688bb778dd8ec7f061fe9d9ec677f..ab731b54b90f7ee4a4ac6b677b48cc0773d84e64 100644 (file)
@@ -76,10 +76,12 @@ OBJS =      bin.obj         \
        exports.obj     \
        expr.obj        \
        extsyms.obj     \
+       fileinfo.obj    \
        fileio.obj      \
        fragment.obj    \
        global.obj      \
        library.obj     \
+       lineinfo.obj    \
        main.obj        \
        mapfile.obj     \
        o65.obj         \
index 8deecb0f730ad5fd3d427b645771a38f730aa4c8..5183c7d817c2f51660e1f914d4a842727e589893 100644 (file)
@@ -41,6 +41,7 @@
 
 /* ld65 */
 #include "error.h"
+#include "fileinfo.h"
 #include "objdata.h"
 
 
@@ -110,7 +111,7 @@ void FreeObjData (ObjData* O)
     xfree (O->Name);
     xfree (O->Imports);
     xfree (O->Exports);
-    xfree (O->DbgSyms);            
+    xfree (O->DbgSyms);
     xfree (O->LineInfos);
     xfree (O);
 }
@@ -144,7 +145,7 @@ const char* GetSourceFileName (const ObjData* O, unsigned Index)
        PRECONDITION (Index < O->FileCount);
 
        /* Return the name */
-       return O->Files[Index];
+       return O->Files[Index]->Name;
 
     }
 }
index a6d39ace71f96d8b3aad37c3b1f0dfbd2a756199..cca2f7a38f516d40bbbd8a9a89b0e38597e6b706 100644 (file)
@@ -65,7 +65,7 @@ struct ObjData {
     unsigned long      Start;          /* Start offset of data in library */
     unsigned           Flags;
     unsigned           FileCount;      /* Input file count */
-    char**             Files;          /* List of input files */
+    struct FileInfo**          Files;          /* List of input files */
     unsigned           SectionCount;   /* Count of sections in this object */
     struct Section**   Sections;       /* List of all sections */
     unsigned           ExportCount;    /* Count of exports */
index f08b147617cff948fcff7838a300271c964f47cb..b11794236c87cefd529c5b84d331781062d0d133 100644 (file)
@@ -46,6 +46,7 @@
 #include "dbgsyms.h"
 #include "error.h"
 #include "exports.h"
+#include "fileinfo.h"
 #include "fileio.h"
 #include "lineinfo.h"
 #include "objdata.h"
@@ -112,13 +113,9 @@ void ObjReadFiles (FILE* F, ObjData* O)
     unsigned I;
 
     O->FileCount  = ReadVar (F);
-    O->Files      = xmalloc (O->FileCount * sizeof (char*));
+    O->Files      = xmalloc (O->FileCount * sizeof (FileInfo*));
     for (I = 0; I < O->FileCount; ++I) {
-               /* Skip MTime and size */
-               Read32 (F);
-               Read32 (F);
-               /* Read the filename */
-               O->Files [I] = ReadStr (F);
+               O->Files[I] = ReadFileInfo (F, O);
     }
 }
 
@@ -158,7 +155,7 @@ void ObjReadDbgSyms (FILE* F, ObjData* O)
 /* Read the debug symbols from a file at the current position */
 {
     unsigned I;
-                    
+
     O->DbgSymCount = ReadVar (F);
     O->DbgSyms    = xmalloc (O->DbgSymCount * sizeof (DbgSym*));
     for (I = 0; I < O->DbgSymCount; ++I) {