Mercurial > pidgin.yaz
changeset 10016:5b4a0af99bf7
[gaim-migrate @ 10935]
(15:16:26) datallah: LSchiere: are you still planning to commit that
gtkimhtml change to HEAD?
(15:16:37) LSchiere: datallah: yes let me do that now
for those that don't remember, this makes pasting on win32 suck less
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 11 Sep 2004 19:18:58 +0000 |
parents | ab342e285f3a |
children | ef935958e84c |
files | src/gtkimhtml.c |
diffstat | 1 files changed, 27 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkimhtml.c Sat Sep 11 16:55:09 2004 +0000 +++ b/src/gtkimhtml.c Sat Sep 11 19:18:58 2004 +0000 @@ -151,9 +151,11 @@ clipboard_win32_to_html(char *clipboard) { const char *header; const char *begin, *end; - gint start=0; - gint finish=0; + gint start = 0; + gint finish = 0; gchar *html; + gchar **split; + int clipboard_length = 0; #if 0 /* Debugging for Windows clipboard */ FILE *fd; @@ -165,25 +167,38 @@ fclose(fd); #endif - if (!(header = strstr(clipboard, "StartFragment:"))) + clipboard_length = strlen(clipboard); + + if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) return NULL; - sscanf(header, "StartFragment:%d", &start); - header = strstr(clipboard, "EndFragment:"); + if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) + return NULL; sscanf(header, "EndFragment:%d", &finish); + if (finish > clipboard_length) + finish = clipboard_length; + + if (start > finish) + start = finish; + begin = clipboard + start; - if (header == NULL) - end = clipboard + strlen(clipboard); - else - end = clipboard + finish; - - html = g_strstrip(g_strndup(begin, end-begin)); + end = clipboard + finish; + + html = g_strndup(begin, end - begin); + + /* any newlines in the string will now be \r\n, so we need to strip out the \r */ + split = g_strsplit(html, "\r\n", 0); + g_free(html); + html = g_strjoinv("\n", split); + g_strfreev(split); + + html = g_strstrip(html); #if 0 /* Debugging for Windows clipboard */ - gaim_debug_info("imhtml clipboard", "HTML fragment: %s\n", html); + gaim_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); #endif return html;