aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2003-10-02 12:30:22 +0000
committerJason Woodward2003-10-02 12:30:22 +0000
commit2878008c10a8624b5244d7ec4eb6bfcc0344fc2f (patch)
tree95bf8853e5e185d69bd93cf4486bd943ea2c2fcd
parentfb5e9b9f26d84028db8f8df395339d0932912e9d (diff)
downloadslapt-get-2878008c10a8624b5244d7ec4eb6bfcc0344fc2f.tar.gz
fix for pkg cmp routine where pkgs with 3 version parts where not found to be greater than pkgs with 2 version parts
version increase to 0.9.5b
-rw-r--r--ChangeLog4
-rw-r--r--Makefile2
-rw-r--r--src/package.c21
3 files changed, 19 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d94606a..5f239e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
+0.9.5b Oct 02, 2003
+ * yet another improvement to pkg version checking, xspace pointed
+ out another example of how pkg versions might slip through cmp routine.
+
0.9.5 Oct 01, 2003
* fixed pkg name so that slack-desc shows up... wasn't following
new package naming convention. Thanks Luke Yelavich <luke@audioslack.com>
diff --git a/Makefile b/Makefile
index 56786a2..3215a56 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
PROGRAM_NAME=slapt-get
-VERSION=0.9.5
+VERSION=0.9.5b
ARCH=i386
RELEASE=1
CC=gcc
diff --git a/src/package.c b/src/package.c
index 993492c..c4fa9b3 100644
--- a/src/package.c
+++ b/src/package.c
@@ -639,12 +639,13 @@ void get_md5sum(const rc_config *global_config,pkg_info_t *pkg,char *md5_sum){
int cmp_pkg_versions(char *a, char *b){
int ver_breakdown_1[] = { 0, 0, 0, 0 };
int ver_breakdown_2[] = { 0, 0, 0, 0 };
- int count1,count2,position = 0,greater = 1,lesser = -1;
+ int version_part_count1,version_part_count2,position = 0;
+ int greater = 1,lesser = -1;
- count1 = break_down_pkg_version(ver_breakdown_1,a);
- count2 = break_down_pkg_version(ver_breakdown_2,b);
+ version_part_count1 = break_down_pkg_version(ver_breakdown_1,a);
+ version_part_count2 = break_down_pkg_version(ver_breakdown_2,b);
- while( position < count1 && position < count2 ){
+ while( position < version_part_count1 && position < version_part_count2 ){
if( ver_breakdown_1[position] != ver_breakdown_2[position] ){
if( ver_breakdown_1[position] < ver_breakdown_2[position] )
@@ -657,9 +658,15 @@ int cmp_pkg_versions(char *a, char *b){
++position;
}
- /* if the integer version of each package is equal,
- we fall back on strcmp */
- return strcmp(a,b);
+ /*
+ * if we got this far, we know that some or all of the version
+ * parts are equal in both packages. If pkg-a has 3 version parts
+ * and pkg-b has 2, then we assume pkg-a to be greater. If both
+ * have the same # of version parts, then we fall back on strcmp.
+ */
+ return (version_part_count1 != version_part_count2)
+ ? ( (version_part_count1 > version_part_count2) ? greater : lesser )
+ : strcmp(a,b);
}
int break_down_pkg_version(int *v,char *version){