blob: d2b56704af19120f743bb7b347528f487e2af5e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/**************************************************************************
* Copyright (C) 2006 by Michel Ludwig ([email protected]) *
***************************************************************************/
/**************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "kileversion.h"
#include <tqstringlist.h>
int compareVersionStrings(const TQString& s1, const TQString& s2) {
TQStringList l1 = TQStringList::split(".", s1);
TQStringList l2 = TQStringList::split(".", s2);
while(l1.size() < 3) {
l1.push_back("0");
}
while(l2.size() < 3) {
l2.push_back("0");
}
TQStringList::iterator i1 = l1.begin();
TQStringList::iterator i2 = l2.begin();
for(unsigned int i = 0; i < 3; ++i) {
unsigned int c1 = (*i1).toUInt();
unsigned int c2 = (*i2).toUInt();
if(c1 < c2) {
return -1;
}
else if(c1 > c2) {
return 1;
}
++i1;
++i2;
}
return 0;
}
|