Program: 82617
Project: 82617
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
 * @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];
  double ret=0.0;
  boolean gotPositivePrefix=text.startsWith(positivePrefix,inOutPos[0]);
  boolean gotNegativePrefix=text.startsWith(negativePrefix,inOutPos[0]);
  boolean gotPositiveSuffix=text.endsWith(positiveSuffix);
  boolean gotNegativeSuffix=text.endsWith(negativeSuffix);
  boolean gotPositive=gotPositivePrefix && gotPositiveSuffix;
  boolean gotNegative=gotNegativePrefix && gotNegativeSuffix;
  if (gotPositive && gotNegative) {
    if (positivePrefix.length() > negativePrefix.length()) {
      gotNegative=false;
    }
 else     if (positivePrefix.length() < negativePrefix.length()) {
      gotPositive=false;
    }
 else     if (positiveSuffix.length() > negativeSuffix.length()) {
      gotNegative=false;
    }
 else     if (positiveSuffix.length() < negativeSuffix.length()) {
      gotPositive=false;
    }
 else {
      gotNegative=false;
    }
  }
 else   if (!gotPositive && !gotNegative) {
    throw new NumberFormatException(text + "String_Node_Str");
  }
  String valueOnly=null;
  if (gotPositive) {
    inOutPos[0]+=positivePrefix.length();
    valueOnly=text.substring(inOutPos[0],text.length() - positiveSuffix.length());
  }
 else {
    inOutPos[0]+=negativePrefix.length();
    valueOnly=text.substring(inOutPos[0],text.length() - negativeSuffix.length());
  }
  if (valueOnly.equals(numberConstants.infinity())) {
    inOutPos[0]+=numberConstants.infinity().length();
    ret=Double.POSITIVE_INFINITY;
  }
 else   if (valueOnly.equals(numberConstants.notANumber())) {
    inOutPos[0]+=numberConstants.notANumber().length();
    ret=Double.NaN;
  }
 else {
    int[] tempPos={0};
    ret=parseNumber(valueOnly,tempPos);
    inOutPos[0]+=tempPos[0];
  }
  if (gotPositive) {
    inOutPos[0]+=positiveSuffix.length();
  }
 else   if (gotNegative) {
    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 {
  double ret=0.0;
  boolean gotPositivePrefix=text.startsWith(positivePrefix,inOutPos[0]);
  boolean gotNegativePrefix=text.startsWith(negativePrefix,inOutPos[0]);
  boolean gotPositiveSuffix=text.endsWith(positiveSuffix);
  boolean gotNegativeSuffix=text.endsWith(negativeSuffix);
  boolean gotPositive=gotPositivePrefix && gotPositiveSuffix;
  boolean gotNegative=gotNegativePrefix && gotNegativeSuffix;
  if (gotPositive && gotNegative) {
    if (positivePrefix.length() > negativePrefix.length()) {
      gotNegative=false;
    }
 else     if (positivePrefix.length() < negativePrefix.length()) {
      gotPositive=false;
    }
 else     if (positiveSuffix.length() > negativeSuffix.length()) {
      gotNegative=false;
    }
 else     if (positiveSuffix.length() < negativeSuffix.length()) {
      gotPositive=false;
    }
 else {
      gotNegative=false;
    }
  }
 else   if (!gotPositive && !gotNegative) {
    throw new NumberFormatException(text + "String_Node_Str");
  }
  String valueOnly=null;
  if (gotPositive) {
    inOutPos[0]+=positivePrefix.length();
    valueOnly=text.substring(inOutPos[0],text.length() - positiveSuffix.length());
  }
 else {
    inOutPos[0]+=negativePrefix.length();
    valueOnly=text.substring(inOutPos[0],text.length() - negativeSuffix.length());
  }
  if (valueOnly.equals(numberConstants.infinity())) {
    inOutPos[0]+=numberConstants.infinity().length();
    ret=Double.POSITIVE_INFINITY;
  }
 else   if (valueOnly.equals(numberConstants.notANumber())) {
    inOutPos[0]+=numberConstants.notANumber().length();
    ret=Double.NaN;
  }
 else {
    int[] tempPos={0};
    ret=parseNumber(valueOnly,tempPos);
    inOutPos[0]+=tempPos[0];
  }
  if (gotPositive) {
    inOutPos[0]+=positiveSuffix.length();
  }
 else   if (gotNegative) {
    inOutPos[0]+=negativeSuffix.length();
  }
  if (gotNegative) {
    ret=-ret;
  }
  return ret;
}