Mercurial > pidgin
comparison src/gtkimhtml.c @ 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 | f1f239fa8973 |
children | b6178d85d132 |
comparison
equal
deleted
inserted
replaced
10015:ab342e285f3a | 10016:5b4a0af99bf7 |
---|---|
149 | 149 |
150 static gchar * | 150 static gchar * |
151 clipboard_win32_to_html(char *clipboard) { | 151 clipboard_win32_to_html(char *clipboard) { |
152 const char *header; | 152 const char *header; |
153 const char *begin, *end; | 153 const char *begin, *end; |
154 gint start=0; | 154 gint start = 0; |
155 gint finish=0; | 155 gint finish = 0; |
156 gchar *html; | 156 gchar *html; |
157 gchar **split; | |
158 int clipboard_length = 0; | |
157 | 159 |
158 #if 0 /* Debugging for Windows clipboard */ | 160 #if 0 /* Debugging for Windows clipboard */ |
159 FILE *fd; | 161 FILE *fd; |
160 | 162 |
161 gaim_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard); | 163 gaim_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard); |
163 fd = fopen("e:\\gaimcb.txt", "wb"); | 165 fd = fopen("e:\\gaimcb.txt", "wb"); |
164 fprintf(fd, "%s", clipboard); | 166 fprintf(fd, "%s", clipboard); |
165 fclose(fd); | 167 fclose(fd); |
166 #endif | 168 #endif |
167 | 169 |
168 if (!(header = strstr(clipboard, "StartFragment:"))) | 170 clipboard_length = strlen(clipboard); |
171 | |
172 if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) | |
169 return NULL; | 173 return NULL; |
170 | |
171 sscanf(header, "StartFragment:%d", &start); | 174 sscanf(header, "StartFragment:%d", &start); |
172 | 175 |
173 header = strstr(clipboard, "EndFragment:"); | 176 if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) |
177 return NULL; | |
174 sscanf(header, "EndFragment:%d", &finish); | 178 sscanf(header, "EndFragment:%d", &finish); |
175 | 179 |
180 if (finish > clipboard_length) | |
181 finish = clipboard_length; | |
182 | |
183 if (start > finish) | |
184 start = finish; | |
185 | |
176 begin = clipboard + start; | 186 begin = clipboard + start; |
177 | 187 |
178 if (header == NULL) | 188 end = clipboard + finish; |
179 end = clipboard + strlen(clipboard); | 189 |
180 else | 190 html = g_strndup(begin, end - begin); |
181 end = clipboard + finish; | 191 |
182 | 192 /* any newlines in the string will now be \r\n, so we need to strip out the \r */ |
183 html = g_strstrip(g_strndup(begin, end-begin)); | 193 split = g_strsplit(html, "\r\n", 0); |
194 g_free(html); | |
195 html = g_strjoinv("\n", split); | |
196 g_strfreev(split); | |
197 | |
198 html = g_strstrip(html); | |
184 | 199 |
185 #if 0 /* Debugging for Windows clipboard */ | 200 #if 0 /* Debugging for Windows clipboard */ |
186 gaim_debug_info("imhtml clipboard", "HTML fragment: %s\n", html); | 201 gaim_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); |
187 #endif | 202 #endif |
188 | 203 |
189 return html; | 204 return html; |
190 } | 205 } |
191 | 206 |