Diffstat (limited to 'noncore/settings/aqpkg/version.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/version.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/noncore/settings/aqpkg/version.cpp b/noncore/settings/aqpkg/version.cpp index e836da1..59e6f3f 100644 --- a/noncore/settings/aqpkg/version.cpp +++ b/noncore/settings/aqpkg/version.cpp | |||
@@ -14,25 +14,27 @@ | |||
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 | # define _(Text) Text | 26 | #include <qobject.h> |
27 | |||
28 | //# define _(Text) Text | ||
27 | 29 | ||
28 | class versionrevision | 30 | class versionrevision |
29 | { | 31 | { |
30 | public: | 32 | public: |
31 | versionrevision() | 33 | versionrevision() |
32 | { | 34 | { |
33 | version = 0; | 35 | version = 0; |
34 | } | 36 | } |
35 | 37 | ||
36 | ~versionrevision() | 38 | ~versionrevision() |
37 | { | 39 | { |
38 | if ( version ) | 40 | if ( version ) |
@@ -100,41 +102,44 @@ int versionsatisfied3(const struct versionrevision *it, | |||
100 | int r; | 102 | int r; |
101 | r= versioncompare(it,ref); | 103 | r= versioncompare(it,ref); |
102 | if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) | 104 | if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) |
103 | return r <= 0; | 105 | return r <= 0; |
104 | if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) | 106 | if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) |
105 | return r >= 0; | 107 | return r >= 0; |
106 | if (strcmp(op, "<<") == 0) | 108 | if (strcmp(op, "<<") == 0) |
107 | return r < 0; | 109 | return r < 0; |
108 | if (strcmp(op, ">>") == 0) | 110 | if (strcmp(op, ">>") == 0) |
109 | return r > 0; | 111 | return r > 0; |
110 | if (strcmp(op, "=") == 0) | 112 | if (strcmp(op, "=") == 0) |
111 | return r == 0; | 113 | return r == 0; |
112 | fprintf(stderr, "unknown operator: %s", op); | 114 | // fprintf(stderr, "unknown operator: %s", op); |
113 | 115 | ||
114 | exit(1); | 116 | exit(1); |
115 | } | 117 | } |
116 | 118 | ||
117 | const char *parseversion(struct versionrevision *rversion, const char *string) | 119 | const char *parseversion(struct versionrevision *rversion, const char *string) |
118 | { | 120 | { |
119 | char *hyphen, *colon, *eepochcolon; | 121 | char *hyphen, *colon, *eepochcolon; |
120 | unsigned long epoch; | 122 | unsigned long epoch; |
121 | 123 | ||
122 | if (!*string) return _("version string is empty"); | 124 | if ( !*string ) |
125 | return QObject::tr( "Version string is empty." ); | ||
123 | 126 | ||
124 | colon= strchr(string,':'); | 127 | colon= strchr(string,':'); |
125 | if (colon) { | 128 | if (colon) { |
126 | epoch= strtoul(string,&eepochcolon,10); | 129 | epoch= strtoul(string,&eepochcolon,10); |
127 | if (colon != eepochcolon) return _("epoch in version is not number"); | 130 | if ( colon != eepochcolon ) |
128 | if (!*++colon) return _("nothing after colon in version number"); | 131 | return QObject::tr( "Epoch in version is not number." ); |
132 | if ( !*++colon ) | ||
133 | return QObject::tr( "Nothing after colon in version number." ); | ||
129 | string= colon; | 134 | string= colon; |
130 | rversion->epoch= epoch; | 135 | rversion->epoch= epoch; |
131 | } else { | 136 | } else { |
132 | rversion->epoch= 0; | 137 | rversion->epoch= 0; |
133 | } | 138 | } |
134 | 139 | ||
135 | rversion->revision = ""; | 140 | rversion->revision = ""; |
136 | rversion->familiar_revision = ""; | 141 | rversion->familiar_revision = ""; |
137 | 142 | ||
138 | rversion->setVersion( string ); | 143 | rversion->setVersion( string ); |
139 | hyphen= strrchr(rversion->version,'-'); | 144 | hyphen= strrchr(rversion->version,'-'); |
140 | if (hyphen) { | 145 | if (hyphen) { |
@@ -158,31 +163,31 @@ const char *parseversion(struct versionrevision *rversion, const char *string) | |||
158 | rversion->familiar_revision); | 163 | rversion->familiar_revision); |
159 | */ | 164 | */ |
160 | return 0; | 165 | return 0; |
161 | } | 166 | } |
162 | 167 | ||
163 | int compareVersions( const char *v1, const char *v2 ) | 168 | int compareVersions( const char *v1, const char *v2 ) |
164 | { | 169 | { |
165 | const char *err; | 170 | const char *err; |
166 | versionrevision ver, ref; | 171 | versionrevision ver, ref; |
167 | 172 | ||
168 | err = parseversion(&ref, v1); | 173 | err = parseversion(&ref, v1); |
169 | if (err) { | 174 | if (err) { |
170 | fprintf(stderr, "Invalid version `%s': %s\n", v2, err); | 175 | // fprintf(stderr, "Invalid version `%s': %s\n", v2, err); |
171 | return -2; | 176 | return -2; |
172 | } | 177 | } |
173 | 178 | ||
174 | err = parseversion(&ver, v2); | 179 | err = parseversion(&ver, v2); |
175 | if (err) { | 180 | if (err) { |
176 | fprintf(stderr, "Invalid version `%s': %s\n", v1, err); | 181 | // fprintf(stderr, "Invalid version `%s': %s\n", v1, err); |
177 | return -2; | 182 | return -2; |
178 | } | 183 | } |
179 | 184 | ||
180 | if ( versionsatisfied3( &ver, &ref, "=" ) ) | 185 | if ( versionsatisfied3( &ver, &ref, "=" ) ) |
181 | return 0; | 186 | return 0; |
182 | else if ( versionsatisfied3( &ver, &ref, "<" ) ) | 187 | else if ( versionsatisfied3( &ver, &ref, "<" ) ) |
183 | return -1; | 188 | return -1; |
184 | else | 189 | else |
185 | return 1; | 190 | return 1; |
186 | } | 191 | } |
187 | 192 | ||
188 | /* | 193 | /* |