Program: 143958
Project: 143958
Buggy source:
/** 
 * Handle events for the terminal. Only accept events for the scroll bar. Any other events have to be propagated to the parent.
 * @param evt the event
 */
public void keyPressed(KeyEvent evt){
  boolean control=evt.isControlDown();
  boolean shift=evt.isShiftDown();
  boolean alt=evt.isAltDown();
  int keyCode=evt.getKeyCode();
  char keyChar=evt.getKeyChar();
  if (pressedKey == KeyEvent.VK_ENTER && (keyCode == KeyEvent.VK_ENTER || keyChar == 10) && evt.getWhen() - pressedWhen < 50)   return;
  pressedWhen=evt.getWhen();
  if (keyCode == KeyEvent.VK_ENTER && !control) {
    if (sendcrlf)     write("String_Node_Str");
 else     write("String_Node_Str");
  }
  if (((!vms && keyChar == '2') || keyChar == ' ') && control)   write("String_Node_Str" + (char)0);
  if (vms) {
    if (keyChar == 8) {
      if (shift && !control)       write("String_Node_Str" + (char)10);
 else       if (control && !shift)       write("String_Node_Str" + (char)24);
 else       write("String_Node_Str" + (char)127);
    }
 else     if (keyChar == 127 && !control) {
      if (shift)       write(Insert[0]);
 else       write(Remove[0]);
    }
 else     if (control) switch (keyChar) {
case '0':
      write(KP0);
    return;
case '1':
  write(KP1);
return;
case '2':
write(KP2);
return;
case '3':
write(KP3);
return;
case '4':
write(KP4);
return;
case '5':
write(KP5);
return;
case '6':
write(KP6);
return;
case '7':
write(KP7);
return;
case '8':
write(KP8);
return;
case '9':
write(KP9);
return;
case '.':
write(KPPeriod);
return;
case '-':
case 31:
write(KPMinus);
return;
case '+':
write(KPComma);
return;
case 10:
write(KPEnter);
return;
case '/':
write(PF2);
return;
case '*':
write(PF3);
return;
}
if (shift && keyChar < 32) write(PF1 + (char)(keyChar + 64));
return;
}
String fmap[];
int xind;
xind=0;
fmap=FunctionKey;
if (shift) {
fmap=FunctionKeyShift;
xind=1;
}
if (control) {
fmap=FunctionKeyCtrl;
xind=2;
}
if (alt) {
fmap=FunctionKeyAlt;
xind=3;
}
switch (keyCode) {
case KeyEvent.VK_F1:
write(fmap[1]);
return;
case KeyEvent.VK_F2:
write(fmap[2]);
return;
case KeyEvent.VK_F3:
write(fmap[3]);
return;
case KeyEvent.VK_F4:
write(fmap[4]);
return;
case KeyEvent.VK_F5:
write(fmap[5]);
return;
case KeyEvent.VK_F6:
write(fmap[6]);
return;
case KeyEvent.VK_F7:
write(fmap[7]);
return;
case KeyEvent.VK_F8:
write(fmap[8]);
return;
case KeyEvent.VK_F9:
write(fmap[9]);
return;
case KeyEvent.VK_F10:
write(fmap[10]);
return;
case KeyEvent.VK_F11:
write(fmap[11]);
return;
case KeyEvent.VK_F12:
write(fmap[12]);
return;
case KeyEvent.VK_UP:
write(KeyUp);
return;
case KeyEvent.VK_DOWN:
write(KeyDown);
return;
case KeyEvent.VK_LEFT:
write(KeyLeft);
return;
case KeyEvent.VK_RIGHT:
write(KeyRight);
return;
case KeyEvent.VK_PAGE_DOWN:
write(NextScn[xind]);
return;
case KeyEvent.VK_PAGE_UP:
write(PrevScn[xind]);
return;
case KeyEvent.VK_INSERT:
write(Insert[xind]);
return;
case KeyEvent.VK_HOME:
if (vms) write("String_Node_Str" + (char)8);
 else write(KeyHome[xind]);
return;
case KeyEvent.VK_END:
if (vms) write("String_Node_Str" + (char)5);
 else write(KeyEnd[xind]);
return;
case KeyEvent.VK_NUM_LOCK:
if (vms && control) if (pressedKey != keyCode) {
pressedKey=keyCode;
write(PF1);
}
 else pressedKey=' ';
if (!control) numlock=!numlock;
return;
case KeyEvent.VK_CAPS_LOCK:
capslock=!capslock;
return;
default :
if (debug > 0) System.out.println("String_Node_Str" + evt);
}
}

Fixed version (ground truth):
/** 
 * Handle events for the terminal. Only accept events for the scroll bar. Any other events have to be propagated to the parent.
 * @param evt the event
 */
public void keyPressed(KeyEvent evt){
  boolean control=evt.isControlDown();
  boolean shift=evt.isShiftDown();
  boolean alt=evt.isAltDown();
  int keyCode=evt.getKeyCode();
  char keyChar=evt.getKeyChar();
  if (keyCode == KeyEvent.VK_ENTER && !control) {
    if (sendcrlf)     write("String_Node_Str");
 else     write("String_Node_Str");
  }
  if (((!vms && keyChar == '2') || keyChar == ' ') && control)   write("String_Node_Str" + (char)0);
  if (vms) {
    if (keyChar == 8) {
      if (shift && !control)       write("String_Node_Str" + (char)10);
 else       if (control && !shift)       write("String_Node_Str" + (char)24);
 else       write("String_Node_Str" + (char)127);
    }
 else     if (keyChar == 127 && !control) {
      if (shift)       write(Insert[0]);
 else       write(Remove[0]);
    }
 else     if (control) switch (keyChar) {
case '0':
      write(KP0);
    return;
case '1':
  write(KP1);
return;
case '2':
write(KP2);
return;
case '3':
write(KP3);
return;
case '4':
write(KP4);
return;
case '5':
write(KP5);
return;
case '6':
write(KP6);
return;
case '7':
write(KP7);
return;
case '8':
write(KP8);
return;
case '9':
write(KP9);
return;
case '.':
write(KPPeriod);
return;
case '-':
case 31:
write(KPMinus);
return;
case '+':
write(KPComma);
return;
case 10:
write(KPEnter);
return;
case '/':
write(PF2);
return;
case '*':
write(PF3);
return;
}
if (shift && keyChar < 32) write(PF1 + (char)(keyChar + 64));
return;
}
String fmap[];
int xind;
xind=0;
fmap=FunctionKey;
if (shift) {
fmap=FunctionKeyShift;
xind=1;
}
if (control) {
fmap=FunctionKeyCtrl;
xind=2;
}
if (alt) {
fmap=FunctionKeyAlt;
xind=3;
}
switch (keyCode) {
case KeyEvent.VK_F1:
write(fmap[1]);
return;
case KeyEvent.VK_F2:
write(fmap[2]);
return;
case KeyEvent.VK_F3:
write(fmap[3]);
return;
case KeyEvent.VK_F4:
write(fmap[4]);
return;
case KeyEvent.VK_F5:
write(fmap[5]);
return;
case KeyEvent.VK_F6:
write(fmap[6]);
return;
case KeyEvent.VK_F7:
write(fmap[7]);
return;
case KeyEvent.VK_F8:
write(fmap[8]);
return;
case KeyEvent.VK_F9:
write(fmap[9]);
return;
case KeyEvent.VK_F10:
write(fmap[10]);
return;
case KeyEvent.VK_F11:
write(fmap[11]);
return;
case KeyEvent.VK_F12:
write(fmap[12]);
return;
case KeyEvent.VK_UP:
write(KeyUp);
return;
case KeyEvent.VK_DOWN:
write(KeyDown);
return;
case KeyEvent.VK_LEFT:
write(KeyLeft);
return;
case KeyEvent.VK_RIGHT:
write(KeyRight);
return;
case KeyEvent.VK_PAGE_DOWN:
write(NextScn[xind]);
return;
case KeyEvent.VK_PAGE_UP:
write(PrevScn[xind]);
return;
case KeyEvent.VK_INSERT:
write(Insert[xind]);
return;
case KeyEvent.VK_HOME:
if (vms) write("String_Node_Str" + (char)8);
 else write(KeyHome[xind]);
return;
case KeyEvent.VK_END:
if (vms) write("String_Node_Str" + (char)5);
 else write(KeyEnd[xind]);
return;
case KeyEvent.VK_NUM_LOCK:
if (vms && control) if (pressedKey != keyCode) {
pressedKey=keyCode;
write(PF1);
}
 else pressedKey=' ';
if (!control) numlock=!numlock;
return;
case KeyEvent.VK_CAPS_LOCK:
capslock=!capslock;
return;
default :
if (debug > 0) System.out.println("String_Node_Str" + evt);
}
}