--- xboard-4.2.7/backend.c 2003-11-28 09:37:36.000000000 +0000 +++ xboard-4.2.7+byte/backend.c 2006-04-04 21:14:48.000000000 +0100 @@ -1421,8 +1421,46 @@ static int player1Rating = -1; static int player2Rating = -1; /*----------------------------*/ +/* timeseal doesn't strip out the extra \n\r, + * but also incorrectly removes the \n from the + * final \n\r before the prompt + * + * FICS input: \n\r\n\r[timeseal data]\n\rfics% + * timeseal output: \n\r\n\r\rfics% + * normal FICS input: \n\rfics% + * + * This function strips out the \n\r\r sequence. + */ +int +fix_timeseal(text) + char *text; +{ + char *p = text; + char *q = text; + char last[3]; + char ch; + int fixed = 0; + + memset(last, 0, 3); + do { + ch = *p++; + last[0] = last[1]; + last[1] = last[2]; + last[2] = ch; + if (last[0] == '\n' && last[1] == '\r' && last[2] == '\r') { + *q--; // remove \n + *q--; // remove \r + fixed += 3; + continue; // skip \r + } + *q++ = ch; + } while (ch != '\0'); + + return fixed; +} + void read_from_ics(isr, closure, data, count, error) InputSourceRef isr; VOIDSTAR closure; @@ -1464,8 +1502,10 @@ } } #endif + count -= fix_timeseal(data); + if (count > 0) { /* If last read ended with a partial line that we couldn't parse, prepend it to the new read and try again. */ if (leftover_len > 0) {