Added
Link Here
|
1 |
--- ./jdk/make/tools/freetypecheck/freetypecheck.c.orig 2016-12-29 23:30:31.000000000 -0500 |
2 |
+++ ./jdk/make/tools/freetypecheck/freetypecheck.c 2019-05-29 18:29:32.876811000 -0400 |
3 |
@@ -32,26 +32,65 @@ |
4 |
#define QUOTEMACRO(x) QUOTEME(x) |
5 |
#define QUOTEME(x) #x |
6 |
|
7 |
+int compare_versions(FT_Int req_major, FT_Int req_minor, FT_Int req_patch, |
8 |
+ FT_Int major, FT_Int minor, FT_Int patch) { |
9 |
+ if (major > req_major) { |
10 |
+ printf("Major version %d greater than required major version %d\n", |
11 |
+ major, req_major); |
12 |
+ return 0; |
13 |
+ } |
14 |
+ if (major < req_major) { |
15 |
+ printf("Major version %d less than required major version %d\n", |
16 |
+ major, req_major); |
17 |
+ return -1; |
18 |
+ } |
19 |
+ printf("Major version %d equal to required major version %d\n", |
20 |
+ major, req_major); |
21 |
+ if (minor > req_minor) { |
22 |
+ printf("Minor version %d greater than required minor version %d\n", |
23 |
+ minor, req_minor); |
24 |
+ return 0; |
25 |
+ } |
26 |
+ if (minor < req_minor) { |
27 |
+ printf("Minor version %d less than required minor version %d\n", |
28 |
+ minor, req_minor); |
29 |
+ return -2; |
30 |
+ } |
31 |
+ printf("Minor version %d equal to required minor version %d\n", |
32 |
+ minor, req_minor); |
33 |
+ if (patch >= req_patch) { |
34 |
+ printf("Patch version %d greater than or equal to required patch version %d\n", |
35 |
+ patch, req_patch); |
36 |
+ return 0; |
37 |
+ } |
38 |
+ printf("Patch version %d less than required patch version %d\n", |
39 |
+ patch, req_patch); |
40 |
+ return -3; |
41 |
+} |
42 |
+ |
43 |
int main(int argc, char** argv) { |
44 |
- char v[50]; |
45 |
- FT_Int major, minor, patch; |
46 |
+ FT_Int major, minor, patch, req_major, req_minor, req_patch; |
47 |
FT_Library library; |
48 |
- sprintf(v, "%d.%d.%d", FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH); |
49 |
|
50 |
- printf("Required version of freetype: %s\n", |
51 |
- QUOTEMACRO(REQUIRED_FREETYPE_VERSION)); |
52 |
+ sscanf(QUOTEMACRO(REQUIRED_FREETYPE_VERSION), |
53 |
+ "%d.%d.%d", &req_major, &req_minor, &req_patch); |
54 |
+ printf("Required version of freetype: %d.%d.%d\n", |
55 |
+ req_major, req_minor, req_patch); |
56 |
|
57 |
- printf("Detected freetype headers: %s\n", v); |
58 |
- if (strcmp(v, QUOTEMACRO(REQUIRED_FREETYPE_VERSION)) < 0) { |
59 |
+ printf("Detected freetype headers: %d.%d.%d\n", |
60 |
+ FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH); |
61 |
+ if (compare_versions(req_major, req_minor, req_patch, |
62 |
+ FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH) < 0) { |
63 |
printf("Failed: headers are too old.\n"); |
64 |
} |
65 |
|
66 |
FT_Init_FreeType(&library); |
67 |
FT_Library_Version(library, &major, &minor, &patch); |
68 |
- sprintf(v, "%d.%d.%d", major, minor, patch); |
69 |
|
70 |
- printf("Detected freetype library: %s\n", v); |
71 |
- if (strcmp(v, QUOTEMACRO(REQUIRED_FREETYPE_VERSION)) < 0) { |
72 |
+ printf("Detected freetype library: %d.%d.%d\n", |
73 |
+ major, minor, patch); |
74 |
+ if (compare_versions(req_major, req_minor, req_patch, |
75 |
+ major, minor, patch) < 0) { |
76 |
printf("Failed: too old library.\n"); |
77 |
} |
78 |
|