Program: 151637
Project: 151637
Buggy source:
private void more(InputStream stream,PipeOut out) throws IOException {
  byte[] buffer=new byte[1024];
  int read;
  byte c;
  int height=shell.getHeight() - 1;
  int width=shell.getWidth();
  int lCounter=width;
  int y=0;
  LineBuffer lineBuffer=new LineBuffer(stream,width);
  Mainloop:   while ((read=lineBuffer.read(buffer)) != -1) {
    Bufferloop:     for (int i=0; i < read; i++) {
      if (--lCounter == 0) {
        lineBuffer.seenLine();
        lCounter=width;
        ++y;
      }
switch (c=buffer[i]) {
case '\r':
        i++;
case '\n':
      lineBuffer.seenLine();
    lCounter=width;
  ++y;
default :
if (y == height) {
  out.println();
  boolean backwards=false;
  do {
    String prompt=MOREPROMPT + "String_Node_Str" + lineBuffer.getCurrentLine()+ "String_Node_Str";
    out.print(ShellColor.BOLD,prompt);
switch (shell.scan()) {
case 'e':
case 'E':
case 'j':
case 'J':
case 16:
      lineBuffer.rewindBuffer(height=shell.getHeight() - 1,lineBuffer.getCurrentLine() - 1);
    lineBuffer.setLineWidth(shell.getWidth());
  y=0;
shell.clear();
continue Mainloop;
case 'u':
case 'U':
lineBuffer.rewindBuffer(height=shell.getHeight() - 1,lineBuffer.getCurrentLine() - height);
y=0;
shell.clear();
continue Mainloop;
case 'y':
case 'Y':
case 'k':
case 'K':
case 14:
case '\n':
y--;
height=shell.getHeight() - 1;
lineBuffer.setLineWidth(shell.getWidth());
shell.cursorLeft(prompt.length());
shell.clearLine();
continue Bufferloop;
case ' ':
y=0;
height=shell.getHeight() - 1;
lineBuffer.setLineWidth(shell.getWidth());
shell.clearLine();
shell.cursorLeft(prompt.length());
continue Bufferloop;
case 'q':
case 'Q':
out.println();
break Mainloop;
case '?':
backwards=true;
case '/':
shell.clearLine();
shell.cursorLeft(prompt.length());
prompt=backwards ? SEARCH_BACKWARDS_PROMPT : SEARCH_FORWARD_PROMPT;
out.print(ShellColor.BOLD,prompt);
String pattern=shell.promptAndSwallowCR().trim();
int result=lineBuffer.findPattern(pattern,backwards);
if (result == -1) {
shell.clearLine();
shell.cursorLeft(prompt.length() + pattern.length());
shell.print(ShellColor.RED,PATTERN_NOT_FOUND + pattern);
shell.scan();
shell.clearLine();
shell.cursorLeft(PATTERN_NOT_FOUND.length() + pattern.length());
}
 else {
lineBuffer.rewindBuffer(shell.getHeight() - 1,result);
y=0;
shell.clear();
continue Mainloop;
}
break;
}
}
 while (true);
}
}
out.write(c);
}
}
}

Fixed version (ground truth):
private void more(InputStream stream,PipeOut out) throws IOException {
  byte[] buffer=new byte[1024];
  int read;
  byte c;
  int height=shell.getHeight() - 1;
  int width=shell.getWidth();
  int lCounter=width;
  int y=0;
  LineBuffer lineBuffer=new LineBuffer(stream,width);
  String lastPattern=null;
  Mainloop:   while ((read=lineBuffer.read(buffer)) != -1) {
    Bufferloop:     for (int i=0; i < read; i++) {
      if (--lCounter == 0) {
        lineBuffer.seenLine();
        lCounter=width;
        ++y;
      }
switch (c=buffer[i]) {
case '\r':
        i++;
case '\n':
      lineBuffer.seenLine();
    lCounter=width;
  ++y;
default :
if (y == height) {
  out.println();
  boolean backwards=false;
  do {
    String prompt=MOREPROMPT + "String_Node_Str" + lineBuffer.getCurrentLine()+ "String_Node_Str";
    out.print(ShellColor.BOLD,prompt);
switch (shell.scan()) {
case 'e':
case 'E':
case 'j':
case 'J':
case 16:
      lineBuffer.rewindBuffer(height=shell.getHeight() - 1,lineBuffer.getCurrentLine() - 1);
    lineBuffer.setLineWidth(shell.getWidth());
  y=0;
shell.clear();
continue Mainloop;
case 'u':
case 'U':
lineBuffer.rewindBuffer(height=shell.getHeight() - 1,lineBuffer.getCurrentLine() - height);
y=0;
shell.clear();
continue Mainloop;
case 'y':
case 'Y':
case 'k':
case 'K':
case 14:
case '\n':
y--;
height=shell.getHeight() - 1;
lineBuffer.setLineWidth(shell.getWidth());
shell.cursorLeft(prompt.length());
shell.clearLine();
continue Bufferloop;
case ' ':
y=0;
height=shell.getHeight() - 1;
lineBuffer.setLineWidth(shell.getWidth());
shell.clearLine();
shell.cursorLeft(prompt.length());
continue Bufferloop;
case 'q':
case 'Q':
shell.clearLine();
shell.cursorLeft(prompt.length());
out.println();
break Mainloop;
case '?':
backwards=true;
case '/':
shell.clearLine();
shell.cursorLeft(prompt.length());
prompt=backwards ? SEARCH_BACKWARDS_PROMPT : SEARCH_FORWARD_PROMPT;
String pattern;
if (lastPattern != null) {
prompt+="String_Node_Str" + lastPattern + "String_Node_Str";
}
out.print(ShellColor.BOLD,prompt);
pattern=shell.promptAndSwallowCR().trim();
String searched;
int result=lineBuffer.findPattern(pattern.equals("String_Node_Str") && lastPattern != null ? searched=lastPattern : (searched=lastPattern=pattern),backwards);
if (result == -1) {
shell.clearLine();
shell.cursorLeft(prompt.length() + pattern.length());
shell.print(ShellColor.RED,PATTERN_NOT_FOUND + searched);
shell.scan();
shell.clearLine();
shell.cursorLeft(PATTERN_NOT_FOUND.length() + searched.length());
}
 else {
lineBuffer.rewindBuffer(shell.getHeight() - 1,result);
y=0;
shell.clear();
continue Mainloop;
}
break;
}
}
 while (true);
}
}
out.write(c);
}
}
}