Kaynağa Gözat

Synchronize changes to RTS files

k-john-gough 8 yıl önce
ebeveyn
işleme
aed8f694da

+ 6 - 11
libs/csharp/RTS.cs

@@ -781,7 +781,7 @@ public class ProgArgs
 
         public static void GetEnvVar(char[] name, char[] valu) {
             System.String nam = CP_rts.mkStr(name);
-            System.String val = System.Environment.GetEnvironmentVariable(nam);
+            System.String val = System.Environment.GetEnvironmentVariable(nam, System.EnvironmentVariableTarget.User);
             CP_rts.StrToChF(valu, val);
         }
 
@@ -891,16 +891,11 @@ public class CP_rts
 	// Known in ILASM as [RTS]CP_rts::chrArrLength
 	public static int chrArrLength(char[] src)
 	{
-	    int  ix = 0;
-	    char ch;
-	    do {
-		ch = src[ix];
-		ix++;
-	    } while (ch != '\0');
-// System.Console.Write(ix-1);
-// System.Console.Write(' ');
-// System.Console.WriteLine(src);
-	    return ix-1;
+        int len = src.Length;
+        for (int ix = 0; ix < len; ix++)
+            if (src[ix] == '\0')
+                return ix - 1;
+        return len;
 	}
 
 /* -------------------------------------------------------------------- */

+ 5 - 0
libs/java/CPJrts.java

@@ -113,6 +113,8 @@ public class CPJrts
 
 	public static char[] JavaStrToChrOpen(String input)
 	{
+            if (input == null) 
+                return null;
 	    int    len = input.length();
 	    char[] str = new char[len+1];
 	    input.getChars(0, len, str, 0);
@@ -133,7 +135,10 @@ public class CPJrts
 
 	public static String FixChToJavaStr(char[] arr)
 	{
+            if (arr == null) return null;
+	    //
             // This truncation makes semantics same as .NET version
+	    //
             int len = ChrArrLength(arr);
 	    return new String(arr, 0, len);
 	}

+ 5 - 1
libs/java/GPBinFiles.java

@@ -9,6 +9,7 @@ package CP.GPBinFiles;
 import java.io.*;
 import CP.CPJ.CPJ;
 import CP.GPFiles.GPFiles.*;
+import CP.ProgArgs.ProgArgs.*;
 
 public class GPBinFiles {
 
@@ -40,6 +41,10 @@ public class GPBinFiles {
 
     String nextDir;
     String thisPath = System.getProperty(pName);
+    if (thisPath == null)
+	    thisPath = System.getenv(pName);
+    if (thisPath == null)
+	    return null;
     GPBinFiles_FILE cpf = new GPBinFiles_FILE();
     boolean found = false; 
     boolean pathFinished = false;
@@ -122,7 +127,6 @@ public class GPBinFiles {
     //    cpf.length = cpf.rf.length();
     return cpf;
   } 
-
   public static boolean EOF(GPBinFiles_FILE cpf) throws IOException {
     return cpf.rf.getFilePointer() >= cpf.length;
   }

+ 2 - 0
libs/java/MakeAll.bat

@@ -24,3 +24,5 @@ javac -d . VecR32.java
 javac -d . VecR64.java
 javac -d . VecBase.java
 javac -d . VecRef.java
+pause
+

+ 35 - 0
libs/java/MakeRTSjar.bat

@@ -0,0 +1,35 @@
+
+REM @echo off
+REM this compiles all of the standard java-sourced libraries for GPCP
+REM and collects then together in a JAR file. New for gpcp-JVM v1.4.*
+mkdir dest
+javac -d dest Console.java
+javac -d dest CPJ.java
+javac -d dest CPJrts.java
+javac -d dest XHR.java
+javac -d dest CPmain.java
+javac -d dest Error.java
+javac -d dest GPFiles_FILE.java
+javac -d dest GPFiles.java
+javac -d dest GPBinFiles_FILE.java
+javac -d dest GPBinFiles.java
+javac -d dest GPTextFiles_FILE.java
+javac -d dest GPTextFiles.java
+javac -d dest ProcType.java
+javac -d dest ProgArgs.java
+javac -d dest RTS.java
+javac -d dest StdIn.java
+javac -d dest VecBase.java
+javac -d dest VecChr.java
+javac -d dest VecI32.java
+javac -d dest VecI64.java
+javac -d dest VecR32.java
+javac -d dest VecR64.java
+javac -d dest VecBase.java
+javac -d dest VecRef.java
+cd dest
+jar cvf cprts.jar .
+copy cprts.jar ..
+cd ..
+pause
+

+ 5 - 0
libs/java/ProgArgs.java

@@ -42,7 +42,12 @@ public class ProgArgs
         public static void GetEnvVar(char[] ss, char[] ds) 
         {
             String path = CP.CPJ.CPJ.MkStr(ss);
+	    //
+	    //  getenv was deprecated between jave 1.1 and SE 5 (!)
+	    //
             String valu = System.getProperty(path);
+	    if (valu == null) // Try getenv instead
+		    valu = System.getenv(path);
             int i;
             for (i = 0; 
                  i < valu.length() && i < ds.length;