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/08/21 10:53:27 UTC

[GitHub] sdedic commented on a change in pull request #734: [NETBEANS-1157] resolved problem with java version higher 9 and the n…

sdedic commented on a change in pull request #734: [NETBEANS-1157] resolved problem with java version higher 9 and the n…
URL: https://github.com/apache/incubator-netbeans/pull/734#discussion_r211560874
 
 

 ##########
 File path: nbi/engine/native/launcher/windows/src/JavaUtils.c
 ##########
 @@ -125,58 +125,79 @@ 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];
+        char *p = string;
+        
+        // get major 
+        long major = 0;
+        while(p!=NULL) {
+            char c = p[0];
+            if(c>='0' && c<='9') {
+                major = (major) * 10 + c - '0';
+                p++;
+                continue;
+            }
+            else if(c=='.'){
+                p++;
+            }
+            else{
+                return vers;
+            }
+            break;
+        }
+        
+        // get minor 
+        long minor = 0;
+        while(p!=NULL) {
+            char c = p[0];
             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...
+                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!=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) {
 
 Review comment:
   Because `c` is being tested after the loop, the check here must be
   ```
   while ((c = *p) != 0) {
     p++;
     // the rest of the code
   }
   

----------------------------------------------------------------
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