From 45242a8e0214008c1957fce6a5803a756949e11a Mon Sep 17 00:00:00 2001 From: cuz Date: Tue, 29 May 2001 07:39:01 +0000 Subject: [PATCH] Fixed line info issues git-svn-id: svn://svn.cc65.org/cc65/trunk@763 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/lineinfo.c | 12 ++++++++++++ src/ca65/objcode.c | 25 +++---------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/ca65/lineinfo.c b/src/ca65/lineinfo.c index 3abfd6e3f..4ea2e73f1 100644 --- a/src/ca65/lineinfo.c +++ b/src/ca65/lineinfo.c @@ -166,8 +166,17 @@ static int CmpLineInfo (void* Data, const void* LI1_, const void* LI2_) void MakeLineInfoIndex (void) /* Sort the line infos and drop all unreferenced ones */ { + unsigned I; + /* Sort the collection */ CollSort (&LineInfoColl, CmpLineInfo, 0); + + /* Walk over the list and index the line infos. */ + for (I = 0; I < LineInfoValid; ++I) { + /* Get a pointer to this line info */ + LineInfo* LI = CollAtUnchecked (&LineInfoColl, I); + LI->Index = I; + } } @@ -203,6 +212,9 @@ void WriteLineInfo (void) ObjWriteVar (0); } + + /* End of line infos */ + ObjEndLineInfos (); } diff --git a/src/ca65/objcode.c b/src/ca65/objcode.c index a231b289b..a7e984724 100644 --- a/src/ca65/objcode.c +++ b/src/ca65/objcode.c @@ -458,8 +458,6 @@ static void WriteOneSeg (Segment* Seg) /* Write one segment to the object file */ { Fragment* Frag; - Fragment* F; - unsigned long Size; unsigned LineInfoIndex; /* Write the segment name followed by the byte count in this segment */ @@ -478,26 +476,9 @@ static void WriteOneSeg (Segment* Seg) switch (Frag->Type) { case FRAG_LITERAL: - /* To make the object file somewhat smaller, write all literal - * data of this and the following fragments preceeded by the - * length. - */ - F = Frag; - Size = 0; - while (F && F->Type == FRAG_LITERAL) { - Size += F->Len; - F = F->Next; - } ObjWrite8 (FRAG_LITERAL); - ObjWriteVar (Size); - - /* Now write the literal data */ - F = Frag; - while (F && F->Type == FRAG_LITERAL) { - ObjWriteData (F->V.Data, F->Len); - Frag = F; - F = F->Next; - } + ObjWriteVar (Frag->Len); + ObjWriteData (Frag->V.Data, Frag->Len); break; case FRAG_EXPR: @@ -537,7 +518,7 @@ static void WriteOneSeg (Segment* Seg) /* Write extra line info for this fragment. Zero is considered * "no line info", so add one to the value. - */ + */ LineInfoIndex = Frag->LI? Frag->LI->Index + 1 : 0; ObjWriteVar (LineInfoIndex); -- 2.39.5