commit dd73705611ada36019e58fdd8f27fa59aae7e975 from: Russ Cox date: Sat Sep 12 23:38:54 2009 UTC devdraw: update OS X snarf for 32-bit Rune fixes #29 http://code.swtch.com/plan9port/issues/29/ http://codereview.appspot.com/117057 commit - 6ad28910942886749e259f58505ee23fea04f267 commit + dd73705611ada36019e58fdd8f27fa59aae7e975 blob - 7c686ed953302c38c49f41e12d1f51ffa00c4977 blob + abf276aac570031f1e1a2642db5bdd5cc3571b7c --- src/cmd/devdraw/osx-screen.c +++ src/cmd/devdraw/osx-screen.c @@ -732,7 +732,7 @@ struct { char* getsnarf(void) { - char *s; + char *s, *t; CFArrayRef flavors; CFDataRef data; CFIndex nflavor, ndata, j; @@ -741,9 +741,6 @@ getsnarf(void) PasteboardItemID id; PasteboardSyncFlags flags; UInt32 i; - u16int *u; - Fmt fmt; - Rune r; /* fprint(2, "applegetsnarf\n"); */ qlock(&clip.lk); @@ -778,26 +775,15 @@ getsnarf(void) continue; if(PasteboardCopyItemFlavorData(clip.apple, id, type, &data) != noErr) continue; + ndata = CFDataGetLength(data); qunlock(&clip.lk); - ndata = CFDataGetLength(data)/2; - u = (u16int*)CFDataGetBytePtr(data); - fmtstrinit(&fmt); - // decode utf-16. what was apple thinking? - for(i=0; i= 0x10000) { - r -= 0x10000; - *p++ = 0xd800 + (r>>10); - *p++ = 0xdc00 + (r & ((1<<10)-1)); - } else - *p++ = r; - } + assert(sizeof(clip.rbuf[0]) == 2); cfdata = CFDataCreate(kCFAllocatorDefault, - (uchar*)u, (p-u)*2); - free(u); + (uchar*)clip.rbuf, runestrlen(clip.rbuf)*2); if(cfdata == nil){ fprint(2, "apple pasteboard cfdatacreate failed\n"); qunlock(&clip.lk);