ICU-12611 Fix some issues found through static analysis.
X-SVN-Rev: 38935
This commit is contained in:
parent
edbdac6318
commit
3fe7709485
@ -688,7 +688,6 @@ class CharsetBOCU1 extends CharsetICU {
|
||||
int sourceIndex, nextSourceIndex;
|
||||
int prev, c , diff, count;
|
||||
byte[] bytes;
|
||||
int targetCapacity;
|
||||
CoderResult cr;
|
||||
|
||||
/* label values for supporting behavior similar to goto in C */
|
||||
|
@ -110,7 +110,6 @@ class CharsetISCII extends CharsetICU {
|
||||
|
||||
private final static String ISCII_CNV_PREFIX = "ISCII,version=";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final class UConverterDataISCII {
|
||||
int option;
|
||||
int contextCharToUnicode; /* previous Unicode codepoint for contextual analysis */
|
||||
@ -123,12 +122,10 @@ class CharsetISCII extends CharsetICU {
|
||||
short defMaskToUnicode; /* mask for default state in toUnicode */
|
||||
boolean isFirstBuffer; /* boolean for fromUnicode to see if we need to announce the first script */
|
||||
boolean resetToDefaultToUnicode; /* boolean for reseting to default delta and mask when a newline is encountered */
|
||||
String name;
|
||||
int prevToUnicodeStatus; /* Hold the previous toUnicodeStatus. This is necessary because we may need to know the last two code points. */
|
||||
|
||||
UConverterDataISCII(int option, String name) {
|
||||
UConverterDataISCII(int option) {
|
||||
this.option = option;
|
||||
this.name = name;
|
||||
|
||||
initialize();
|
||||
}
|
||||
@ -766,10 +763,7 @@ class CharsetISCII extends CharsetICU {
|
||||
//get the version number of the ISCII converter
|
||||
int option = Integer.parseInt(icuCanonicalName.substring(14));
|
||||
|
||||
extraInfo = new UConverterDataISCII(
|
||||
option,
|
||||
ISCII_CNV_PREFIX + (option & UCNV_OPTIONS_VERSION_MASK) /* name */
|
||||
);
|
||||
extraInfo = new UConverterDataISCII(option);
|
||||
|
||||
initializePNJSets();
|
||||
}
|
||||
|
@ -237,7 +237,6 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
|
||||
data = new UConverterSharedData(1, null, false, 0);
|
||||
data.dataReader = reader;
|
||||
data.staticData = staticData;
|
||||
data.sharedDataCached = false;
|
||||
|
||||
|
@ -110,8 +110,7 @@ class CharsetSCSU extends CharsetICU{
|
||||
private static final int defineOne=6;
|
||||
// };
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final static class SCSUData{
|
||||
private final static class SCSUData {
|
||||
/* dynamic window offsets, intitialize to default values from initialDynamicOffsets */
|
||||
int toUDynamicOffsets[] = new int[8] ;
|
||||
int fromUDynamicOffsets[] = new int[8] ;
|
||||
@ -121,7 +120,6 @@ class CharsetSCSU extends CharsetICU{
|
||||
short toUState;
|
||||
byte toUQuoteWindow, toUDynamicWindow;
|
||||
short toUByteOne;
|
||||
short toUPadding[];
|
||||
|
||||
/* state machine state - fromUnicode */
|
||||
boolean fromUIsSingleByteMode;
|
||||
|
@ -49,7 +49,7 @@ final class UConverterAlias {
|
||||
|
||||
static byte[] gNormalizedStringTable = null;
|
||||
|
||||
static final String GET_STRING(int idx) {
|
||||
private static final String GET_STRING(int idx) {
|
||||
return extractString(gStringTable, 2 * idx);
|
||||
}
|
||||
|
||||
@ -701,9 +701,6 @@ final class UConverterAlias {
|
||||
|
||||
static int gAvailableConverterCount = 0;
|
||||
|
||||
static byte[] gDefaultConverterNameBuffer; // [MAX_CONVERTER_NAME_LENGTH +
|
||||
// 1]; /* +1 for NULL */
|
||||
|
||||
static String gDefaultConverterName = null;
|
||||
|
||||
// static UBool haveAvailableConverterList(UErrorCode *pErrorCode)
|
||||
@ -762,53 +759,4 @@ final class UConverterAlias {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* default converter name --------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* In order to be really thread-safe, the get function would have to take
|
||||
* a buffer parameter and copy the current string inside a mutex block.
|
||||
* This implementation only tries to be really thread-safe while
|
||||
* setting the name.
|
||||
* It assumes that setting a pointer is atomic.
|
||||
*/
|
||||
|
||||
// U_CFUNC const char * getDefaultName()
|
||||
// static final synchronized String getDefaultName() {
|
||||
// /* local variable to be thread-safe */
|
||||
// String name;
|
||||
//
|
||||
// //agljport:todo umtx_lock(null);
|
||||
// name = gDefaultConverterName;
|
||||
// //agljport:todo umtx_unlock(null);
|
||||
//
|
||||
// if (name == null) {
|
||||
// //UConverter cnv = null;
|
||||
// int length = 0;
|
||||
//
|
||||
// name = CharsetICU.getDefaultCharsetName();
|
||||
//
|
||||
// /* if the name is there, test it out and get the canonical name with options */
|
||||
// if (name != null) {
|
||||
// // cnv = UConverter.open(name);
|
||||
// // name = cnv.getName(cnv);
|
||||
// // TODO: fix me
|
||||
// }
|
||||
//
|
||||
// if (name == null || name.length() == 0 ||/* cnv == null ||*/
|
||||
// length >= gDefaultConverterNameBuffer.length) {
|
||||
// /* Panic time, let's use a fallback. */
|
||||
// name = new String("US-ASCII");
|
||||
// }
|
||||
//
|
||||
// //length=(int32_t)(strlen(name));
|
||||
//
|
||||
// /* Copy the name before we close the converter. */
|
||||
// name = gDefaultConverterName;
|
||||
// }
|
||||
//
|
||||
// return name;
|
||||
// }
|
||||
|
||||
//end bld.c
|
||||
}
|
||||
|
@ -339,7 +339,6 @@ final class UConverterSharedData {
|
||||
return sharedData;
|
||||
}
|
||||
*/
|
||||
UConverterDataReader dataReader = null;
|
||||
|
||||
/*
|
||||
* returns a converter type from a string
|
||||
|
@ -1175,7 +1175,7 @@ public final class StringSearch extends SearchIterator {
|
||||
// * the match limit is a normalization boundary
|
||||
boolean allowMidclusterMatch =
|
||||
breakIterator == null &&
|
||||
nextCEI != null && (((nextCEI.ce_) >>> 32) & 0xFFFF0000L) != 0 &&
|
||||
(((nextCEI.ce_) >>> 32) & 0xFFFF0000L) != 0 &&
|
||||
maxLimit >= lastCEI.highIndex_ && nextCEI.highIndex_ > maxLimit &&
|
||||
(nfd_.hasBoundaryBefore(codePointAt(targetText, maxLimit)) ||
|
||||
nfd_.hasBoundaryAfter(codePointBefore(targetText, maxLimit)));
|
||||
@ -1435,7 +1435,7 @@ public final class StringSearch extends SearchIterator {
|
||||
// * the match limit is a normalization boundary
|
||||
boolean allowMidclusterMatch =
|
||||
breakIterator == null &&
|
||||
nextCEI != null && (((nextCEI.ce_) >>> 32) & 0xFFFF0000L) != 0 &&
|
||||
(((nextCEI.ce_) >>> 32) & 0xFFFF0000L) != 0 &&
|
||||
maxLimit >= lastCEI.highIndex_ && nextCEI.highIndex_ > maxLimit &&
|
||||
(nfd_.hasBoundaryBefore(codePointAt(targetText, maxLimit)) ||
|
||||
nfd_.hasBoundaryAfter(codePointBefore(targetText, maxLimit)));
|
||||
|
@ -895,8 +895,7 @@ public class GlobalizationPreferences implements Freezable<GlobalizationPreferen
|
||||
int index = 0;
|
||||
while (index < result.size()) {
|
||||
ULocale uloc = result.get(index);
|
||||
while (true) {
|
||||
uloc = uloc.getFallback();
|
||||
while ((uloc = uloc.getFallback()) != null) {
|
||||
if (uloc.getLanguage().length() == 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -1417,7 +1417,8 @@ public class ICUResourceBundle extends UResourceBundle {
|
||||
UResourceBundle requested) {
|
||||
WholeBundle wholeBundle = base.wholeBundle;
|
||||
ClassLoader loaderToUse = wholeBundle.loader;
|
||||
String locale = null, keyPath = null;
|
||||
String locale;
|
||||
String keyPath = null;
|
||||
String bundleName;
|
||||
String rpath = wholeBundle.reader.getAlias(_resource);
|
||||
if (aliasesVisited == null) {
|
||||
@ -1473,12 +1474,7 @@ public class ICUResourceBundle extends UResourceBundle {
|
||||
}
|
||||
sub = ICUResourceBundle.findResourceWithFallback(keyPath, bundle, null);
|
||||
}else{
|
||||
if (locale == null) {
|
||||
// {dlf} must use requestor's class loader to get resources from same jar
|
||||
bundle = getBundleInstance(bundleName, "", loaderToUse, false);
|
||||
} else {
|
||||
bundle = getBundleInstance(bundleName, locale, loaderToUse, false);
|
||||
}
|
||||
bundle = getBundleInstance(bundleName, locale, loaderToUse, false);
|
||||
|
||||
int numKeys;
|
||||
if (keyPath != null) {
|
||||
|
@ -218,7 +218,7 @@ public final class ICUResourceBundleReader {
|
||||
// set pool bundle if necessary
|
||||
if (usesPoolBundle) {
|
||||
poolBundleReader = getReader(baseName, "pool", loader);
|
||||
if (!poolBundleReader.isPoolBundle) {
|
||||
if (poolBundleReader == null || !poolBundleReader.isPoolBundle) {
|
||||
throw new IllegalStateException("pool.res is not a pool bundle");
|
||||
}
|
||||
if (poolBundleReader.poolCheckSum != poolCheckSum) {
|
||||
|
@ -578,7 +578,6 @@ public class ICUService extends ICUNotifier {
|
||||
* Return a map from visible ids to factories.
|
||||
*/
|
||||
private Map<String, Factory> getVisibleIDMap() {
|
||||
Map<String, Factory> idcache = this.idcache;
|
||||
synchronized (this) { // or idcache-only lock?
|
||||
if (idcache == null) {
|
||||
try {
|
||||
@ -589,7 +588,7 @@ public class ICUService extends ICUNotifier {
|
||||
Factory f = lIter.previous();
|
||||
f.updateVisibleIDs(mutableMap);
|
||||
}
|
||||
this.idcache = idcache = Collections.unmodifiableMap(mutableMap);
|
||||
this.idcache = Collections.unmodifiableMap(mutableMap);
|
||||
} finally {
|
||||
factoryLock.releaseRead();
|
||||
}
|
||||
|
@ -260,7 +260,9 @@ public class JavaTimeZone extends TimeZone {
|
||||
public TimeZone cloneAsThawed() {
|
||||
JavaTimeZone tz = (JavaTimeZone)super.cloneAsThawed();
|
||||
tz.javatz = (java.util.TimeZone)javatz.clone();
|
||||
tz.javacal = (java.util.GregorianCalendar)javacal.clone();
|
||||
synchronized(javacal) {
|
||||
tz.javacal = (java.util.GregorianCalendar)javacal.clone();
|
||||
}
|
||||
tz.isFrozen = false;
|
||||
return tz;
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ public class OlsonTimeZone extends BasicTimeZone {
|
||||
if (transitionCount > 0) {
|
||||
r = res.get("typeMap");
|
||||
typeMapData = r.getBinary(null);
|
||||
if (typeMapData.length != transitionCount) {
|
||||
if (typeMapData == null || typeMapData.length != transitionCount) {
|
||||
throw new IllegalArgumentException("Invalid Format");
|
||||
}
|
||||
} else {
|
||||
|
@ -170,8 +170,8 @@ public class Relation<K, V> implements Freezable<Relation<K,V>> { // TODO: add ,
|
||||
}
|
||||
|
||||
public void putAll(Map<? extends K, ? extends V> t) {
|
||||
for (K key : t.keySet()) {
|
||||
put(key, t.get(key));
|
||||
for (Map.Entry<? extends K, ? extends V> entry : t.entrySet()) {
|
||||
put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,8 +266,8 @@ public class Relation<K, V> implements Freezable<Relation<K,V>> { // TODO: add ,
|
||||
}
|
||||
|
||||
public Relation<K,V> addAllInverted(Map<V,K> source) {
|
||||
for (V value : source.keySet()) {
|
||||
put(source.get(value), value);
|
||||
for (Map.Entry<V,K> entry : source.entrySet()) {
|
||||
put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -337,4 +337,4 @@ public class Relation<K, V> implements Freezable<Relation<K,V>> { // TODO: add ,
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class StringRange {
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return compareTo((Range)obj) == 0;
|
||||
return this == obj || (obj != null && obj instanceof Range && compareTo((Range)obj) == 0);
|
||||
}
|
||||
public int compareTo(Range that) {
|
||||
int diff = min - that.min;
|
||||
|
@ -106,7 +106,7 @@ public class TimeZoneGenericNames implements Serializable, Freezable<TimeZoneGen
|
||||
}
|
||||
}
|
||||
|
||||
private ULocale _locale;
|
||||
private final ULocale _locale;
|
||||
private TimeZoneNames _tznames;
|
||||
|
||||
private transient volatile boolean _frozen;
|
||||
|
@ -261,7 +261,7 @@ public final class UCharacterName
|
||||
}
|
||||
|
||||
synchronized (m_utilStringBuffer_) {
|
||||
m_utilStringBuffer_.delete(0, m_utilStringBuffer_.length());
|
||||
m_utilStringBuffer_.setLength(0);
|
||||
byte b;
|
||||
char token;
|
||||
for (int i = 0; i < length;) {
|
||||
@ -369,7 +369,7 @@ public final class UCharacterName
|
||||
result = TYPE_NAMES_[type];
|
||||
}
|
||||
synchronized (m_utilStringBuffer_) {
|
||||
m_utilStringBuffer_.delete(0, m_utilStringBuffer_.length());
|
||||
m_utilStringBuffer_.setLength(0);
|
||||
m_utilStringBuffer_.append('<');
|
||||
m_utilStringBuffer_.append(result);
|
||||
m_utilStringBuffer_.append('-');
|
||||
@ -491,7 +491,7 @@ public final class UCharacterName
|
||||
{
|
||||
String result = null;
|
||||
synchronized (m_utilStringBuffer_) {
|
||||
m_utilStringBuffer_.delete(0, m_utilStringBuffer_.length());
|
||||
m_utilStringBuffer_.setLength(0);
|
||||
m_algorithm_[index].appendName(codepoint, m_utilStringBuffer_);
|
||||
result = m_utilStringBuffer_.toString();
|
||||
}
|
||||
@ -820,8 +820,7 @@ public final class UCharacterName
|
||||
int count = 0;
|
||||
for (int factor = m_factor_[i]; factor > 0; -- factor) {
|
||||
synchronized (m_utilStringBuffer_) {
|
||||
m_utilStringBuffer_.delete(0,
|
||||
m_utilStringBuffer_.length());
|
||||
m_utilStringBuffer_.setLength(0);
|
||||
count
|
||||
= UCharacterUtility.getNullTermByteSubString(
|
||||
m_utilStringBuffer_,
|
||||
@ -883,7 +882,7 @@ public final class UCharacterName
|
||||
}
|
||||
|
||||
synchronized (m_utilStringBuffer_) {
|
||||
m_utilStringBuffer_.delete(0, m_utilStringBuffer_.length());
|
||||
m_utilStringBuffer_.setLength(0);
|
||||
int count = 0;
|
||||
int factor;
|
||||
size --;
|
||||
@ -1190,7 +1189,7 @@ public final class UCharacterName
|
||||
) {
|
||||
// index in terms integer index
|
||||
synchronized (m_utilStringBuffer_) {
|
||||
m_utilStringBuffer_.delete(0, m_utilStringBuffer_.length());
|
||||
m_utilStringBuffer_.setLength(0);
|
||||
|
||||
for (int index = m_algorithm_.length - 1; index >= 0; index --)
|
||||
{
|
||||
@ -1523,8 +1522,7 @@ public final class UCharacterName
|
||||
byte tlength = tokenlength[b];
|
||||
if (tlength == 0) {
|
||||
synchronized (m_utilStringBuffer_) {
|
||||
m_utilStringBuffer_.delete(0,
|
||||
m_utilStringBuffer_.length());
|
||||
m_utilStringBuffer_.setLength(0);
|
||||
UCharacterUtility.getNullTermByteSubString(
|
||||
m_utilStringBuffer_, m_tokenstring_,
|
||||
token);
|
||||
|
@ -34,8 +34,7 @@ public final class USerializedSet {
|
||||
|
||||
length=src[srcStart++];
|
||||
|
||||
|
||||
if((length&0x8000) >0) {
|
||||
if ((length&0x8000) != 0) {
|
||||
/* there are supplementary values */
|
||||
length&=0x7fff;
|
||||
if(src.length<(srcStart+1+length)) {
|
||||
|
@ -174,7 +174,8 @@ public class CharSequences {
|
||||
*/
|
||||
@Deprecated
|
||||
public static int compare(int codepoint, CharSequence a) {
|
||||
return -compare(a, codepoint);
|
||||
int result = compare(a, codepoint);
|
||||
return result > 0 ? -1 : result < 0 ? 1 : 0; // Reverse the order.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,28 +105,28 @@ public final class ArabicShaping {
|
||||
") for buffer of length " + dest.length);
|
||||
}
|
||||
/* Validate input options */
|
||||
if ( ((options&TASHKEEL_MASK) > 0) &&
|
||||
if ( ((options&TASHKEEL_MASK) != 0) &&
|
||||
!(((options & TASHKEEL_MASK)==TASHKEEL_BEGIN) ||
|
||||
((options & TASHKEEL_MASK)==TASHKEEL_END ) ||
|
||||
((options & TASHKEEL_MASK)==TASHKEEL_RESIZE )||
|
||||
((options & TASHKEEL_MASK)==TASHKEEL_REPLACE_BY_TATWEEL)) ){
|
||||
((options & TASHKEEL_MASK)==TASHKEEL_END) ||
|
||||
((options & TASHKEEL_MASK)==TASHKEEL_RESIZE) ||
|
||||
((options & TASHKEEL_MASK)==TASHKEEL_REPLACE_BY_TATWEEL))) {
|
||||
throw new IllegalArgumentException("Wrong Tashkeel argument");
|
||||
}
|
||||
|
||||
///CLOVER:OFF
|
||||
//According to Steven Loomis, the code is unreachable when you OR all the constants within the if statements
|
||||
if(((options&LAMALEF_MASK) > 0)&&
|
||||
if(((options&LAMALEF_MASK) != 0) &&
|
||||
!(((options & LAMALEF_MASK)==LAMALEF_BEGIN) ||
|
||||
((options & LAMALEF_MASK)==LAMALEF_END ) ||
|
||||
((options & LAMALEF_MASK)==LAMALEF_RESIZE )||
|
||||
((options & LAMALEF_MASK)==LAMALEF_AUTO) ||
|
||||
((options & LAMALEF_MASK)==LAMALEF_NEAR))){
|
||||
((options & LAMALEF_MASK)==LAMALEF_END) ||
|
||||
((options & LAMALEF_MASK)==LAMALEF_RESIZE) ||
|
||||
((options & LAMALEF_MASK)==LAMALEF_AUTO) ||
|
||||
((options & LAMALEF_MASK)==LAMALEF_NEAR))) {
|
||||
throw new IllegalArgumentException("Wrong Lam Alef argument");
|
||||
}
|
||||
///CLOVER:ON
|
||||
|
||||
/* Validate Tashkeel (Tashkeel replacement options should be enabled in shaping mode only)*/
|
||||
if(((options&TASHKEEL_MASK) > 0) && (options&LETTERS_MASK) == LETTERS_UNSHAPE) {
|
||||
if(((options&TASHKEEL_MASK) != 0) && (options&LETTERS_MASK) == LETTERS_UNSHAPE) {
|
||||
throw new IllegalArgumentException("Tashkeel replacement should not be enabled in deshaping mode ");
|
||||
}
|
||||
return internalShape(source, sourceStart, sourceLength, dest, destStart, destSize);
|
||||
@ -1689,8 +1689,8 @@ public final class ArabicShaping {
|
||||
int nw = 0;
|
||||
|
||||
while (i >= 0) {
|
||||
// If high byte of currLink > 0 then there might be more than one shape
|
||||
if ((currLink & '\uFF00') > 0 || isTashkeelChar(dest[i])) {
|
||||
// If high byte of currLink != 0 then there might be more than one shape
|
||||
if ((currLink & '\uFF00') != 0 || isTashkeelChar(dest[i])) {
|
||||
nw = i - 1;
|
||||
nx = -2;
|
||||
while (nx < 0) { // we need to know about next char
|
||||
@ -1871,7 +1871,7 @@ public final class ArabicShaping {
|
||||
break;
|
||||
|
||||
case LETTERS_SHAPE:
|
||||
if( ((options&TASHKEEL_MASK)> 0) &&
|
||||
if( ((options&TASHKEEL_MASK) != 0) &&
|
||||
((options&TASHKEEL_MASK) !=TASHKEEL_REPLACE_BY_TATWEEL)) {
|
||||
/* Call the shaping function with tashkeel flag == 2 for removal of tashkeel */
|
||||
outputSize = shapeUnicode(temp, 0, sourceLength, destSize, 2);
|
||||
|
@ -529,7 +529,6 @@ public class Bidi {
|
||||
int contextPos; /* position of last strong char found before opening */
|
||||
short flags; /* bits for L or R/AL found within the pair */
|
||||
byte contextDir; /* L or R according to last strong char before opening */
|
||||
byte filler; /* to complete a nice multiple of 4 bytes */
|
||||
}
|
||||
|
||||
static class IsoRun {
|
||||
|
@ -44,7 +44,6 @@ class CjkBreakEngine extends DictionaryBreakEngine {
|
||||
setCharacters(fHangulWordSet);
|
||||
} else { //Chinese and Japanese
|
||||
UnicodeSet cjSet = new UnicodeSet();
|
||||
cjSet = new UnicodeSet();
|
||||
cjSet.addAll(fHanWordSet);
|
||||
cjSet.addAll(fKatakanaWordSet);
|
||||
cjSet.addAll(fHiraganaWordSet);
|
||||
|
@ -245,10 +245,10 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public boolean equals(Object a) {
|
||||
if ( a instanceof PatternInfo ) {
|
||||
if (a instanceof PatternInfo) {
|
||||
PatternInfo patternInfo = (PatternInfo)a;
|
||||
return Utility.objectEquals(fIntervalPatternFirstPart, patternInfo.fIntervalPatternFirstPart) &&
|
||||
Utility.objectEquals(fIntervalPatternSecondPart, fIntervalPatternSecondPart) &&
|
||||
Utility.objectEquals(fIntervalPatternSecondPart, patternInfo.fIntervalPatternSecondPart) &&
|
||||
fFirstDateInPtnIsLaterDate == patternInfo.fFirstDateInPtnIsLaterDate;
|
||||
}
|
||||
return false;
|
||||
|
@ -2068,14 +2068,15 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
MISSING_FIELD = 0x1000;
|
||||
|
||||
|
||||
static private String getName(String s) {
|
||||
private static String getName(String s) {
|
||||
int i = getCanonicalIndex(s, true);
|
||||
String name = FIELD_NAME[types[i][1]];
|
||||
int subtype = types[i][2];
|
||||
boolean string = subtype < 0;
|
||||
if (string) subtype = -subtype;
|
||||
if (subtype < 0) name += ":S";
|
||||
else name += ":N";
|
||||
if (types[i][2] < 0) {
|
||||
name += ":S"; // string
|
||||
}
|
||||
else {
|
||||
name += ":N";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -2321,10 +2322,8 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) { return true; }
|
||||
if (other == null) { return false; }
|
||||
SkeletonFields _other = (SkeletonFields) other;
|
||||
return Arrays.equals(chars, _other.chars) && Arrays.equals(lengths, _other.lengths);
|
||||
return this == other || (other != null && other instanceof SkeletonFields
|
||||
&& compareTo((SkeletonFields) other) == 0);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
@ -2448,14 +2447,13 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
}
|
||||
|
||||
public int compareTo(DateTimeMatcher that) {
|
||||
return -original.compareTo(that.original);
|
||||
int result = original.compareTo(that.original);
|
||||
return result > 0 ? -1 : result < 0 ? 1 : 0; // Reverse the order.
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) { return true; }
|
||||
if (other == null) { return false; }
|
||||
DateTimeMatcher _other = (DateTimeMatcher) other;
|
||||
return original.equals(_other.original);
|
||||
return this == other || (other != null && other instanceof DateTimeMatcher
|
||||
&& original.equals(((DateTimeMatcher) other).original));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
@ -345,6 +345,12 @@ public abstract class LocaleDisplayNames {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || !(obj instanceof UiListItem)) {
|
||||
return false;
|
||||
}
|
||||
UiListItem other = (UiListItem)obj;
|
||||
return nameInDisplayLocale.equals(other.nameInDisplayLocale)
|
||||
&& nameInSelf.equals(other.nameInSelf)
|
||||
|
@ -1111,7 +1111,7 @@ public class MeasureFormat extends UFormat {
|
||||
return positive ? ((DecimalFormat)nf).getPositivePrefix() : ((DecimalFormat)nf).getNegativePrefix();
|
||||
}
|
||||
public String getSuffix(boolean positive) {
|
||||
return positive ? ((DecimalFormat)nf).getPositiveSuffix() : ((DecimalFormat)nf).getPositiveSuffix();
|
||||
return positive ? ((DecimalFormat)nf).getPositiveSuffix() : ((DecimalFormat)nf).getNegativeSuffix();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1277,7 +1277,7 @@ final class NFRule {
|
||||
*/
|
||||
private boolean allIgnorable(String str) {
|
||||
// if the string is empty, we can just return true
|
||||
if (str.length() == 0) {
|
||||
if (str == null || str.length() == 0) {
|
||||
return true;
|
||||
}
|
||||
RbnfLenientScanner scanner = formatter.getLenientScanner();
|
||||
|
@ -506,7 +506,7 @@ final class NFRuleSet {
|
||||
}
|
||||
|
||||
// if there's a master rule, use it to format the number
|
||||
if (nonNumericalRules != null && nonNumericalRules[MASTER_RULE_INDEX] != null) {
|
||||
if (nonNumericalRules[MASTER_RULE_INDEX] != null) {
|
||||
return nonNumericalRules[MASTER_RULE_INDEX];
|
||||
}
|
||||
else {
|
||||
|
@ -48,8 +48,6 @@ class RBBIRuleScanner {
|
||||
|
||||
RBBIRuleChar fC = new RBBIRuleChar(); // Current char for parse state machine
|
||||
// processing.
|
||||
String fVarName; // $variableName, valid when we've just
|
||||
// scanned one.
|
||||
|
||||
|
||||
short fStack[] = new short[kStackSize]; // State stack, holds state pushes
|
||||
|
@ -124,7 +124,7 @@ class RBBISetBuilder {
|
||||
RangeDescriptor fRangeList; // Head of the linked list of RangeDescriptors
|
||||
|
||||
IntTrieBuilder fTrie; // The mapping TRIE that is the end result of processing
|
||||
int fTrieSize; // the Unicode Sets.
|
||||
// the Unicode Sets.
|
||||
|
||||
// Groups correspond to character categories -
|
||||
// groups of ranges that are in the same original UnicodeSets.
|
||||
|
@ -601,12 +601,16 @@ public class SpoofChecker {
|
||||
// setAllowedLocales.
|
||||
private void addScriptChars(ULocale locale, UnicodeSet allowedChars) {
|
||||
int scripts[] = UScript.getCode(locale);
|
||||
UnicodeSet tmpSet = new UnicodeSet();
|
||||
int i;
|
||||
for (i = 0; i < scripts.length; i++) {
|
||||
tmpSet.applyIntPropertyValue(UProperty.SCRIPT, scripts[i]);
|
||||
allowedChars.addAll(tmpSet);
|
||||
if (scripts != null) {
|
||||
UnicodeSet tmpSet = new UnicodeSet();
|
||||
for (int i = 0; i < scripts.length; i++) {
|
||||
tmpSet.applyIntPropertyValue(UProperty.SCRIPT, scripts[i]);
|
||||
allowedChars.addAll(tmpSet);
|
||||
}
|
||||
}
|
||||
// else it's an unknown script.
|
||||
// Maybe they asked for the script of "zxx", which refers to no linguistic content.
|
||||
// Maybe they asked for the script of a newer locale that we don't know in the older version of ICU.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,8 +227,6 @@ public final class StringPrep {
|
||||
private int[] indexes;
|
||||
// mapping data read from the data file
|
||||
private char[] mappingData;
|
||||
// format version of the data file
|
||||
//private byte[] formatVersion;
|
||||
// the version of Unicode supported by the data file
|
||||
private VersionInfo sprepUniVer;
|
||||
// the Unicode version of last entry in the
|
||||
@ -287,9 +285,6 @@ public final class StringPrep {
|
||||
// load the rest of the data data and initialize the data members
|
||||
mappingData = reader.read(indexes[INDEX_MAPPING_DATA_SIZE]/2);
|
||||
|
||||
// get the data format version
|
||||
/*formatVersion = */reader.getDataFormatVersion();
|
||||
|
||||
// get the options
|
||||
doNFKC = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
|
||||
checkBiDi = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
|
||||
|
@ -529,7 +529,7 @@ public class TimeUnitFormat extends MeasureFormat {
|
||||
// then search the units resource fallback from the current level to root
|
||||
if (parentLocale == null && resourceKey.equals("unitsShort")) {
|
||||
searchInTree("units", styl, timeUnit, srcPluralCount, searchPluralCount, countToPatterns);
|
||||
if (countToPatterns != null && countToPatterns.get(srcPluralCount) != null
|
||||
if (countToPatterns.get(srcPluralCount) != null
|
||||
&& countToPatterns.get(srcPluralCount)[styl] != null) {
|
||||
return;
|
||||
}
|
||||
|
@ -4512,7 +4512,8 @@ public class UnicodeSet extends UnicodeFilter implements Iterable<String>, Compa
|
||||
if (o.list[i] == HIGH) {
|
||||
if (o.strings.isEmpty()) return -1;
|
||||
String item = o.strings.first();
|
||||
return -compare(item, list[i]);
|
||||
int compareResult = compare(item, list[i]);
|
||||
return compareResult > 0 ? -1 : compareResult < 0 ? 1 : 0; // Reverse the order.
|
||||
}
|
||||
// otherwise return the result if even index, or the reversal if not
|
||||
return (i & 1) == 0 ? result : -result;
|
||||
|
@ -55,7 +55,7 @@ public class AnnualTimeZoneRule extends TimeZoneRule {
|
||||
super(name, rawOffset, dstSavings);
|
||||
this.dateTimeRule = dateTimeRule;
|
||||
this.startYear = startYear;
|
||||
this.endYear = endYear > MAX_YEAR ? MAX_YEAR : endYear;
|
||||
this.endYear = endYear;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@ public class ByteArrayWrapper implements Comparable<ByteArrayWrapper>
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public ByteArrayWrapper(byte[] bytesToAdopt, int size) {
|
||||
if ((bytesToAdopt == null && size != 0) || size < 0 || size > bytesToAdopt.length) {
|
||||
if ((bytesToAdopt == null && size != 0) || size < 0 || (bytesToAdopt != null && size > bytesToAdopt.length)) {
|
||||
throw new IndexOutOfBoundsException("illegal size: " + size);
|
||||
}
|
||||
this.bytes = bytesToAdopt;
|
||||
@ -115,7 +115,9 @@ public class ByteArrayWrapper implements Comparable<ByteArrayWrapper>
|
||||
{
|
||||
if (bytes == null || bytes.length < capacity) {
|
||||
byte[] newbytes = new byte[capacity];
|
||||
copyBytes(bytes, 0, newbytes, 0, size);
|
||||
if (bytes != null) {
|
||||
copyBytes(bytes, 0, newbytes, 0, size);
|
||||
}
|
||||
bytes = newbytes;
|
||||
}
|
||||
return this;
|
||||
|
@ -770,7 +770,7 @@ public class GregorianCalendar extends Calendar {
|
||||
eyear = (int) floorDivide(4*julianEpochDay + 1464, 1461);
|
||||
|
||||
// Compute the Julian calendar day number for January 1, eyear
|
||||
long january1 = 365*(eyear-1) + floorDivide(eyear-1, 4);
|
||||
long january1 = 365L*(eyear-1L) + floorDivide(eyear-1L, 4L);
|
||||
dayOfYear = (int)(julianEpochDay - january1); // 0-based
|
||||
|
||||
// Julian leap years occurred historically every 4 years starting
|
||||
|
@ -450,11 +450,7 @@ public class IndianCalendar extends Calendar {
|
||||
month %= 12;
|
||||
}
|
||||
|
||||
if(month == 12) {
|
||||
imonth = 1;
|
||||
} else {
|
||||
imonth = month +1;
|
||||
}
|
||||
imonth = month + 1;
|
||||
|
||||
double jd = IndianToJD(year ,imonth, 1);
|
||||
|
||||
|
@ -738,7 +738,7 @@ public class IslamicCalendar extends Calendar {
|
||||
*/
|
||||
protected int handleGetMonthLength(int extendedYear, int month) {
|
||||
|
||||
int length = 0;
|
||||
int length;
|
||||
|
||||
if (cType == CalculationType.ISLAMIC_CIVIL
|
||||
|| cType == CalculationType.ISLAMIC_TBLA
|
||||
@ -747,16 +747,20 @@ public class IslamicCalendar extends Calendar {
|
||||
if (month == DHU_AL_HIJJAH && civilLeapYear(extendedYear)) {
|
||||
length++;
|
||||
}
|
||||
} else if (cType == CalculationType.ISLAMIC) {
|
||||
}
|
||||
else if (cType == CalculationType.ISLAMIC) {
|
||||
month = 12*(extendedYear-1) + month;
|
||||
length = (int)( trueMonthStart(month+1) - trueMonthStart(month) );
|
||||
}else if (cType == CalculationType.ISLAMIC_UMALQURA){
|
||||
}
|
||||
else { // cType == CalculationType.ISLAMIC_UMALQURA should be true at this point and not null.
|
||||
int idx = (extendedYear - UMALQURA_YEAR_START); // calculate year offset into bit map array
|
||||
int mask = (0x01 << (11 - month)); // set mask for bit corresponding to month
|
||||
if((UMALQURA_MONTHLENGTH[idx] & mask) == 0 )
|
||||
if((UMALQURA_MONTHLENGTH[idx] & mask) == 0 ) {
|
||||
length = 29;
|
||||
else
|
||||
}
|
||||
else {
|
||||
length = 30;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
@ -460,6 +460,12 @@ public class LocaleMatcher {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || !(obj instanceof LocalePatternMatcher)) {
|
||||
return false;
|
||||
}
|
||||
LocalePatternMatcher other = (LocalePatternMatcher) obj;
|
||||
return Utility.objectEquals(level, other.level)
|
||||
&& Utility.objectEquals(lang, other.lang)
|
||||
@ -665,21 +671,6 @@ public class LocaleMatcher {
|
||||
return 1.0 - diff;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an exceptional distance between languages, typically because regional
|
||||
* dialects were given their own language codes. At this point the code is
|
||||
* symmetric. We don't bother producing an equivalence class because there are
|
||||
* so few cases; this function depends on the other permutations being
|
||||
* added specifically.
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
private LanguageMatcherData addDistance(String desired, String supported, int percent) {
|
||||
return addDistance(desired, supported, percent, false, null);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
|
@ -352,7 +352,8 @@ public class LocalePriorityList implements Iterable<ULocale> {
|
||||
|
||||
private static Comparator<Double> myDescendingDouble = new Comparator<Double>() {
|
||||
public int compare(Double o1, Double o2) {
|
||||
return -o1.compareTo(o2);
|
||||
int result = o1.compareTo(o2);
|
||||
return result > 0 ? -1 : result < 0 ? 1 : 0; // Reverse the order.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ public class PersianCalendar extends Calendar {
|
||||
long daysSinceEpoch = julianDay - PERSIAN_EPOCH;
|
||||
year = 1 + (int) floorDivide(33 * daysSinceEpoch + 3, 12053);
|
||||
|
||||
long farvardin1 = 365 * (year - 1) + floorDivide(8 * year + 21, 33);
|
||||
long farvardin1 = 365L * (year - 1L) + floorDivide(8L * year + 21, 33L);
|
||||
dayOfYear = (int)(daysSinceEpoch - farvardin1); // 0-based
|
||||
if (dayOfYear < 216) { // Compute 0-based month
|
||||
month = dayOfYear / 31;
|
||||
|
@ -349,7 +349,7 @@ public class RuleBasedTimeZone extends BasicTimeZone {
|
||||
return null;
|
||||
}
|
||||
boolean isFinal = false;
|
||||
TimeZoneTransition result = null;
|
||||
TimeZoneTransition result;
|
||||
TimeZoneTransition tzt = historicTransitions.get(0);
|
||||
long tt = tzt.getTime();
|
||||
if (tt > base || (inclusive && tt == base)) {
|
||||
@ -394,18 +394,16 @@ public class RuleBasedTimeZone extends BasicTimeZone {
|
||||
result = prev;
|
||||
}
|
||||
}
|
||||
if (result != null) {
|
||||
// For now, this implementation ignore transitions with only zone name changes.
|
||||
TimeZoneRule from = result.getFrom();
|
||||
TimeZoneRule to = result.getTo();
|
||||
if (from.getRawOffset() == to.getRawOffset()
|
||||
&& from.getDSTSavings() == to.getDSTSavings()) {
|
||||
// No offset changes. Try next one if not final
|
||||
if (isFinal) {
|
||||
return null;
|
||||
} else {
|
||||
result = getNextTransition(result.getTime(), false /* always exclusive */);
|
||||
}
|
||||
// For now, this implementation ignore transitions with only zone name changes.
|
||||
TimeZoneRule from = result.getFrom();
|
||||
TimeZoneRule to = result.getTo();
|
||||
if (from.getRawOffset() == to.getRawOffset()
|
||||
&& from.getDSTSavings() == to.getDSTSavings()) {
|
||||
// No offset changes. Try next one if not final
|
||||
if (isFinal) {
|
||||
return null;
|
||||
} else {
|
||||
result = getNextTransition(result.getTime(), false /* always exclusive */);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -422,7 +420,7 @@ public class RuleBasedTimeZone extends BasicTimeZone {
|
||||
if (historicTransitions == null) {
|
||||
return null;
|
||||
}
|
||||
TimeZoneTransition result = null;
|
||||
TimeZoneTransition result;
|
||||
TimeZoneTransition tzt = historicTransitions.get(0);
|
||||
long tt = tzt.getTime();
|
||||
if (inclusive && tt == base) {
|
||||
@ -464,15 +462,13 @@ public class RuleBasedTimeZone extends BasicTimeZone {
|
||||
result = tzt;
|
||||
}
|
||||
}
|
||||
if (result != null) {
|
||||
// For now, this implementation ignore transitions with only zone name changes.
|
||||
TimeZoneRule from = result.getFrom();
|
||||
TimeZoneRule to = result.getTo();
|
||||
if (from.getRawOffset() == to.getRawOffset()
|
||||
&& from.getDSTSavings() == to.getDSTSavings()) {
|
||||
// No offset changes. Try previous one
|
||||
result = getPreviousTransition(result.getTime(), false /* always exclusive */);
|
||||
}
|
||||
// For now, this implementation ignore transitions with only zone name changes.
|
||||
TimeZoneRule from = result.getFrom();
|
||||
TimeZoneRule to = result.getTo();
|
||||
if (from.getRawOffset() == to.getRawOffset()
|
||||
&& from.getDSTSavings() == to.getDSTSavings()) {
|
||||
// No offset changes. Try previous one
|
||||
result = getPreviousTransition(result.getTime(), false /* always exclusive */);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ class NullTransliterator extends Transliterator {
|
||||
/**
|
||||
* Package accessible IDs for this transliterator.
|
||||
*/
|
||||
static String SHORT_ID = "Null";
|
||||
static String _ID = "Any-Null";
|
||||
static final String SHORT_ID = "Null";
|
||||
static final String _ID = "Any-Null";
|
||||
|
||||
/**
|
||||
* Constructs a transliterator.
|
||||
|
Loading…
Reference in New Issue
Block a user