diff options
| author | Eli Zaretskii | 1999-03-03 14:51:07 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 1999-03-03 14:51:07 +0000 |
| commit | 4029384bd476658dbb3bc819ecba4448923b49da (patch) | |
| tree | 2e01cdc09427189aaaac86e20e825ea04948f9c4 /src | |
| parent | c569512a3560cfc0f8e23e2397cbb06ce0470330 (diff) | |
| download | emacs-4029384bd476658dbb3bc819ecba4448923b49da.tar.gz emacs-4029384bd476658dbb3bc819ecba4448923b49da.zip | |
(get_clipboard_data): Always stop at the first null byte.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w16select.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/w16select.c b/src/w16select.c index b1f4b3adeba..674be37544e 100644 --- a/src/w16select.c +++ b/src/w16select.c | |||
| @@ -369,15 +369,6 @@ 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 | /* Copying text from the DOS box on Windows 95 evidently doubles the | ||
| 373 | size of text as reported by the clipboard. So we must begin | ||
| 374 | looking for the zeroes as if the actual size were half of what's | ||
| 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); | ||
| 381 | 372 | ||
| 382 | if (Format != CF_OEMTEXT) | 373 | if (Format != CF_OEMTEXT) |
| 383 | return 0; | 374 | return 0; |
| @@ -424,23 +415,22 @@ get_clipboard_data (Format, Data, Size, Raw) | |||
| 424 | dp--; | 415 | dp--; |
| 425 | *dp++ = '\n'; | 416 | *dp++ = '\n'; |
| 426 | xbuf_addr++; | 417 | xbuf_addr++; |
| 427 | if (last_block > dp) | ||
| 428 | last_block--; /* adjust the beginning of the last 32 bytes */ | ||
| 429 | if (*lcdp == '\n') | 418 | if (*lcdp == '\n') |
| 430 | lcdp++; | 419 | lcdp++; |
| 431 | } | 420 | } |
| 432 | /* Windows reportedly rounds up the size of clipboard data | 421 | /* Windows reportedly rounds up the size of clipboard data |
| 433 | (passed in SIZE) to a multiple of 32. We therefore bail | 422 | (passed in SIZE) to a multiple of 32, and removes trailing |
| 434 | out when we see the first null character in the last 32-byte | 423 | spaces from each line without updating SIZE. We therefore |
| 435 | block. */ | 424 | bail out when we see the first null character. */ |
| 436 | else if (c == '\0' && dp > last_block) | 425 | else if (c == '\0') |
| 437 | break; | 426 | break; |
| 438 | } | 427 | } |
| 439 | 428 | ||
| 440 | /* If the text in clipboard is identical to what we put there | 429 | /* If the text in clipboard is identical to what we put there |
| 441 | last time set_clipboard_data was called, pretend there's no | 430 | last time set_clipboard_data was called, pretend there's no |
| 442 | data in the clipboard. This is so we don't pass our own text | 431 | data in the clipboard. This is so we don't pass our own text |
| 443 | from the clipboard. */ | 432 | from the clipboard (which might be troublesome if the killed |
| 433 | text includes null characters). */ | ||
| 444 | if (last_clipboard_text && | 434 | if (last_clipboard_text && |
| 445 | xbuf_addr - xbuf_beg == (long)(lcdp - last_clipboard_text)) | 435 | xbuf_addr - xbuf_beg == (long)(lcdp - last_clipboard_text)) |
| 446 | dp = (unsigned char *)Data + 1; | 436 | dp = (unsigned char *)Data + 1; |