len = ptr - buf; ptr = buf; while (len > 0) { n = screen->max_col - screen->cur_col +1; if (n <= 1) {
for (offset = 0; offset < len; offset += this_col) { last_col = CurMaxCol(screen, screen->cur_row); this_col = last_col - screen->cur_col +1; if (this_col <= 1) {
dotext(	register TScreen *screen,	int	charset,	Char	*buf,		/* start of characters to process */	Char	*ptr)		/* end */{	register int	len;	register int	n;	register int	next_col;	if (!xtermCharSets(buf, ptr, charset))		return;	if_OPT_XMC_GLITCH(screen,{		register Char	*s;		if (charset != '?')			for (s=buf; s<ptr; ++s)				if (*s == XMC_GLITCH)					*s = XMC_GLITCH+1;	})	len = ptr - buf;	ptr = buf;	while (len > 0) {		n = screen->max_col - screen->cur_col +1;		if (n <= 1) {			if (screen->do_wrap && (term->flags & WRAPAROUND)) {			    /* mark that we had to wrap this line */			    ScrnSetWrapped(screen, screen->cur_row);			    xtermAutoPrint('\n');			    Index(screen, 1);			    screen->cur_col = 0;			    screen->do_wrap = 0;			    n = screen->max_col+1;			} else			    n = 1;		}		if (len < n)			n = len;		next_col = screen->cur_col + n;		WriteText(screen, ptr, n);		/*		 * the call to WriteText updates screen->cur_col.		 * If screen->cur_col != next_col, we must have		 * hit the right margin, so set the do_wrap flag.		 */		screen->do_wrap = (screen->cur_col < next_col);		len -= n;		ptr += n;	}}