tira-misu commented on issue #432:
URL: https://github.com/apache/celix/issues/432#issuecomment-1370562070
i made a quick fix in celix 1.12 for me. Perhaps its a solution for current
branch too?
```
static celix_status_t compareVersion(char* version1, char* version2, int*
compareResult) {
version_pt v1 = NULL;
version_pt v2 = NULL;
if (version_createVersionFromString(version1, &v1) != CELIX_SUCCESS ||
version_createVersionFromString(version2, &v2) != CELIX_SUCCESS)
{
return CELIX_ILLEGAL_ARGUMENT;
}
version_compareTo(v1, v2, compareResult);
version_destroy(v1);
version_destroy(v2);
return CELIX_SUCCESS;
}
```
```
case EQUAL: {
if (compareVersion(string, (char*)value2, &versionCompareResult) ==
CELIX_SUCCESS)
{
*result = versionCompareResult == 0;
return CELIX_SUCCESS;
}
*result = (strcmp(string, (char*)value2) == 0);
return CELIX_SUCCESS;
}
case GREATER: {
if (compareVersion(string, (char*)value2, &versionCompareResult) ==
CELIX_SUCCESS)
{
*result = versionCompareResult > 0;
return CELIX_SUCCESS;
}
*result = (strcmp(string, (char*)value2) > 0);
return CELIX_SUCCESS;
}
case GREATEREQUAL: {
if (compareVersion(string, (char*)value2, &versionCompareResult) ==
CELIX_SUCCESS)
{
*result = versionCompareResult >= 0;
return CELIX_SUCCESS;
}
*result = (strcmp(string, (char*)value2) >= 0);
return CELIX_SUCCESS;
}
case LESS: {
if (compareVersion(string, (char*)value2, &versionCompareResult) ==
CELIX_SUCCESS)
{
*result = versionCompareResult < 0;
return CELIX_SUCCESS;
}
*result = (strcmp(string, (char*)value2) < 0);
return CELIX_SUCCESS;
}
case LESSEQUAL: {
if (compareVersion(string, (char*)value2, &versionCompareResult) ==
CELIX_SUCCESS)
{
*result = versionCompareResult <= 0;
return CELIX_SUCCESS;
}
*result = (strcmp(string, (char*)value2) <= 0);
return CELIX_SUCCESS;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]