summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/version.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/version.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/version.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/version.cpp b/noncore/settings/aqpkg/version.cpp
index 59e6f3f..ce2de7b 100644
--- a/noncore/settings/aqpkg/version.cpp
+++ b/noncore/settings/aqpkg/version.cpp
@@ -1,137 +1,137 @@
1/* 1/*
2 * libdpkg - Debian packaging suite library routines 2 * libdpkg - Debian packaging suite library routines
3 * vercmp.c - comparison of version numbers 3 * vercmp.c - comparison of version numbers
4 * 4 *
5 * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> 5 * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
6 * 6 *
7 * This is free software; you can redistribute it and/or modify 7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as 8 * it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2, 9 * published by the Free Software Foundation; either version 2,
10 * or (at your option) any later version. 10 * or (at your option) any later version.
11 * 11 *
12 * This is distributed in the hope that it will be useful, but 12 * This is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public 17 * You should have received a copy of the GNU General Public
18 * License along with dpkg; if not, write to the Free Software 18 * License along with dpkg; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <ctype.h> 23#include <ctype.h>
24#include <string.h> 24#include <string.h>
25 25
26#include <qobject.h> 26#include <qobject.h>
27 27
28//# define _(Text) Text 28//# define _(Text) Text
29 29
30class versionrevision 30class versionrevision
31{ 31{
32public: 32public:
33 versionrevision() 33 versionrevision()
34 { 34 {
35 version = 0; 35 version = 0;
36 } 36 }
37 37
38 ~versionrevision() 38 ~versionrevision()
39 { 39 {
40 if ( version ) 40 if ( version )
41 delete version; 41 delete [] version;
42 } 42 }
43 43
44 void setVersion( const char *str ) 44 void setVersion( const char *str )
45 { 45 {
46 version = new char[(strlen(str)+1)]; 46 version = new char[(strlen(str)+1)];
47 strcpy( version, str ); 47 strcpy( version, str );
48 } 48 }
49 49
50 unsigned long epoch; 50 unsigned long epoch;
51 char *version; 51 char *version;
52 const char *revision; 52 const char *revision;
53 const char *familiar_revision; 53 const char *familiar_revision;
54}; 54};
55 55
56static int verrevcmp(const char *val, const char *ref) 56static int verrevcmp(const char *val, const char *ref)
57{ 57{
58 int vc, rc; 58 int vc, rc;
59 long vl, rl; 59 long vl, rl;
60 const char *vp, *rp; 60 const char *vp, *rp;
61 61
62 if (!val) val= ""; 62 if (!val) val= "";
63 if (!ref) ref= ""; 63 if (!ref) ref= "";
64 for (;;) { 64 for (;;) {
65 vp= val; while (*vp && !isdigit(*vp)) vp++; 65 vp= val; while (*vp && !isdigit(*vp)) vp++;
66 rp= ref; while (*rp && !isdigit(*rp)) rp++; 66 rp= ref; while (*rp && !isdigit(*rp)) rp++;
67 for (;;) { 67 for (;;) {
68 vc= val == vp ? 0 : *val++; 68 vc= val == vp ? 0 : *val++;
69 rc= ref == rp ? 0 : *ref++; 69 rc= ref == rp ? 0 : *ref++;
70 if (!rc && !vc) break; 70 if (!rc && !vc) break;
71 if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ 71 if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
72 if (rc && !isalpha(rc)) rc += 256; 72 if (rc && !isalpha(rc)) rc += 256;
73 if (vc != rc) return vc - rc; 73 if (vc != rc) return vc - rc;
74 } 74 }
75 val= vp; 75 val= vp;
76 ref= rp; 76 ref= rp;
77 vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); 77 vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
78 rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); 78 rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
79 if (vl != rl) return vl - rl; 79 if (vl != rl) return vl - rl;
80 if (!*val && !*ref) return 0; 80 if (!*val && !*ref) return 0;
81 if (!*val) return -1; 81 if (!*val) return -1;
82 if (!*ref) return +1; 82 if (!*ref) return +1;
83 } 83 }
84} 84}
85 85
86int versioncompare(const struct versionrevision *version, 86int versioncompare(const struct versionrevision *version,
87 const struct versionrevision *refversion) 87 const struct versionrevision *refversion)
88{ 88{
89 int r; 89 int r;
90 90
91 if (version->epoch > refversion->epoch) return 1; 91 if (version->epoch > refversion->epoch) return 1;
92 if (version->epoch < refversion->epoch) return -1; 92 if (version->epoch < refversion->epoch) return -1;
93 r= verrevcmp(version->version,refversion->version); if (r) return r; 93 r= verrevcmp(version->version,refversion->version); if (r) return r;
94 r= verrevcmp(version->revision,refversion->revision); if (r) return r; 94 r= verrevcmp(version->revision,refversion->revision); if (r) return r;
95 return verrevcmp(version->familiar_revision,refversion->familiar_revision); 95 return verrevcmp(version->familiar_revision,refversion->familiar_revision);
96} 96}
97 97
98int versionsatisfied3(const struct versionrevision *it, 98int versionsatisfied3(const struct versionrevision *it,
99 const struct versionrevision *ref, 99 const struct versionrevision *ref,
100 const char *op) 100 const char *op)
101{ 101{
102 int r; 102 int r;
103 r= versioncompare(it,ref); 103 r= versioncompare(it,ref);
104 if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) 104 if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0)
105 return r <= 0; 105 return r <= 0;
106 if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) 106 if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0)
107 return r >= 0; 107 return r >= 0;
108 if (strcmp(op, "<<") == 0) 108 if (strcmp(op, "<<") == 0)
109 return r < 0; 109 return r < 0;
110 if (strcmp(op, ">>") == 0) 110 if (strcmp(op, ">>") == 0)
111 return r > 0; 111 return r > 0;
112 if (strcmp(op, "=") == 0) 112 if (strcmp(op, "=") == 0)
113 return r == 0; 113 return r == 0;
114// fprintf(stderr, "unknown operator: %s", op); 114// fprintf(stderr, "unknown operator: %s", op);
115 115
116 exit(1); 116 exit(1);
117} 117}
118 118
119const char *parseversion(struct versionrevision *rversion, const char *string) 119const char *parseversion(struct versionrevision *rversion, const char *string)
120{ 120{
121 char *hyphen, *colon, *eepochcolon; 121 char *hyphen, *colon, *eepochcolon;
122 unsigned long epoch; 122 unsigned long epoch;
123 123
124 if ( !*string ) 124 if ( !*string )
125 return QObject::tr( "Version string is empty." ); 125 return QObject::tr( "Version string is empty." );
126 126
127 colon= strchr(string,':'); 127 colon= strchr(string,':');
128 if (colon) { 128 if (colon) {
129 epoch= strtoul(string,&eepochcolon,10); 129 epoch= strtoul(string,&eepochcolon,10);
130 if ( colon != eepochcolon ) 130 if ( colon != eepochcolon )
131 return QObject::tr( "Epoch in version is not number." ); 131 return QObject::tr( "Epoch in version is not number." );
132 if ( !*++colon ) 132 if ( !*++colon )
133 return QObject::tr( "Nothing after colon in version number." ); 133 return QObject::tr( "Nothing after colon in version number." );
134 string= colon; 134 string= colon;
135 rversion->epoch= epoch; 135 rversion->epoch= epoch;
136 } else { 136 } else {
137 rversion->epoch= 0; 137 rversion->epoch= 0;