From 86c2948eb4d4fa75e28182472094d0812fabb29e Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 9 Feb 2011 20:31:34 +0000 Subject: Fix copying text/plain to clipboard svn path=/trunk/netsurf/; revision=11636 --- amiga/clipboard.c | 4 +++- atari/gui.c | 5 +++-- cocoa/selection.m | 4 +++- gtk/selection.c | 7 +++++-- riscos/textselection.c | 7 +++++-- windows/gui.c | 6 ++++-- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/amiga/clipboard.c b/amiga/clipboard.c index 61f60a087..177b5025c 100755 --- a/amiga/clipboard.c +++ b/amiga/clipboard.c @@ -246,7 +246,9 @@ bool ami_clipboard_copy(const char *text, size_t length, struct box *box, if(text) { - if (!ami_add_to_clipboard(text, length, box->space)) return false; + bool add_space = box != NULL ? box->space : false; + + if (!ami_add_to_clipboard(text, length, add_space)) return false; } PopChunk(iffh); diff --git a/atari/gui.c b/atari/gui.c index 9f1c3d1d3..c848f3ff5 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -876,14 +876,15 @@ gui_selection_traverse_handler(const char *text, const char *space_text, size_t space_length) { + bool add_space = box != NULL ? box->space : false; - if (space_text) { + if (space_text != NULL && space_length > 0) { if (!gui_add_to_clipboard(space_text, space_length, false)) { return false; } } - if (!gui_add_to_clipboard(text, length, box->space)) + if (!gui_add_to_clipboard(text, length, add_space)) return false; return true; diff --git a/cocoa/selection.m b/cocoa/selection.m index cb0c3dca9..208776ebb 100644 --- a/cocoa/selection.m +++ b/cocoa/selection.m @@ -72,9 +72,11 @@ static bool cocoa_clipboard_copy_handler(const char *text, size_t length, struct void *handle, const char *whitespace_text, size_t whitespace_length) { + bool add_space = box != NULL ? box->space : false; + if (whitespace_text && !gui_add_to_clipboard( whitespace_text, whitespace_length, false )) return false; - return gui_add_to_clipboard( text, length, box->space ); + return gui_add_to_clipboard( text, length, add_space ); } bool gui_commit_clipboard(void) diff --git a/gtk/selection.c b/gtk/selection.c index 68ab88f71..3ffd0db91 100644 --- a/gtk/selection.c +++ b/gtk/selection.c @@ -50,15 +50,18 @@ bool copy_handler(const char *text, size_t length, struct box *box, void *handle, const char *whitespace_text, size_t whitespace_length) { + bool add_space = box != NULL ? box->space : false; + /* add any whitespace which precedes the text from this box */ - if (whitespace_text) { + if (whitespace_text != NULL && whitespace_length > 0) { if (!gui_add_to_clipboard(whitespace_text, whitespace_length, false)) { return false; } } + /* add the text from this box */ - if (!gui_add_to_clipboard(text, length, box->space)) + if (!gui_add_to_clipboard(text, length, add_space)) return false; return true; diff --git a/riscos/textselection.c b/riscos/textselection.c index 369346ca0..07a87e50b 100644 --- a/riscos/textselection.c +++ b/riscos/textselection.c @@ -207,15 +207,18 @@ bool copy_handler(const char *text, size_t length, struct box *box, void *handle, const char *whitespace_text, size_t whitespace_length) { + bool add_space = box != NULL ? box->space : false; + /* add any whitespace which precedes the text from this box */ - if (whitespace_text) { + if (whitespace_text != NULL && whitespace_length > 0) { if (!gui_add_to_clipboard(whitespace_text, whitespace_length, false)) { return false; } } + /* add the text from this box */ - if (!gui_add_to_clipboard(text, length, box->space)) + if (!gui_add_to_clipboard(text, length, add_space)) return false; return true; diff --git a/windows/gui.c b/windows/gui.c index ba4dad571..03f3d67ec 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -2488,13 +2488,15 @@ gui_selection_traverse_handler(const char *text, const char *space_text, size_t space_length) { - if (space_text) { + bool add_space = box != NULL ? box->space : false; + + if (space_text != NULL && space_length > 0) { if (!gui_add_to_clipboard(space_text, space_length, false)) { return false; } } - if (!gui_add_to_clipboard(text, length, box->space)) + if (!gui_add_to_clipboard(text, length, add_space)) return false; return true; -- cgit v1.2.3