mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-12611 Fix some issues found through static analysis.
X-SVN-Rev: 38937
This commit is contained in:
parent
e6fc703918
commit
5bb1e71bca
12 changed files with 29 additions and 34 deletions
|
@ -31,11 +31,11 @@ public final class CharacterIteration {
|
|||
public static int next32(CharacterIterator ci) {
|
||||
// If the current position is at a surrogate pair, move to the trail surrogate
|
||||
// which leaves it in position for underlying iterator's next() to work.
|
||||
int c= ci.current();
|
||||
int c = ci.current();
|
||||
if (c >= UTF16.LEAD_SURROGATE_MIN_VALUE && c<=UTF16.LEAD_SURROGATE_MAX_VALUE) {
|
||||
c = ci.next();
|
||||
if (c<UTF16.TRAIL_SURROGATE_MIN_VALUE || c>UTF16.TRAIL_SURROGATE_MAX_VALUE) {
|
||||
c = ci.previous();
|
||||
ci.previous();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -570,7 +570,7 @@ public final class ICUBinary {
|
|||
*/
|
||||
public static int readHeader(ByteBuffer bytes, int dataFormat, Authenticate authenticate)
|
||||
throws IOException {
|
||||
assert bytes.position() == 0;
|
||||
assert bytes != null && bytes.position() == 0;
|
||||
byte magic1 = bytes.get(2);
|
||||
byte magic2 = bytes.get(3);
|
||||
if (magic1 != MAGIC1 || magic2 != MAGIC2) {
|
||||
|
|
|
@ -834,7 +834,7 @@ public class Trie2Writable extends Trie2 {
|
|||
|
||||
if (UTRIE2_DEBUG) {
|
||||
/* we saved some space */
|
||||
System.out.printf("compacting UTrie2: count of 32-bit data words %d->%d\n",
|
||||
System.out.printf("compacting UTrie2: count of 32-bit data words %d->%d%n",
|
||||
dataLength, newStart);
|
||||
}
|
||||
|
||||
|
@ -915,7 +915,7 @@ public class Trie2Writable extends Trie2 {
|
|||
|
||||
if (UTRIE2_DEBUG) {
|
||||
/* we saved some space */
|
||||
System.out.printf("compacting UTrie2: count of 16-bit index-2 words %d->%d\n",
|
||||
System.out.printf("compacting UTrie2: count of 16-bit index-2 words %d->%d%n",
|
||||
index2Length, newStart);
|
||||
}
|
||||
|
||||
|
@ -942,7 +942,7 @@ public class Trie2Writable extends Trie2 {
|
|||
this.highStart=localHighStart;
|
||||
|
||||
if (UTRIE2_DEBUG) {
|
||||
System.out.printf("UTrie2: highStart U+%04x highValue 0x%x initialValue 0x%x\n",
|
||||
System.out.printf("UTrie2: highStart U+%04x highValue 0x%x initialValue 0x%x%n",
|
||||
highStart, highValue, initialValue);
|
||||
}
|
||||
|
||||
|
@ -957,7 +957,7 @@ public class Trie2Writable extends Trie2 {
|
|||
compactIndex2();
|
||||
} else {
|
||||
if (UTRIE2_DEBUG) {
|
||||
System.out.printf("UTrie2: highStart U+%04x count of 16-bit index-2 words %d->%d\n",
|
||||
System.out.printf("UTrie2: highStart U+%04x count of 16-bit index-2 words %d->%d%n",
|
||||
highStart, index2Length, UTRIE2_INDEX_1_OFFSET);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,15 +171,17 @@ public abstract class URLHandler {
|
|||
}
|
||||
|
||||
private void process(URLVisitor v, boolean recurse, boolean strip, String path, File[] files) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File f = files[i];
|
||||
|
||||
if (f.isDirectory()) {
|
||||
if (recurse) {
|
||||
process(v, recurse, strip, path + f.getName()+ '/', f.listFiles());
|
||||
if (files != null) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File f = files[i];
|
||||
|
||||
if (f.isDirectory()) {
|
||||
if (recurse) {
|
||||
process(v, recurse, strip, path + f.getName()+ '/', f.listFiles());
|
||||
}
|
||||
} else {
|
||||
v.visit(strip? f.getName() : path + f.getName());
|
||||
}
|
||||
} else {
|
||||
v.visit(strip? f.getName() : path + f.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,14 +141,12 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
|||
//
|
||||
static class iteratedChar {
|
||||
int charValue = 0; // 1-4 bytes from the raw input data
|
||||
int index = 0;
|
||||
int nextIndex = 0;
|
||||
boolean error = false;
|
||||
boolean done = false;
|
||||
|
||||
void reset() {
|
||||
charValue = 0;
|
||||
index = -1;
|
||||
nextIndex = 0;
|
||||
error = false;
|
||||
done = false;
|
||||
|
@ -199,7 +197,6 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
|||
0x838a, 0x838b, 0x838d, 0x8393, 0x8e96, 0x93fa, 0x95aa};
|
||||
|
||||
boolean nextChar(iteratedChar it, CharsetDetector det) {
|
||||
it.index = it.nextIndex;
|
||||
it.error = false;
|
||||
int firstByte;
|
||||
firstByte = it.charValue = it.nextByte(det);
|
||||
|
@ -262,7 +259,6 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
|||
0xbba1, 0xbdd1, 0xc2c4, 0xc3b9, 0xc440, 0xc45f};
|
||||
|
||||
boolean nextChar(iteratedChar it, CharsetDetector det) {
|
||||
it.index = it.nextIndex;
|
||||
it.error = false;
|
||||
int firstByte;
|
||||
firstByte = it.charValue = it.nextByte(det);
|
||||
|
@ -321,7 +317,6 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
|||
* packed into an int.
|
||||
*/
|
||||
boolean nextChar(iteratedChar it, CharsetDetector det) {
|
||||
it.index = it.nextIndex;
|
||||
it.error = false;
|
||||
int firstByte = 0;
|
||||
int secondByte = 0;
|
||||
|
@ -461,7 +456,6 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
|||
* packed into an int.
|
||||
*/
|
||||
boolean nextChar(iteratedChar it, CharsetDetector det) {
|
||||
it.index = it.nextIndex;
|
||||
it.error = false;
|
||||
int firstByte = 0;
|
||||
int secondByte = 0;
|
||||
|
|
|
@ -786,7 +786,8 @@ public class DateIntervalFormat extends UFormat {
|
|||
FieldPosition otherPos = new FieldPosition(pos.getField());
|
||||
fDateFormat.format(secondCal, appendTo, otherPos);
|
||||
if (pos.getEndIndex() == 0 && otherPos.getEndIndex() > 0) {
|
||||
pos = otherPos;
|
||||
pos.setBeginIndex(otherPos.getBeginIndex());
|
||||
pos.setEndIndex(otherPos.getEndIndex());
|
||||
}
|
||||
}
|
||||
fDateFormat.applyPattern(originalPattern);
|
||||
|
|
|
@ -493,7 +493,7 @@ final class NFRuleSet {
|
|||
}
|
||||
|
||||
// if the number isn't an integer, we use one f the fraction rules...
|
||||
if (nonNumericalRules != null && number != Math.floor(number)) {
|
||||
if (number != Math.floor(number)) {
|
||||
if (number < 1 && nonNumericalRules[PROPER_FRACTION_RULE_INDEX] != null) {
|
||||
// if the number is between 0 and 1, return the proper
|
||||
// fraction rule
|
||||
|
|
|
@ -2341,12 +2341,10 @@ public class SpoofChecker {
|
|||
int CFUStringLengthsSize = bytes.getInt();
|
||||
|
||||
int anyCaseTrieOffset = bytes.getInt();
|
||||
@SuppressWarnings("unused")
|
||||
int anyCaseTrieSize = bytes.getInt();
|
||||
/*int anyCaseTrieSize =*/ bytes.getInt();
|
||||
|
||||
int lowerCaseTrieOffset = bytes.getInt();
|
||||
@SuppressWarnings("unused")
|
||||
int lowerCaseTrieLength = bytes.getInt();
|
||||
/*int lowerCaseTrieLength =*/ bytes.getInt();
|
||||
|
||||
int scriptSetsOffset = bytes.getInt();
|
||||
int scriptSetslength = bytes.getInt();
|
||||
|
|
|
@ -37,7 +37,7 @@ class CaseFoldTransliterator extends Transliterator{
|
|||
Transliterator.registerSpecialInverse("CaseFold", "Upper", false);
|
||||
}
|
||||
|
||||
private UCaseProps csp;
|
||||
private final UCaseProps csp;
|
||||
private ReplaceableContextIterator iter;
|
||||
private StringBuilder result;
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ class LowercaseTransliterator extends Transliterator{
|
|||
Transliterator.registerSpecialInverse("Lower", "Upper", true);
|
||||
}
|
||||
|
||||
private ULocale locale;
|
||||
private final ULocale locale;
|
||||
|
||||
private UCaseProps csp;
|
||||
private final UCaseProps csp;
|
||||
private ReplaceableContextIterator iter;
|
||||
private StringBuilder result;
|
||||
private int[] locCache;
|
||||
|
|
|
@ -35,9 +35,9 @@ class TitlecaseTransliterator extends Transliterator {
|
|||
registerSpecialInverse("Title", "Lower", false);
|
||||
}
|
||||
|
||||
private ULocale locale;
|
||||
private final ULocale locale;
|
||||
|
||||
private UCaseProps csp;
|
||||
private final UCaseProps csp;
|
||||
private ReplaceableContextIterator iter;
|
||||
private StringBuilder result;
|
||||
private int[] locCache;
|
||||
|
|
|
@ -35,9 +35,9 @@ class UppercaseTransliterator extends Transliterator {
|
|||
});
|
||||
}
|
||||
|
||||
private ULocale locale;
|
||||
private final ULocale locale;
|
||||
|
||||
private UCaseProps csp;
|
||||
private final UCaseProps csp;
|
||||
private ReplaceableContextIterator iter;
|
||||
private StringBuilder result;
|
||||
private int[] locCache;
|
||||
|
|
Loading…
Add table
Reference in a new issue