Skip to content

Commit

Permalink
clean up code and implementation of hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Hauffe committed Aug 21, 2018
1 parent 57cb8c4 commit 452a878
Showing 1 changed file with 56 additions and 61 deletions.
117 changes: 56 additions & 61 deletions nbi/engine/native/launcher/windows/src/JavaUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,80 +124,75 @@ DWORD isJavaCompatible(JavaProperties *currentJava, JavaCompatible ** compatible

JavaVersion * getJavaVersionFromString(char * string, DWORD * result) {
JavaVersion *vers = NULL;
if(getLengthA(string)>=3) {
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;
}
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!=NULL) {
char c = p[0];
}

// 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') {
minor = (minor) * 10 + c - '0';
vers->micro = (vers->micro) * 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...
} else if(c=='_') {//update
p++;
while(p!=NULL) {
char c = p[0];
while((c = *p) != 0) {
p++;
if(c>='0' && c<='9') {
vers->micro = (vers->micro) * 10 + c - '0';
p++;
vers->update = (vers->update) * 10 + c - '0';
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;
}
break;
}
} else {
if(*p!=0) p++;
}
if(c=='-' && *p!=0) { // build number
lstrcpyn(vers->build, p, min(127, getLengthA(p)+1));
}
break;
}
}
}
return vers;
}

Expand Down

0 comments on commit 452a878

Please sign in to comment.