/* */
/* */
/* */
-/* (C) 2000-2007 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2000-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include "check.h"
#include "fname.h"
#include "fragdefs.h"
+#include "strbuf.h"
#include "version.h"
#include "xmalloc.h"
-void NewListingLine (const char* Line, unsigned char File, unsigned char Depth)
+void NewListingLine (const StrBuf* Line, unsigned char File, unsigned char Depth)
/* Create a new ListLine struct and insert it */
{
/* Store only if listing is enabled */
- if (Listing) {
+ if (SB_GetLen (&ListingName) > 0) {
ListLine* L;
/* Get the length of the line */
- unsigned Len = strlen (Line);
+ unsigned Len = SB_GetLen (Line);
/* Ignore trailing newlines */
- while (Len > 0 && Line[Len-1] == '\n') {
+ while (Len > 0 && SB_AtUnchecked (Line, Len-1) == '\n') {
--Len;
}
L->Depth = Depth;
L->Output = (ListingEnabled > 0);
L->ListBytes = (unsigned char) ListBytes;
- memcpy (L->Line, Line, Len);
- L->Line [Len] = '\0';
+ memcpy (L->Line, SB_GetConstBuf (Line), Len);
+ L->Line[Len] = '\0';
/* Insert the line into the list of lines */
if (LineList == 0) {
void EnableListing (void)
/* Enable output of lines to the listing */
{
- if (Listing) {
+ if (SB_GetLen (&ListingName) > 0) {
/* If we're about to enable the listing, do this for the current line
* also, so we will see the source line that did this.
*/
void DisableListing (void)
/* Disable output of lines to the listing */
{
- if (Listing) {
+ if (SB_GetLen (&ListingName) > 0) {
if (ListingEnabled == 0) {
/* Cannot switch the listing off once more */
Error ("Counter underflow");
void InitListingLine (void)
/* Initialize the current listing line */
{
- if (Listing) {
+ if (SB_GetLen (&ListingName) > 0) {
/* Make the last loaded line the current line */
/* ###### This code is a hack! We really need to do it right
* as soon as we know, how:-(
* last line of the previous page.
*/
{
+ /* Gte a pointer to the current input file */
+ const StrBuf* CurFile = GetFileName (L->File);
+
/* Print the header on the new page */
fprintf (F,
- "ca65 V%u.%u.%u - %s\n"
+ "ca65 V%s - %s\n"
"Main file : %s\n"
- "Current file: %s\n"
+ "Current file: %.*s\n"
"\n",
- VER_MAJOR, VER_MINOR, VER_PATCH,
- Copyright,
+ GetVersionAsString (), Copyright,
InFile,
- GetFileName (L->File));
+ (int) SB_GetLen (CurFile), SB_GetConstBuf (CurFile));
/* Count pages, reset lines */
++PageNumber;
ListLine* L;
char HeaderBuf [LINE_HEADER_LEN+1];
- /* Create the name of the listing file if needed */
- if (ListFile == 0) {
- ListFile = MakeFilename (InFile, ListExt);
- }
-
/* Open the real listing file */
- F = fopen (ListFile, "w");
+ F = fopen (SB_GetConstBuf (&ListingName), "w");
if (F == 0) {
- Fatal ("Cannot open listing file: %s", strerror (errno));
+ Fatal ("Cannot open listing file `%s': %s",
+ SB_GetConstBuf (&ListingName),
+ strerror (errno));
}
/* Reset variables, print the header for the first page */