rem: } else {
add: } else
context: debug_read_line(char *buf, int max_len){	char c;	int ptr = 0;	bool done = false;	int cur_history_spot = cur_line;	while(!done) {		c = arch_dbg_con_read();		switch(c) {			case '\n':			case '\r':				buf[ptr++] = '\0';				dbg_puts("\n");				done = true;				break;			case 8: // backspace				if(ptr > 0) {					dbg_puts("\x1b[1D"); // move to the left one					dbg_putch(' ');					dbg_puts("\x1b[1D"); // move to the left one					ptr--;				}				break;			case 27: // escape sequence				c = arch_dbg_con_read(); // should be '['				c = arch_dbg_con_read();				switch(c) {					case 67: // right arrow acts like space						buf[ptr++] = ' ';						dbg_putch(' ');						break;					case 68: // left arrow acts like backspace						if(ptr > 0) {							dbg_puts("\x1b[1D"); // move to the left one							dbg_putch(' ');							dbg_puts("\x1b[1D"); // move to the left one							ptr--;						}						break;					case 65: // up arrow					case 66: // down arrow					{						int history_line = 0;//						dprintf("1c %d h %d ch %d\n", cur_line, history_line, cur_history_spot);						if(c == 65) {							// up arrow							history_line = cur_history_spot - 1;							if(history_line < 0)								history_line = HISTORY_SIZE - 1;						} else {							// down arrow							if(cur_history_spot != cur_line) {								history_line = cur_history_spot + 1;								if(history_line >= HISTORY_SIZE)									history_line = 0;							} else {								break; // nothing to do here							}						}//						dprintf("2c %d h %d ch %d\n", cur_line, history_line, cur_history_spot);						// swap the current line with something from the history						if(ptr > 0)							dprintf("\x1b[%dD", ptr); // move to beginning of line						strcpy(buf, line_buf[history_line]);						ptr = strlen(buf);						dprintf("%s\x1b[K", buf); // print the line and clear the rest						cur_history_spot = history_line;						break;					}					default:						break;				}				break;			case '$':			case '+':				/* HACK ALERT!!!				 *				 * If we get a $ at the beginning of the line				 * we assume we are talking with GDB				 */				if(ptr == 0) {					strcpy(buf, "gdb");					ptr= 4;					done= true;					break;				} else {					/* fall thru */				}			default:				buf[ptr++] = c;				dbg_putch(c);		}		if(ptr >= max_len - 2) {			buf[ptr++] = '\0';			dbg_puts("\n");			done = true;			break;		}	}	return ptr;}