break; case ATTR_SCOACS: uc = unitab_scoacs[uc&0xFF];
static void clipme(pos top, pos bottom){    wchar_t *workbuf;    wchar_t *wbptr;		       /* where next char goes within workbuf */    int wblen = 0;		       /* workbuf len */    int buflen;			       /* amount of memory allocated to workbuf */    buflen = 5120;		       /* Default size */    workbuf = smalloc(buflen * sizeof(wchar_t));    wbptr = workbuf;		       /* start filling here */    while (poslt(top, bottom)) {	int nl = FALSE;	unsigned long *ldata = lineptr(top.y);	pos nlpos;	nlpos.y = top.y;	nlpos.x = cols;	if (!(ldata[cols] & LATTR_WRAPPED)) {	    while (((ldata[nlpos.x - 1] & 0xFF) == 0x20 ||		    (DIRECT_CHAR(ldata[nlpos.x - 1]) &&		     (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)) {#if 0	    char cbuf[16], *p;	    sprintf(cbuf, "<U+%04x>", (ldata[top.x] & 0xFFFF));#else	    wchar_t cbuf[16], *p;	    int uc = (ldata[top.x] & 0xFFFF);	    int set, c;	    if (uc == UCSWIDE) {		top.x++;		continue;	    }	    switch (uc & CSET_MASK) {	      case ATTR_LINEDRW:		if (!cfg.rawcnp) {		    uc = unitab_xterm[uc & 0xFF];		    break;		}	      case ATTR_ASCII:		uc = unitab_line[uc & 0xFF];		break;	    }	    switch (uc & CSET_MASK) {	      case ATTR_ACP:		uc = unitab_font[uc & 0xFF];		break;	      case ATTR_OEMCP:		uc = unitab_oemcp[uc & 0xFF];		break;	    }	    set = (uc & CSET_MASK);	    c = (uc & CHAR_MASK);	    cbuf[0] = uc;	    cbuf[1] = 0;	    if (DIRECT_FONT(uc)) {		if (c >= ' ' && c != 0x7F) {		    unsigned char buf[4];		    WCHAR wbuf[4];		    int rv;		    if (IsDBCSLeadByteEx(font_codepage, (BYTE) c)) {			buf[0] = c;			buf[1] = (unsigned char) ldata[top.x + 1];			rv = MultiByteToWideChar(font_codepage,						 0, buf, 2, wbuf, 4);			top.x++;		    } else {			buf[0] = c;			rv = MultiByteToWideChar(font_codepage,						 0, buf, 1, wbuf, 4);		    }		    if (rv > 0) {			memcpy(cbuf, wbuf, rv * sizeof(wchar_t));			cbuf[rv] = 0;		    }		}	    }#endif	    for (p = cbuf; *p; p++) {		/* Enough overhead for trailing NL and nul */		if (wblen >= buflen - 16) {		    workbuf =			srealloc(workbuf,				 sizeof(wchar_t) * (buflen += 100));		    wbptr = workbuf + wblen;		}		wblen++;		*wbptr++ = *p;	    }	    top.x++;	}	if (nl) {	    int i;	    for (i = 0; i < sel_nl_sz; i++) {		wblen++;		*wbptr++ = sel_nl[i];	    }	}	top.y++;	top.x = 0;    }    wblen++;    *wbptr++ = 0;    write_clip(workbuf, wblen, FALSE); /* transfer to clipboard */    if (buflen > 0)		       /* indicates we allocated this buffer */	sfree(workbuf);}