clipboard: improve EOL conversion of plain text
Handle the case of clipboard text with CR line endings
This commit is contained in:
		| @ -1068,23 +1068,30 @@ transmute_cf_unicodetext_to_utf8_string (const guchar    *data, | ||||
|                                          gint            *set_data_length, | ||||
|                                          GDestroyNotify  *set_data_destroy) | ||||
| { | ||||
|   wchar_t *ptr, *p, *q; | ||||
|   wchar_t *ptr, *p, *q, *endp; | ||||
|   gchar *result; | ||||
|   glong wclen, u8_len; | ||||
|  | ||||
|   /* Strip out \r */ | ||||
|   /* Replace CR and CR+LF with LF */ | ||||
|   ptr = (wchar_t *) data; | ||||
|   p = ptr; | ||||
|   q = ptr; | ||||
|   endp = ptr + length / 2; | ||||
|   wclen = 0; | ||||
|  | ||||
|   while (p < ptr + length / 2) | ||||
|   while (p < endp) | ||||
|     { | ||||
|       if (*p != L'\r') | ||||
|         { | ||||
|           *q++ = *p; | ||||
|           wclen++; | ||||
|         } | ||||
|       else if (p + 1 >= endp || *(p + 1) != L'\n') | ||||
|         { | ||||
|           *q++ = L'\n'; | ||||
|           wclen++; | ||||
|         } | ||||
|  | ||||
|       p++; | ||||
|     } | ||||
|  | ||||
| @ -1269,24 +1276,31 @@ transmute_cf_text_to_utf8_string (const guchar    *data, | ||||
|                                   gint            *set_data_length, | ||||
|                                   GDestroyNotify  *set_data_destroy) | ||||
| { | ||||
|   char *ptr, *p, *q; | ||||
|   char *ptr, *p, *q, *endp; | ||||
|   gchar *result; | ||||
|   glong wclen, u8_len; | ||||
|   wchar_t *wstr; | ||||
|  | ||||
|   /* Strip out \r */ | ||||
|   /* Replace CR and CR+LF with LF */ | ||||
|   ptr = (gchar *) data; | ||||
|   p = ptr; | ||||
|   q = ptr; | ||||
|   endp = ptr + length / 2; | ||||
|   wclen = 0; | ||||
|  | ||||
|   while (p < ptr + length / 2) | ||||
|   while (p < endp) | ||||
|     { | ||||
|       if (*p != '\r') | ||||
|         { | ||||
|           *q++ = *p; | ||||
|           wclen++; | ||||
|         } | ||||
|       else if (p + 1 > endp || *(p + 1) != '\n') | ||||
|         { | ||||
|           *q++ = '\n'; | ||||
|           wclen++; | ||||
|         } | ||||
|  | ||||
|       p++; | ||||
|     } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Ignazio Pillai
					Ignazio Pillai