aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii1999-02-15 15:14:47 +0000
committerEli Zaretskii1999-02-15 15:14:47 +0000
commitcc6d8c5b60d02946f5b5fb149a8ba9c0c670aba2 (patch)
tree45e099fb7bc995c223922c5dc4a70dfccfb3ea61 /src
parent1468535ed1694af3a245efbbbfc330082a55c2a6 (diff)
downloademacs-cc6d8c5b60d02946f5b5fb149a8ba9c0c670aba2.tar.gz
emacs-cc6d8c5b60d02946f5b5fb149a8ba9c0c670aba2.zip
(get_clipboard_data): Work around a bug in Windows95
DOS box which doubles the reported size of text in the clipboard.
Diffstat (limited to 'src')
-rw-r--r--src/w16select.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/w16select.c b/src/w16select.c
index 68e958fa427..b1f4b3adeba 100644
--- a/src/w16select.c
+++ b/src/w16select.c
@@ -369,10 +369,15 @@ get_clipboard_data (Format, Data, Size, Raw)
369 __dpmi_regs regs; 369 __dpmi_regs regs;
370 unsigned long xbuf_addr; 370 unsigned long xbuf_addr;
371 unsigned char *dp = Data; 371 unsigned char *dp = Data;
372 /* The last 32-byte aligned block of data. See commentary below. */ 372 /* Copying text from the DOS box on Windows 95 evidently doubles the
373 unsigned char *last_block = dp + ((Size & 0x1f) 373 size of text as reported by the clipboard. So we must begin
374 ? (Size & 0x20) 374 looking for the zeroes as if the actual size were half of what's
375 : Size - 0x20); 375 reported. Jeez, what a mess! */
376 unsigned half_size = Size > 32 ? Size / 2 : Size;
377 /* Where we should begin looking for zeroes. See commentary below. */
378 unsigned char *last_block = dp + ((half_size & 0x1f)
379 ? (half_size & 0x20)
380 : half_size - 0x20);
376 381
377 if (Format != CF_OEMTEXT) 382 if (Format != CF_OEMTEXT)
378 return 0; 383 return 0;
@@ -419,7 +424,8 @@ get_clipboard_data (Format, Data, Size, Raw)
419 dp--; 424 dp--;
420 *dp++ = '\n'; 425 *dp++ = '\n';
421 xbuf_addr++; 426 xbuf_addr++;
422 last_block--; /* adjust the beginning of the last 32 bytes */ 427 if (last_block > dp)
428 last_block--; /* adjust the beginning of the last 32 bytes */
423 if (*lcdp == '\n') 429 if (*lcdp == '\n')
424 lcdp++; 430 lcdp++;
425 } 431 }