+ if (cfg.ldisc_term) {
+ while (p < buf+len) {
+ char *q = p;
+ unsigned char * cstr = 0;
+ while (p < buf+len) {
+ if ((unsigned char)*p == IAC) {
+ cstr = iac;
+ break;
+ }
+ if (*p == '\r') {
+ if( p+1 >= buf+len || ( p[1] != '\n' && p[1] != '\0'))
+ {
+ cstr = cr;
+ break;
+ }
+ }
+ p++;
+ }
+ if (p!=q) s_write (q, p-q);
+ if (cstr) s_write (cstr,2), p++;
+ }
+ } else while (p < buf+len) {