pos lineend, nlpos;
pos nlpos;
static void clipme(pos top, pos bottom, char *workbuf) {    char *wbptr;		/* where next char goes within workbuf */    int wblen = 0;		/* workbuf len */    int buflen;			/* amount of memory allocated to workbuf */    if ( workbuf != NULL ) {	/* user supplied buffer? */	buflen = -1;		/* assume buffer passed in is big enough */	wbptr = workbuf;	/* start filling here */    }    else	buflen = 0;		/* No data is available yet */    while (poslt(top, bottom)) {	int nl = FALSE;	unsigned long *ldata = lineptr(top.y);	pos lineend, nlpos;	nlpos.y = top.y;	nlpos.x = cols;	if (!(ldata[cols] & ATTR_WRAPPED)) {	    while ((ldata[nlpos.x-1] & CHAR_MASK) == 0x20 && poslt(top, nlpos))		decpos(nlpos);	    if (poslt(nlpos, bottom))		nl = TRUE;	}	while (poslt(top, bottom) && poslt(top, nlpos)) {	    int ch = (ldata[top.x] & CHAR_MASK);	    int set = (ldata[top.x] & CSET_MASK);	    /* VT Specials -> ISO8859-1 for Cut&Paste */	    static const unsigned char poorman2[] ="* # HTFFCRLF\xB0 \xB1 NLVT+ + + + + - - - - - + + + + | <=>=PI!=\xA3 \xB7 ";	    if (set && !cfg.rawcnp) {	        if (set == ATTR_LINEDRW && ch >= 0x60 && ch < 0x7F) {		    int x;		    if ((x = poorman2[2*(ch-0x60)+1]) == ' ')		        x = 0;		    ch = (x<<8) + poorman2[2*(ch-0x60)];	        }	    }	    while(ch != 0) {		if (cfg.rawcnp || !!(ch&0xE0)) {		    if ( wblen == buflen )		    {		        workbuf = srealloc(workbuf, buflen += 100);		        wbptr = workbuf + wblen;		    }		    wblen++;		    *wbptr++ = (unsigned char) ch;		}		ch>>=8;	    }	    top.x++;	}	if (nl) {	    int i;	    for (i=0; i<sizeof(sel_nl); i++)	    {		if ( wblen == buflen )		{		    workbuf = srealloc(workbuf, buflen += 100);		    wbptr = workbuf + wblen;		}	        wblen++;		*wbptr++ = sel_nl[i];	    }	}	top.y++;	top.x = 0;    }    write_clip (workbuf, wblen, FALSE);	/* transfer to clipboard */    if ( buflen > 0 )	/* indicates we allocated this buffer */	sfree(workbuf);}