Alexandre Julliard : winex11: Simplify the clipboard HTML export function.
Alexandre Julliard
julliard at winehq.org
Wed May 10 17:23:18 CDT 2017
Module: wine
Branch: master
Commit: 0bdebc66c634098e24258abcbc80403243356a5a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0bdebc66c634098e24258abcbc80403243356a5a
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed May 10 15:28:12 2017 -0500
winex11: Simplify the clipboard HTML export function.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winex11.drv/clipboard.c | 61 +++++++++++---------------------------------
1 file changed, 15 insertions(+), 46 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index 4cb8cb8..2566d01 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -1293,28 +1293,6 @@ static BOOL export_enhmetafile( Display *display, Window win, Atom prop, Atom ta
/**************************************************************************
- * get_html_description_field
- *
- * Find the value of a field in an HTML Format description.
- */
-static LPCSTR get_html_description_field(LPCSTR data, LPCSTR keyword)
-{
- LPCSTR pos=data;
-
- while (pos && *pos && *pos != '<')
- {
- if (memcmp(pos, keyword, strlen(keyword)) == 0)
- return pos+strlen(keyword);
-
- pos = strchr(pos, '\n');
- if (pos) pos++;
- }
-
- return NULL;
-}
-
-
-/**************************************************************************
* export_text_html
*
* Export HTML Format to text/html.
@@ -1323,36 +1301,27 @@ static LPCSTR get_html_description_field(LPCSTR data, LPCSTR keyword)
*/
static BOOL export_text_html( Display *display, Window win, Atom prop, Atom target, HANDLE handle )
{
- LPCSTR data, field_value;
- UINT fragmentstart, fragmentend;
-
- data = GlobalLock( handle );
+ const char *p, *data;
+ UINT start = 0, end = 0;
+ BOOL ret = TRUE;
- /* read the important fields */
- field_value = get_html_description_field(data, "StartFragment:");
- if (!field_value)
- {
- ERR("Couldn't find StartFragment value\n");
- goto failed;
- }
- fragmentstart = atoi(field_value);
+ if (!(data = GlobalLock( handle ))) return FALSE;
- field_value = get_html_description_field(data, "EndFragment:");
- if (!field_value)
+ p = data;
+ while (*p && *p != '<')
{
- ERR("Couldn't find EndFragment value\n");
- goto failed;
+ if (!strncmp( p, "StartFragment:", 14 )) start = atoi( p + 14 );
+ else if (!strncmp( p, "EndFragment:", 12 )) end = atoi( p + 12 );
+ if (!(p = strpbrk( p, "\r\n" ))) break;
+ while (*p == '\r' || *p == '\n') p++;
}
- fragmentend = atoi(field_value);
-
- /* export only the fragment */
- put_property( display, win, prop, target, 8, &data[fragmentstart], fragmentend - fragmentstart );
- GlobalUnlock( handle );
- return TRUE;
+ if (start && start < end && end <= GlobalSize( handle ))
+ put_property( display, win, prop, target, 8, data + start, end - start );
+ else
+ ret = FALSE;
-failed:
GlobalUnlock( handle );
- return FALSE;
+ return ret;
}
More information about the wine-cvs
mailing list