]> git.sur5r.net Git - cc65/commitdiff
New --label-break option
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 27 Jan 2006 19:36:33 +0000 (19:36 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 27 Jan 2006 19:36:33 +0000 (19:36 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3699 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/da65/global.c
src/da65/global.h
src/da65/infofile.c
src/da65/main.c
src/da65/output.c
src/da65/scanner.h

index 27875309bb99329b8c3c0b35778784cd0450b3af..40c8949c55d8a4835ad9879cd4d7f7b3f38bfef0 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2005 Ullrich von Bassewitz                                       */
+/* (C) 2000-2006 Ullrich von Bassewitz                                       */
 /*               Römerstrasse 52                                             */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
@@ -69,6 +69,7 @@ unsigned      Comments        = 0;      /* Add which comments to the output? */
 
 /* Page formatting */
 unsigned PageLength                  = 0;      /* Length of a listing page */
+unsigned LBreak               = 7;      /* Linefeed if labels exceed this limit */
 unsigned MIndent             = 9;      /* Mnemonic indent */
 unsigned AIndent             = 17;     /* Argument indent */
 unsigned CIndent             = 49;     /* Comment indent */
index 586cc18f030f8dbeff1029c2bd65d6060e3b8925..bd0b07a4f51d49c892c494f59aa6cd1a5128bba1 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2005 Ullrich von Bassewitz                                       */
+/* (C) 2000-2006 Ullrich von Bassewitz                                       */
 /*               Römerstrasse 52                                             */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
@@ -74,6 +74,7 @@ extern unsigned         Comments;       /* Add which comments to the output? */
 #define MIN_PAGE_LEN   32
 #define MAX_PAGE_LEN   127
 extern unsigned         PageLength;    /* Length of a listing page */
+extern unsigned         LBreak;         /* Linefeed if labels exceed this limit */
 extern unsigned                MIndent;        /* Mnemonic indent */
 extern unsigned                AIndent;        /* Argument indent */
 extern unsigned        CIndent;        /* Comment indent */
index 44a6f9e1f1ea11c75f24930ba79aa285b9a26d31..fff0feb6e7677ad5eb60181eaf58422e47f1716e 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <limits.h>
 #if defined(_MSC_VER)
 /* Microsoft compiler */
 #  include <io.h>
@@ -86,6 +87,7 @@ static void GlobalSection (void)
                {   "INPUTNAME",        INFOTOK_INPUTNAME       },
         {   "INPUTOFFS",        INFOTOK_INPUTOFFS       },
         {   "INPUTSIZE",        INFOTOK_INPUTSIZE       },
+        {   "LABELBREAK",       INFOTOK_LABELBREAK      },
        {   "OUTPUTNAME",       INFOTOK_OUTPUTNAME      },
        {   "PAGELENGTH",       INFOTOK_PAGELENGTH      },
        {   "STARTADDR",        INFOTOK_STARTADDR       },
@@ -160,6 +162,14 @@ static void GlobalSection (void)
                InfoNextTok ();
                break;
 
+            case INFOTOK_LABELBREAK:
+               InfoNextTok ();
+               InfoAssureInt ();
+                InfoRangeCheck (0, UCHAR_MAX);
+               LBreak = (unsigned char) InfoIVal;
+               InfoNextTok ();
+               break;
+
            case INFOTOK_OUTPUTNAME:
                InfoNextTok ();
                InfoAssureStr ();
index 673cf868f22f10ba826ff37a6e945892a06069b1..ed4471e8c3d5b9433597477d07f2023524afb0d8 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2005 Ullrich von Bassewitz                                       */
+/* (C) 1998-2006 Ullrich von Bassewitz                                       */
 /*               Römerstrasse 52                                             */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
+#include <limits.h>
 #include <time.h>
 
 /* common */
@@ -88,6 +89,7 @@ static void Usage (void)
             "  --help\t\tHelp (this text)\n"
             "  --hexoffs\t\tUse hexadecimal label offsets\n"
             "  --info name\t\tSpecify an info file\n"
+            "  --label-break n\tAdd newline if label exceeds length n\n"
             "  --pagelength n\tSet the page length for the listing\n"
             "  --start-addr addr\tSet the start/load address\n"
             "  --verbose\t\tIncrease verbosity\n"
@@ -198,6 +200,24 @@ static void OptInfo (const char* Opt attribute ((unused)), const char* Arg)
 
 
 
+static void OptLabelBreak (const char* Opt, const char* Arg)
+/* Handle the --label-break option */
+{
+    /* Convert the argument to a number */
+    unsigned long Val = CvtNumber (Opt, Arg);
+
+    /* Check for a valid range */
+    if (Val >= UCHAR_MAX) {
+        Error ("Argument for %s out of valid range (%d)",
+               Opt, UCHAR_MAX);
+    }
+
+    /* Use the value */
+    LBreak = (unsigned char) Val;
+}
+
+
+
 static void OptPageLength (const char* Opt attribute ((unused)), const char* Arg)
 /* Handle the --pagelength option */
 {
@@ -392,6 +412,7 @@ int main (int argc, char* argv [])
        { "--help",             0,      OptHelp                 },
                { "--hexoffs",          0,      OptHexOffs              },
                { "--info",             1,      OptInfo                 },
+        { "--label-break",      1,      OptLabelBreak           },
        { "--pagelength",       1,      OptPageLength           },
        { "--start-addr",       1,      OptStartAddr            },
        { "--verbose",          0,      OptVerbose              },
index f05f86f7bdbfaa003187c18915df38d6ed0d69ba..90b778d139c7d33acc5608ad5ce4e90475458bc7 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2005 Ullrich von Bassewitz                                       */
+/* (C) 2000-2006 Ullrich von Bassewitz                                       */
 /*               Römerstrasse 52                                             */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
@@ -166,8 +166,10 @@ void DefLabel (const char* Name)
 /* Define a label with the given name */
 {
     Output ("%s:", Name);
-    /* Don't start a new line if the label is fully in the left column */
-    if (Col > MIndent) {
+    /* If the label is longer than the configured maximum, or if it runs into
+     * the opcode column, start a new line.
+     */
+    if (Col > LBreak+2 || Col > MIndent) {
        LineFeed ();
     }
 }
index 2bd96be4ae90eafc7f7fbc4f8421d8088d8fc27c..fca05ed42fc8cbfd1746ace8784f4f74a643afb3 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2005 Ullrich von Bassewitz                                       */
+/* (C) 2000-2006 Ullrich von Bassewitz                                       */
 /*               Römerstrasse 52                                             */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
@@ -73,6 +73,7 @@ typedef enum token_t {
     INFOTOK_INPUTNAME,
     INFOTOK_INPUTOFFS,
     INFOTOK_INPUTSIZE,
+    INFOTOK_LABELBREAK,
     INFOTOK_OUTPUTNAME,
     INFOTOK_PAGELENGTH,
     INFOTOK_STARTADDR,