Program: 82838
Project: 82838
Buggy source:
/** 
 * Parses text to produce a numeric value. <p> The method attempts to parse text starting at the index given by pos. If parsing succeeds, then the index of <code>pos</code> is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed number is returned. The updated <code>pos</code> can be used to indicate the starting point for the next call to this method. If an error occurs, then the index of <code>pos</code> is not changed. </p>
 * @param text the string to be parsed
 * @param inOutPos position to pass in and get back
 * @return a double value representing the parsed number, or <code>0.0</code>if the parse fails
 */
public double parse(String text,int[] inOutPos){
  int start=inOutPos[0];
  boolean gotPositive, gotNegative;
  double ret=0.0;
  gotPositive=(text.indexOf(positivePrefix,inOutPos[0]) == inOutPos[0]);
  gotNegative=(text.indexOf(negativePrefix,inOutPos[0]) == inOutPos[0]);
  if (gotPositive && gotNegative) {
    if (positivePrefix.length() > negativePrefix.length()) {
      gotNegative=false;
    }
 else     if (positivePrefix.length() < negativePrefix.length()) {
      gotPositive=false;
    }
  }
  if (gotPositive) {
    inOutPos[0]+=positivePrefix.length();
  }
 else   if (gotNegative) {
    inOutPos[0]+=negativePrefix.length();
  }
  if (text.indexOf(numberConstants.infinity(),inOutPos[0]) == inOutPos[0]) {
    inOutPos[0]+=numberConstants.infinity().length();
    ret=Double.POSITIVE_INFINITY;
  }
 else   if (text.indexOf(numberConstants.notANumber(),inOutPos[0]) == inOutPos[0]) {
    inOutPos[0]+=numberConstants.notANumber().length();
    ret=Double.NaN;
  }
 else {
    ret=parseNumber(text,inOutPos);
  }
  if (gotPositive) {
    if (!(text.indexOf(positiveSuffix,inOutPos[0]) == inOutPos[0])) {
      inOutPos[0]=start;
      return 0.0;
    }
    inOutPos[0]+=positiveSuffix.length();
  }
 else   if (gotNegative) {
    if (!(text.indexOf(negativeSuffix,inOutPos[0]) == inOutPos[0])) {
      inOutPos[0]=start;
      return 0.0;
    }
    inOutPos[0]+=negativeSuffix.length();
  }
  if (gotNegative) {
    ret=-ret;
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Parses text to produce a numeric value. <p> The method attempts to parse text starting at the index given by pos. If parsing succeeds, then the index of <code>pos</code> is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed number is returned. The updated <code>pos</code> can be used to indicate the starting point for the next call to this method. If an error occurs, then the index of <code>pos</code> is not changed. </p>
 * @param text the string to be parsed
 * @param inOutPos position to pass in and get back
 * @return a double value representing the parsed number, or <code>0.0</code>if the parse fails
 * @throws NumberFormatException if the text segment could not be converted into a number
 */
public double parse(String text,int[] inOutPos) throws NumberFormatException {
  int start=inOutPos[0];
  boolean gotPositive, gotNegative;
  double ret=0.0;
  gotPositive=(text.indexOf(positivePrefix,inOutPos[0]) == inOutPos[0]);
  gotNegative=(text.indexOf(negativePrefix,inOutPos[0]) == inOutPos[0]);
  if (gotPositive && gotNegative) {
    if (positivePrefix.length() > negativePrefix.length()) {
      gotNegative=false;
    }
 else     if (positivePrefix.length() < negativePrefix.length()) {
      gotPositive=false;
    }
  }
  if (gotPositive) {
    inOutPos[0]+=positivePrefix.length();
  }
 else   if (gotNegative) {
    inOutPos[0]+=negativePrefix.length();
  }
  if (text.indexOf(numberConstants.infinity(),inOutPos[0]) == inOutPos[0]) {
    inOutPos[0]+=numberConstants.infinity().length();
    ret=Double.POSITIVE_INFINITY;
  }
 else   if (text.indexOf(numberConstants.notANumber(),inOutPos[0]) == inOutPos[0]) {
    inOutPos[0]+=numberConstants.notANumber().length();
    ret=Double.NaN;
  }
 else {
    ret=parseNumber(text,inOutPos);
  }
  if (gotPositive) {
    if (!(text.indexOf(positiveSuffix,inOutPos[0]) == inOutPos[0])) {
      inOutPos[0]=start;
      return 0.0;
    }
    inOutPos[0]+=positiveSuffix.length();
  }
 else   if (gotNegative) {
    if (!(text.indexOf(negativeSuffix,inOutPos[0]) == inOutPos[0])) {
      inOutPos[0]=start;
      return 0.0;
    }
    inOutPos[0]+=negativeSuffix.length();
  }
  if (gotNegative) {
    ret=-ret;
  }
  return ret;
}