- }
- /*
- * Weird loop. Copy the buffer to the pty
- * and stopping on the escape character
- * in a hopefully efficient way.
- * Probably a good thing to make wwibc == 1 a special
- * case.
- */
- for (p = wwibp, n = wwibc;;) {
- if (--n < 0) {
- (void) write(selwin->ww_pty, wwibp, wwibc);
- wwibc = 0;
- break;
- }
- if (*p++ == escapec) {
- if ((n = p - wwibp) > 1)
- (void) write(selwin->ww_pty,
- wwibp, n - 1);
- wwibp = p;
- wwibc -= n;
- incmd = 1;
- break;
+ if (wwibp < wwibq) {
+ for (p = wwibp; p < wwibq && *p != escapec;
+ p++)
+ ;
+ if ((n = p - wwibp) > 0) {
+ (void) write(wwcurwin->ww_pty,
+ wwibp, n);
+ wwibp = p;
+ }
+ if (wwpeekc() == escapec) {
+ (void) wwgetc();
+ setcmd(1);
+ }