]>
Commit | Line | Data |
---|---|---|
de6a1a64 RC |
1 | /* |
2 | * Copyright (c) 2000, Red Hat, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by DJ Delorie <dj@cygnus.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | #if 0 | |
17 | static const char *cvsid = | |
18 | "\n%%% $Id$\n"; | |
19 | #endif | |
20 | ||
21 | #include "win32.h" | |
22 | ||
23 | #include <stdio.h> | |
24 | #include <stdlib.h> | |
25 | #include <unistd.h> | |
26 | #include <ctype.h> | |
27 | ||
28 | #include "port.h" | |
3c054baf RC |
29 | #include "version.h" |
30 | ||
31 | String | |
32 | canonicalize_version (String const &aString) | |
de6a1a64 | 33 | { |
3c054baf | 34 | char *v =aString.cstr(); |
931f2755 | 35 | char *savev = v; |
de6a1a64 RC |
36 | static char nv[3][100]; |
37 | static int idx = 0; | |
38 | char *np; | |
39 | const char *dp; | |
40 | int i; | |
41 | ||
42 | idx = (idx + 1) % 3; | |
43 | np = nv[idx]; | |
44 | ||
45 | while (*v) | |
46 | { | |
47 | if (isdigit (*v)) | |
48 | { | |
49 | for (dp = v; *dp && isdigit (*dp); dp++); | |
50 | for (i = dp - v; i < 12; i++) | |
51 | *np++ = '0'; | |
52 | while (v < dp) | |
53 | *np++ = *v++; | |
54 | } | |
55 | else | |
56 | *np++ = *v++; | |
57 | } | |
58 | *np++ = 0; | |
931f2755 | 59 | delete[] savev; |
de6a1a64 RC |
60 | return nv[idx]; |
61 | } |