View | Details | Raw Unified | Return to bug 329288 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/core/compiler/CharOperation.java (-9 / +47 lines)
Lines 2939-2962 Link Here
2939
	char[] prefix,
2939
	char[] prefix,
2940
	char[] name,
2940
	char[] name,
2941
	boolean isCaseSensitive) {
2941
	boolean isCaseSensitive) {
2942
	return prefixEquals(prefix, name, isCaseSensitive, 0);
2943
}
2944
2945
/**
2946
 * Answers true if the given name, starting from the given index, starts with the given prefix,
2947
 * false otherwise. isCaseSensitive is used to find out whether or not the comparison should be
2948
 * case sensitive.
2949
 * <br>
2950
 * <br>
2951
 * For example:
2952
 * <ol>
2953
 * <li><pre>
2954
 *    prefix = { 'a' , 'B' }
2955
 *    name = { 'c', 'd', 'a' , 'b', 'b', 'a', 'b', 'a' }
2956
 *    startIndex = 2
2957
 *    isCaseSensitive = false
2958
 *    result => true
2959
 * </pre>
2960
 * </li>
2961
 * <li><pre>
2962
 *    prefix = { 'a' , 'B' }
2963
 *    name = { 'c', 'd', 'a' , 'b', 'b', 'a', 'b', 'a' }
2964
 *    startIndex = 2
2965
 *    isCaseSensitive = true
2966
 *    result => false
2967
 * </pre>
2968
 * </li>
2969
 * </ol>
2970
 *
2971
 * @param prefix the given prefix
2972
 * @param name the given name
2973
 * @param isCaseSensitive to find out whether or not the comparison should be case sensitive
2974
 * @param startIndex index from which the prefix should be searched in the name
2975
 * @return true if the given name starts with the given prefix, false otherwise
2976
 * @throws NullPointerException if the given name is null or if the given prefix is null
2977
 * @since 3.7
2978
 */
2979
public static final boolean prefixEquals(
2980
	char[] prefix,
2981
	char[] name,
2982
	boolean isCaseSensitive,
2983
	int startIndex) {
2942
2984
2943
	int max = prefix.length;
2985
	int max = prefix.length;
2944
	if (name.length < max)
2986
	if (name.length - startIndex < max)
2945
		return false;
2987
		return false;
2946
	if (isCaseSensitive) {
2988
	if (isCaseSensitive) {
2947
		for (int i = max;
2989
		for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
2948
			--i >= 0;
2990
			if (prefix[i] != name[startIndex + i])
2949
			) // assumes the prefix is not larger than the name
2950
			if (prefix[i] != name[i])
2951
				return false;
2991
				return false;
2952
		return true;
2992
		return true;
2953
	}
2993
	}
2954
2994
2955
	for (int i = max;
2995
	for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
2956
		--i >= 0;
2957
		) // assumes the prefix is not larger than the name
2958
		if (ScannerHelper.toLowerCase(prefix[i])
2996
		if (ScannerHelper.toLowerCase(prefix[i])
2959
			!= ScannerHelper.toLowerCase(name[i]))
2997
			!= ScannerHelper.toLowerCase(name[startIndex + i]))
2960
			return false;
2998
			return false;
2961
	return true;
2999
	return true;
2962
}
3000
}
(-)model/org/eclipse/jdt/internal/core/JavadocContents.java (-2 / +2 lines)
Lines 145-151 Link Here
145
			for (int i = 0; i < this.tempAnchorIndexesCount; i++) {
145
			for (int i = 0; i < this.tempAnchorIndexesCount; i++) {
146
				int anchorEndStart = this.tempAnchorIndexes[i];
146
				int anchorEndStart = this.tempAnchorIndexes[i];
147
				
147
				
148
				if (anchorEndStart != -1 && CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) {
148
				if (anchorEndStart != -1 && CharOperation.prefixEquals(anchor, this.content, false, anchorEndStart)) {
149
					
149
					
150
					this.tempAnchorIndexes[i] = -1;
150
					this.tempAnchorIndexes[i] = -1;
151
					
151
					
Lines 165-171 Link Here
165
			
165
			
166
			this.tempLastAnchorFoundIndex = anchorEndStart;
166
			this.tempLastAnchorFoundIndex = anchorEndStart;
167
			
167
			
168
			if (CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) {
168
			if (CharOperation.prefixEquals(anchor, this.content, false, anchorEndStart)) {
169
				return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom);
169
				return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom);
170
			} else {
170
			} else {
171
				if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) {
171
				if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) {

Return to bug 329288