]> git.sur5r.net Git - cc65/blobdiff - src/ca65/main.c
Small fixes for Watcom-C
[cc65] / src / ca65 / main.c
index ecbb58ec973ea9eb62b1e00d7b41392585ed42c6..b029e2f0cc64b67255ec5102819d2143cf6c9f64 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <time.h>
 
 /* common */
+#include "chartype.h"
 #include "cmdline.h"
+#include "print.h"
 #include "target.h"
+#include "tgttrans.h"
 #include "version.h"
 
 /* ca65 */
@@ -54,6 +56,7 @@
 #include "incpath.h"
 #include "instr.h"
 #include "istack.h"
+#include "lineinfo.h"
 #include "listing.h"
 #include "macro.h"
 #include "nexttok.h"
@@ -136,14 +139,14 @@ static void DefineSymbol (const char* Def)
     char SymName [MAX_STR_LEN+1];
 
     /* The symbol must start with a character or underline */
-    if (Def [0] != '_' && !isalpha (Def [0])) {
+    if (Def [0] != '_' && !IsAlpha (Def [0])) {
        InvDef (Def);
     }
     P = Def;
 
     /* Copy the symbol, checking the rest */
     I = 0;
-    while (isalnum (*P) || *P == '_') {
+    while (IsAlNum (*P) || *P == '_') {
        if (I <= MAX_STR_LEN) {
            SymName [I++] = *P;
        }
@@ -312,7 +315,7 @@ static void OptTarget (const char* Opt, const char* Arg)
 static void OptVerbose (const char* Opt, const char* Arg)
 /* Increase verbosity */
 {
-    ++Verbose;
+    ++Verbosity;
 }
 
 
@@ -478,6 +481,9 @@ static void CreateObjFile (void)
     /* Write debug symbols if requested */
     WriteDbgSyms ();
 
+    /* Write line infos if requested */
+    WriteLineInfo ();
+
     /* Write an updated header and close the file */
     ObjClose ();
 }
@@ -507,7 +513,7 @@ int main (int argc, char* argv [])
     int I;
 
     /* Initialize the cmdline module */
-    InitCmdLine (argc, argv, "ca65");
+    InitCmdLine (&argc, &argv, "ca65");
 
     /* Enter the base lexical level. We must do that here, since we may
      * define symbols using -D.
@@ -516,10 +522,10 @@ int main (int argc, char* argv [])
 
     /* Check the parameters */
     I = 1;
-    while (I < argc) {
+    while (I < ArgCount) {
 
                /* Get the argument */
-               const char* Arg = argv [I];
+               const char* Arg = ArgVec [I];
 
                /* Check for an option */
                if (Arg [0] == '-') {
@@ -529,7 +535,7 @@ int main (int argc, char* argv [])
                    LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
                    break;
 
-                       case 'g':
+                       case 'g':
                            OptDebugInfo (Arg, 0);
                            break;
 
@@ -574,7 +580,7 @@ int main (int argc, char* argv [])
                            break;
 
                        case 'V':
-                   OptVersion (Arg, 0);
+                   OptVersion (Arg, 0);
                            break;
 
                        case 'W':
@@ -607,6 +613,9 @@ int main (int argc, char* argv [])
        exit (EXIT_FAILURE);
     }
 
+    /* Intialize the target translation tables */
+    TgtTranslateInit ();
+
     /* Initialize the scanner, open the input file */
     InitScanner (InFile);
 
@@ -631,8 +640,11 @@ int main (int argc, char* argv [])
         SegCheck ();
     }
 
+    /* If we didn't have an errors, index the line infos */
+    MakeLineInfoIndex ();
+
     /* Dump the data */
-    if (Verbose >= 2) {
+    if (Verbosity >= 2) {
         SymDump (stdout);
         SegDump ();
     }