From 18db6826f1cd7c73dd5108210783c3ef7cc0ab2f Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 3 Aug 2012 18:15:16 +0100 Subject: [PATCH] Move Push- and PopChunk out of the selection_traversal function --- amiga/clipboard.c | 83 ++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 52 deletions(-) diff --git a/amiga/clipboard.c b/amiga/clipboard.c index b98ef574a..d6f286796 100755 --- a/amiga/clipboard.c +++ b/amiga/clipboard.c @@ -198,19 +198,9 @@ bool gui_add_to_clipboard(const char *text, size_t length, bool space) These only seem to be called from desktop/textinput.c in this specific order, if they are added elsewhere this might need a rewrite. */ - if(!(PushChunk(iffh,0,ID_CHRS,IFFSIZE_UNKNOWN))) + if(text) { - if(text) - { - if(!ami_add_to_clipboard(text, length, space)) return false; - } - - PopChunk(iffh); - } - else - { - PopChunk(iffh); - return false; + if(!ami_add_to_clipboard(text, length, space)) return false; } return true; @@ -220,33 +210,33 @@ bool ami_add_to_clipboard(const char *text, size_t length, bool space) { char *buffer; - if(nsoption_bool(utf8_clipboard) || ami_utf8_clipboard) - { - WriteChunkBytes(iffh,text,length); - } - else - { - buffer = ami_utf8_easy(text); + if(!(PushChunk(iffh,0,ID_CHRS,IFFSIZE_UNKNOWN))) { + if(nsoption_bool(utf8_clipboard) || ami_utf8_clipboard) { + WriteChunkBytes(iffh,text,length); + } else { + buffer = ami_utf8_easy(text); - if(buffer) - { - char *p; + if(buffer) { + char *p; - p = buffer; + p = buffer; - while(*p != '\0') - { - if(*p == 0xa0) *p = 0x20; - p++; + while(*p != '\0') { + if(*p == 0xa0) *p = 0x20; + p++; + } + WriteChunkBytes(iffh, buffer, strlen(buffer)); + ami_utf8_free(buffer); } - WriteChunkBytes(iffh, buffer, strlen(buffer)); - - ami_utf8_free(buffer); } + + if(space) WriteChunkBytes(iffh," ",1); + PopChunk(iffh); + } else { + PopChunk(iffh); + return false; } - - if(space) WriteChunkBytes(iffh," ",1); - + return true; } @@ -260,28 +250,17 @@ bool gui_commit_clipboard(void) bool ami_clipboard_copy(const char *text, size_t length, struct box *box, void *handle, const char *whitespace_text,size_t whitespace_length) { - if(!(PushChunk(iffh,0,ID_CHRS,IFFSIZE_UNKNOWN))) + if (whitespace_text) { - if (whitespace_text) - { - if(!ami_add_to_clipboard(whitespace_text,whitespace_length, false)) return false; - } - - if(text) - { - bool add_space = box != NULL ? box->space != 0 : false; - - if (!ami_add_to_clipboard(text, length, add_space)) return false; - } - - PopChunk(iffh); - } - else - { - PopChunk(iffh); - return false; + if(!ami_add_to_clipboard(whitespace_text,whitespace_length, false)) return false; } + if(text) + { + bool add_space = box != NULL ? box->space != 0 : false; + + if (!ami_add_to_clipboard(text, length, add_space)) return false; + } return true; }