Program: 35117
Project: 35117
Buggy source:
/** 
 * This function will try to add a number or operator, or entire prevExpression to the current expression Note that there is lots of error checking to be sure user can't entire an invalid operator/number
 * @param sKey should only be single vaild number or operator character, or longer previous expressions
 */
public void keyPresses(String sKey){
  if (sKey.length() > 1) {
    if (mSolved)     replaceExpression(sKey);
 else     insertAtSelection(sKey);
    mSolved=false;
    return;
  }
  if (sKey.matches(regexInvalidChars))   throw new IllegalArgumentException("String_Node_Str");
  if (sKey.matches(regexInvalidStartChar) && (lastNumb().equals("String_Node_Str") || expresssionToSelection().matches("String_Node_Str")))   return;
  if (mSolved && sKey.matches("String_Node_Str"))   clearExpression();
  if (sKey.equals("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.equals("String_Node_Str"))   if (numOpenPara() <= 0)   addToExpressionStart("String_Node_Str");
  if (sKey.equals("String_Node_Str") && lastNumb().matches("String_Node_Str"))   if (!expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str"))   return;
  if (sKey.equals("String_Node_Str") && (lastNumb().contains("String_Node_Str") || expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str")))   return;
  if (lastNumb().matches("String_Node_Str"))   if (sKey.matches("String_Node_Str"))   return;
  if (sKey.matches(regexAnyOperatorOrE) && lastNumb().equals("String_Node_Str"))   return;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   return;
  if (sKey.matches(regexAnyValidOperator) && expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + regexAnyValidOperator+ "String_Node_Str")) {
    backspaceAtSelection();
    backspaceAtSelection();
  }
 else   if (sKey.matches(regexInvalidStartChar) && expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str")) {
    backspaceAtSelection();
  }
  insertAtSelection(sKey);
  mSolved=false;
}

Fixed version (ground truth):
/** 
 * This function will try to add a number or operator, or entire prevExpression to the current expression Note that there is lots of error checking to be sure user can't entire an invalid operator/number
 * @param sKey should only be single vaild number or operator character, or longer previous expressions
 */
public void keyPresses(String sKey){
  if (sKey.length() > 1) {
    if (mSolved)     replaceExpression(sKey);
 else     insertAtSelection(sKey);
    mSolved=false;
    return;
  }
  if (sKey.matches(regexInvalidChars))   throw new IllegalArgumentException("String_Node_Str");
  if (sKey.matches(regexInvalidStartChar) && (lastNumb().equals("String_Node_Str") || expresssionToSelection().matches("String_Node_Str")))   return;
  if (mSolved && sKey.matches("String_Node_Str"))   clearExpression();
  if (sKey.equals("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.equals("String_Node_Str"))   if (numOpenPara() <= 0)   addToExpressionStart("String_Node_Str");
  if (sKey.equals("String_Node_Str") && lastNumb().matches("String_Node_Str"))   if (!expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str"))   return;
  if (sKey.equals("String_Node_Str") && (lastNumb().contains("String_Node_Str") || expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str")))   return;
  if (lastNumb().matches("String_Node_Str"))   if (sKey.matches("String_Node_Str"))   return;
  if (sKey.matches(regexAnyOperatorOrE) && lastNumb().equals("String_Node_Str"))   return;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   return;
  if (sKey.matches(regexAnyValidOperator) && expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + regexAnyValidOperator+ "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
    backspaceAtSelection();
  }
 else   if (sKey.matches(regexInvalidStartChar) && expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
  }
  insertAtSelection(sKey);
  mSolved=false;
}