You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/09/30 07:53:48 UTC

[GitHub] geertjanw closed pull request #734: [NETBEANS-1157] resolved problem with java version higher 9 and the n…

geertjanw closed pull request #734: [NETBEANS-1157] resolved problem with java version higher 9 and the n…
URL: https://github.com/apache/incubator-netbeans/pull/734
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nbi/engine/native/launcher/windows/src/JavaUtils.c b/nbi/engine/native/launcher/windows/src/JavaUtils.c
index 4fbf7f9722..6012afb1d9 100644
--- a/nbi/engine/native/launcher/windows/src/JavaUtils.c
+++ b/nbi/engine/native/launcher/windows/src/JavaUtils.c
@@ -124,57 +124,73 @@ DWORD isJavaCompatible(JavaProperties *currentJava, JavaCompatible ** compatible
 
 JavaVersion * getJavaVersionFromString(char * string, DWORD * result) {
     JavaVersion *vers = NULL;
-    if(getLengthA(string)>=3) {
-        //hope that at least we "major.minor" : 1.5
-        if(string[1]=='.') {
-            char c = string[0];
+    if(getLengthA(string)<3) {
+        return vers;
+    }
+
+    const char *p = string;
+
+    // get major 
+    long major = 0;
+    while(*p!=0) {
+        char c = *p++;
+        if(c>='0' && c<='9') {
+            major = (major) * 10 + c - '0';
+            if (major > 999) return vers;
+            continue;
+        } else if(c=='.'){
+            break;
+        } else{
+            return vers;
+        }
+    }
+
+    // get minor 
+    long minor = 0;
+    while(*p!=0) {
+        char c = *p;
+        if(c>='0' && c<='9') {
+            minor = (minor) * 10 + c - '0';
+            p++;
+            continue;
+        }
+        break;
+    }
+
+    *result = ERROR_OK;
+    vers = (JavaVersion*) LocalAlloc(LPTR, sizeof(JavaVersion));
+    vers->major  = major;
+    vers->minor  = minor;
+    vers->micro  = 0;
+    vers->update = 0;
+    ZERO(vers->build, 128);
+
+    if(p[0]=='.') { // micro...
+        p++;
+        while(*p!=0) {
+            char c = *p;
             if(c>='0' && c<='9') {
-                long major = c - '0';
-                c = string[2];
-                if(c>='0' && c<='9') {
-                    char *p = string + 3;
-                    long minor = c - '0';
-                    *result = ERROR_OK;
-                    vers = (JavaVersion*) LocalAlloc(LPTR, sizeof(JavaVersion));
-                    vers->major  = major;
-                    vers->minor  = minor;
-                    vers->micro  = 0;
-                    vers->update = 0;
-                    ZERO(vers->build, 128);
-                    if(p!=NULL) {
-                        if(p[0]=='.') { // micro...
-                            p++;
-                            while(p!=NULL) {
-                                char c = p[0];
-                                if(c>='0' && c<='9') {
-                                    vers->micro = (vers->micro) * 10 + c - '0';
-                                    p++;
-                                    continue;
-                                }
-                                else if(c=='_') {//update
-                                    p++;
-                                    while(p!=NULL) {
-                                        c = p[0];
-                                        p++;
-                                        if(c>='0' && c<='9') {
-                                            vers->update = (vers->update) * 10 + c - '0';
-                                            continue;
-                                        } else {
-                                            break;
-                                        }
-                                    }
-                                } else {
-                                    if(p!=NULL) p++;
-                                }
-                                if(c=='-' && p!=NULL) { // build number
-                                    lstrcpyn(vers->build, p, min(127, getLengthA(p)+1));
-                                }
-                                break;
-                            }
-                        }
+                vers->micro = (vers->micro) * 10 + c - '0';
+                p++;
+                continue;
+            } else if(c=='_') {//update
+                p++;
+                while((c = *p) != 0) {
+                    p++;
+                    if(c>='0' && c<='9') {
+                        vers->update = (vers->update) * 10 + c - '0';
+                        continue;
+                    } else {
+                        break;
                     }
                 }
+            } else {
+                if(*p!=0) p++;
+            }
+            if(c=='-' && *p!=0) { // build number
+                lstrcpyn(vers->build, p, min(127, getLengthA(p)+1));
             }
+            break;
         }
     }
     return vers;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists