OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 2013-2014, International Business Machines | 3 * Copyright (C) 2013-2015, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 * collationinfo.cpp | 6 * collationinfo.cpp |
7 * | 7 * |
8 * created on: 2013aug05 | 8 * created on: 2013aug05 |
9 * created by: Markus W. Scherer | 9 * created by: Markus W. Scherer |
10 */ | 10 */ |
11 | 11 |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <string.h> | 13 #include <string.h> |
14 | 14 |
15 #include "unicode/utypes.h" | 15 #include "unicode/utypes.h" |
16 | 16 |
17 #if !UCONFIG_NO_COLLATION | 17 #if !UCONFIG_NO_COLLATION |
18 | 18 |
| 19 #include "collationdata.h" |
19 #include "collationdatareader.h" | 20 #include "collationdatareader.h" |
20 #include "collationinfo.h" | 21 #include "collationinfo.h" |
21 #include "uassert.h" | 22 #include "uassert.h" |
| 23 #include "uvectr32.h" |
22 | 24 |
23 U_NAMESPACE_BEGIN | 25 U_NAMESPACE_BEGIN |
24 | 26 |
25 void | 27 void |
26 CollationInfo::printSizes(int32_t sizeWithHeader, const int32_t indexes[]) { | 28 CollationInfo::printSizes(int32_t sizeWithHeader, const int32_t indexes[]) { |
27 int32_t totalSize = indexes[CollationDataReader::IX_TOTAL_SIZE]; | 29 int32_t totalSize = indexes[CollationDataReader::IX_TOTAL_SIZE]; |
28 if(sizeWithHeader > totalSize) { | 30 if(sizeWithHeader > totalSize) { |
29 printf(" header size: %6ld\n", (long)(sizeWithHeader -
totalSize)); | 31 printf(" header size: %6ld\n", (long)(sizeWithHeader -
totalSize)); |
30 } | 32 } |
31 | 33 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 107 } |
106 | 108 |
107 printf(" collator binary total size: %6ld\n", (long)sizeWithHeader); | 109 printf(" collator binary total size: %6ld\n", (long)sizeWithHeader); |
108 } | 110 } |
109 | 111 |
110 int32_t | 112 int32_t |
111 CollationInfo::getDataLength(const int32_t indexes[], int32_t startIndex) { | 113 CollationInfo::getDataLength(const int32_t indexes[], int32_t startIndex) { |
112 return indexes[startIndex + 1] - indexes[startIndex]; | 114 return indexes[startIndex + 1] - indexes[startIndex]; |
113 } | 115 } |
114 | 116 |
| 117 void |
| 118 CollationInfo::printReorderRanges(const CollationData &data, const int32_t *code
s, int32_t length) { |
| 119 UErrorCode errorCode = U_ZERO_ERROR; |
| 120 UVector32 ranges(errorCode); |
| 121 data.makeReorderRanges(codes, length, ranges, errorCode); |
| 122 if(U_FAILURE(errorCode)) { |
| 123 printf(" error building reorder ranges: %s\n", u_errorName(errorCode)); |
| 124 return; |
| 125 } |
| 126 |
| 127 int32_t start = 0; |
| 128 for(int32_t i = 0; i < ranges.size(); ++i) { |
| 129 int32_t pair = ranges.elementAti(i); |
| 130 int32_t limit = (pair >> 16) & 0xffff; |
| 131 int16_t offset = (int16_t)pair; |
| 132 if(offset == 0) { |
| 133 // [inclusive-start, exclusive-limit[ |
| 134 printf(" [%04x, %04x[\n", start, limit); |
| 135 } else if(offset > 0) { |
| 136 printf(" reorder [%04x, %04x[ by offset %02x to [%04x, %04x[\n", |
| 137 start, limit, offset, |
| 138 start + (offset << 8), limit + (offset << 8)); |
| 139 } else /* offset < 0 */ { |
| 140 printf(" reorder [%04x, %04x[ by offset -%02x to [%04x, %04x[\n", |
| 141 start, limit, -offset, |
| 142 start + (offset << 8), limit + (offset << 8)); |
| 143 } |
| 144 start = limit; |
| 145 } |
| 146 } |
| 147 |
115 U_NAMESPACE_END | 148 U_NAMESPACE_END |
116 | 149 |
117 #endif // !UCONFIG_NO_COLLATION | 150 #endif // !UCONFIG_NO_COLLATION |
OLD | NEW |