-
Notifications
You must be signed in to change notification settings - Fork 36
use int compare when both version fields are ints #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
87e86e9
80c5a2d
2ed2b00
2ed21f3
d37f9ca
f0f30de
c11716a
ab4a8ef
7404aeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,31 +32,31 @@ public class Eddy.Package : Object { | |
| public signal void state_updated (); | ||
|
|
||
| public string filename { public get; construct; } | ||
| public string name { | ||
| public string name { | ||
| get { | ||
| return target.get_name (); | ||
| } | ||
| } | ||
|
|
||
| public string summary { | ||
| public string summary { | ||
| get { | ||
| return target.summary; | ||
| } | ||
| } | ||
|
|
||
| public string version { | ||
| public string version { | ||
| get { | ||
| return target.get_version (); | ||
| } | ||
| } | ||
|
|
||
| public uint64 installed_size { | ||
| public uint64 installed_size { | ||
| get { | ||
| return target.size; | ||
| } | ||
| } | ||
|
|
||
| public string homepage { | ||
| public string homepage { | ||
| owned get { | ||
| return target.url; | ||
| } | ||
|
|
@@ -76,8 +76,8 @@ public class Eddy.Package : Object { | |
| public bool has_task { get; set; default = false; } | ||
|
|
||
| public StateFlags state_flags { public get; private set; default = StateFlags.NOT_INSTALLED; } | ||
| public bool is_installed { | ||
|
|
||
| public bool is_installed { | ||
| get { | ||
| return StateFlags.INSTALLED in state_flags; | ||
| } | ||
|
|
@@ -178,7 +178,7 @@ public class Eddy.Package : Object { | |
| foreach (var package in packages) { | ||
| yield package.reset (); | ||
| package.exit_code = exit_code; | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
@@ -282,19 +282,19 @@ public class Eddy.Package : Object { | |
|
|
||
| int length = int.max (aparts.length, bparts.length); | ||
| for (int i = 0; i < length; i++) { | ||
| int rc = strcmp (aparts[i], bparts[i]); | ||
| if (i == length - 1) { | ||
| if (bparts[i] > aparts[i]) { | ||
| return 1; | ||
| } | ||
| else if (bparts[i] < aparts[i]) { | ||
| int a_num, b_num; | ||
| bool a_is_num = int.try_parse(aparts[i], out a_num); | ||
| bool b_is_num = int.try_parse(bparts[i], out b_num); | ||
|
|
||
| if (a_is_num && b_is_num) { | ||
| if (a_num < b_num) { | ||
|
||
| return -1; | ||
| } | ||
| } | ||
| if (rc < 0) { | ||
| return -1; | ||
| } else if (rc > 0) { | ||
| return 1; | ||
| } else if (a_num > b_num) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
|
||
| } else { | ||
| return strcmp (aparts[i], bparts[i]); | ||
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -401,7 +401,7 @@ public class Eddy.Package : Object { | |
| yield update_installed_state (); | ||
| return true; | ||
| } | ||
|
|
||
| } catch (Error e) { | ||
| throw e; | ||
| } | ||
|
|
@@ -426,7 +426,7 @@ public class Eddy.Package : Object { | |
| found = true; | ||
| state_flags = StateFlags.INSTALLED; | ||
|
|
||
| int rc = compare_versions (package.get_version (), version); | ||
| int rc = compare_versions (package.get_version (), version); | ||
| if (rc == 1) { | ||
|
||
| state_flags |= StateFlags.CAN_DOWNGRADE; | ||
| } else if (rc == -1) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a problem coincidentally because you have
return 0, but if you do it correctly it will cause out of array error, replace it withint.minand do the length comparison as above