correct exception handler range checks
[cacao.git] / main.c
diff --git a/main.c b/main.c
index 55aa056505f879992c919be580f38fe111ef4668..74dd1ff0b9cbdfc85c7b6889a4ad5af595f71143 100644 (file)
--- a/main.c
+++ b/main.c
@@ -37,7 +37,7 @@
      - Calling the class loader
      - Running the main method
 
-   $Id: main.c 1371 2004-08-01 21:55:39Z stefan $
+   $Id: main.c 1424 2004-10-30 11:15:23Z motse $
 
 */
 
@@ -350,18 +350,19 @@ int main(int argc, char **argv)
 
        /************ Collect info from the environment ************************/
 
-       classpath = MNEW(u1, 2);
+       /* set an initial, minimal classpath */
+       classpath = MNEW(char, 2);
        strcpy(classpath, ".");
 
        /* get classpath environment */
        cp = getenv("CLASSPATH");
        if (cp) {
                classpath = MREALLOC(classpath,
-                                                        u1,
+                                                        char,
                                                         strlen(classpath),
                                                         strlen(classpath) + 1 + strlen(cp) + 1);
                strcat(classpath, ":");
-               strncat(classpath, cp, strlen(cp));
+               strcat(classpath, cp);
        }
 
        /***************** Interpret the command line *****************/
@@ -374,12 +375,11 @@ int main(int argc, char **argv)
                case OPT_IGNORE: break;
                        
                case OPT_CLASSPATH:
-                       classpath = MREALLOC(classpath,
-                                                                u1,
-                                                                strlen(classpath),
-                                                                strlen(classpath) + 1 + strlen(opt_arg) + 1);
-                       strcat(classpath, ":");
-                       strncat(classpath, opt_arg, strlen(opt_arg));
+                       /* forget old classpath and set the argument as new classpath */
+                       MFREE(classpath, char, strlen(classpath));
+
+                       classpath = MNEW(char, strlen(opt_arg) + 1);
+                       strcpy(classpath, opt_arg);
                        break;
                                
                case OPT_D:
@@ -595,8 +595,7 @@ int main(int argc, char **argv)
                        exit(10);
                }
        }
-   
-   
+
        if (opt_ind >= argc) {
                print_usage();
                exit(10);
@@ -622,10 +621,12 @@ int main(int argc, char **argv)
 
        cacao_initializing = true;
 
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(USE_THREADS)
+#if defined(NATIVE_THREADS)
        initThreadsEarly();
 #endif
        initLocks();
+#endif
 
        /* install architecture dependent signal handler used for exceptions */
        init_exceptions();
@@ -656,6 +657,9 @@ int main(int argc, char **argv)
        if (!class_init(class_new(utf_new_char("java/lang/System"))))
                throw_main_exception_exit();
 
+       
+       
+        jni_init();
        cacao_initializing = false;
 
        /************************* Start worker routines ********************/
@@ -889,16 +893,9 @@ void cacao_exit(s4 status)
 
 void cacao_shutdown(s4 status)
 {
-       /**** RTAprint ***/
-
        if (verbose || getcompilingtime || opt_stat) {
                log_text("CACAO terminated by shutdown");
-               if (opt_stat)
-                       print_stats();
-               if (getcompilingtime)
-                       print_times();
-               mem_usagelog(0);
-               dolog("Exit status: %d\n", (int) status);
+               dolog("Exit status: %d\n", (s4) status);
        }
 
        exit(status);