|
Karsten Hopp |
8b5295 |
To: vim-dev@vim.org
|
|
Karsten Hopp |
8b5295 |
Subject: Patch 7.2.017
|
|
Karsten Hopp |
8b5295 |
Fcc: outbox
|
|
Karsten Hopp |
8b5295 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
8b5295 |
Mime-Version: 1.0
|
|
Karsten Hopp |
8b5295 |
Content-Type: text/plain; charset=ISO-8859-1
|
|
Karsten Hopp |
8b5295 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
8b5295 |
------------
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
Patch 7.2.017
|
|
Karsten Hopp |
8b5295 |
Problem: strlen() used on text that may not end in a NUL. (Dominique Pelle)
|
|
Karsten Hopp |
8b5295 |
Pasting a very big selection doesn't work.
|
|
Karsten Hopp |
8b5295 |
Solution: Use the length passed to the XtSelectionCallbackProc() function.
|
|
Karsten Hopp |
8b5295 |
After getting the SelectionNotify event continue dispatching
|
|
Karsten Hopp |
8b5295 |
events until the callback is actually called. Also dispatch the
|
|
Karsten Hopp |
8b5295 |
PropertyNotify event.
|
|
Karsten Hopp |
8b5295 |
Files: src/ui.c
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
*** ../vim-7.2.016/src/ui.c Sun Sep 7 21:47:51 2008
|
|
Karsten Hopp |
8b5295 |
--- src/ui.c Sun Sep 14 15:52:19 2008
|
|
Karsten Hopp |
8b5295 |
***************
|
|
Karsten Hopp |
8b5295 |
*** 2020,2026 ****
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
if (value == NULL || *length == 0)
|
|
Karsten Hopp |
8b5295 |
{
|
|
Karsten Hopp |
8b5295 |
! clip_free_selection(cbd); /* ??? [what's the query?] */
|
|
Karsten Hopp |
8b5295 |
*(int *)success = FALSE;
|
|
Karsten Hopp |
8b5295 |
return;
|
|
Karsten Hopp |
8b5295 |
}
|
|
Karsten Hopp |
8b5295 |
--- 2020,2026 ----
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
if (value == NULL || *length == 0)
|
|
Karsten Hopp |
8b5295 |
{
|
|
Karsten Hopp |
8b5295 |
! clip_free_selection(cbd); /* nothing received, clear register */
|
|
Karsten Hopp |
8b5295 |
*(int *)success = FALSE;
|
|
Karsten Hopp |
8b5295 |
return;
|
|
Karsten Hopp |
8b5295 |
}
|
|
Karsten Hopp |
8b5295 |
***************
|
|
Karsten Hopp |
8b5295 |
*** 2076,2082 ****
|
|
Karsten Hopp |
8b5295 |
text_prop.value = (unsigned char *)value;
|
|
Karsten Hopp |
8b5295 |
text_prop.encoding = *type;
|
|
Karsten Hopp |
8b5295 |
text_prop.format = *format;
|
|
Karsten Hopp |
8b5295 |
! text_prop.nitems = STRLEN(value);
|
|
Karsten Hopp |
8b5295 |
status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
|
|
Karsten Hopp |
8b5295 |
&text_list, &n_text);
|
|
Karsten Hopp |
8b5295 |
if (status != Success || n_text < 1)
|
|
Karsten Hopp |
8b5295 |
--- 2076,2082 ----
|
|
Karsten Hopp |
8b5295 |
text_prop.value = (unsigned char *)value;
|
|
Karsten Hopp |
8b5295 |
text_prop.encoding = *type;
|
|
Karsten Hopp |
8b5295 |
text_prop.format = *format;
|
|
Karsten Hopp |
8b5295 |
! text_prop.nitems = len;
|
|
Karsten Hopp |
8b5295 |
status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
|
|
Karsten Hopp |
8b5295 |
&text_list, &n_text);
|
|
Karsten Hopp |
8b5295 |
if (status != Success || n_text < 1)
|
|
Karsten Hopp |
8b5295 |
***************
|
|
Karsten Hopp |
8b5295 |
*** 2131,2137 ****
|
|
Karsten Hopp |
8b5295 |
case 3: type = text_atom; break;
|
|
Karsten Hopp |
8b5295 |
default: type = XA_STRING;
|
|
Karsten Hopp |
8b5295 |
}
|
|
Karsten Hopp |
8b5295 |
! success = FALSE;
|
|
Karsten Hopp |
8b5295 |
XtGetSelectionValue(myShell, cbd->sel_atom, type,
|
|
Karsten Hopp |
8b5295 |
clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
--- 2131,2137 ----
|
|
Karsten Hopp |
8b5295 |
case 3: type = text_atom; break;
|
|
Karsten Hopp |
8b5295 |
default: type = XA_STRING;
|
|
Karsten Hopp |
8b5295 |
}
|
|
Karsten Hopp |
8b5295 |
! success = MAYBE;
|
|
Karsten Hopp |
8b5295 |
XtGetSelectionValue(myShell, cbd->sel_atom, type,
|
|
Karsten Hopp |
8b5295 |
clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
***************
|
|
Karsten Hopp |
8b5295 |
*** 2145,2169 ****
|
|
Karsten Hopp |
8b5295 |
* paste! Don't worry, we will catch up with any other events later.
|
|
Karsten Hopp |
8b5295 |
*/
|
|
Karsten Hopp |
8b5295 |
start_time = time(NULL);
|
|
Karsten Hopp |
8b5295 |
! for (;;)
|
|
Karsten Hopp |
8b5295 |
{
|
|
Karsten Hopp |
8b5295 |
! if (XCheckTypedEvent(dpy, SelectionNotify, &event))
|
|
Karsten Hopp |
8b5295 |
{
|
|
Karsten Hopp |
8b5295 |
! /* this is where clip_x11_request_selection_cb() is actually
|
|
Karsten Hopp |
8b5295 |
! * called */
|
|
Karsten Hopp |
8b5295 |
XtDispatchEvent(&event);
|
|
Karsten Hopp |
8b5295 |
! break;
|
|
Karsten Hopp |
8b5295 |
}
|
|
Karsten Hopp |
8b5295 |
- if (XCheckTypedEvent(dpy, SelectionRequest, &event))
|
|
Karsten Hopp |
8b5295 |
- /* We may get a SelectionRequest here and if we don't handle
|
|
Karsten Hopp |
8b5295 |
- * it we hang. KDE klipper does this, for example. */
|
|
Karsten Hopp |
8b5295 |
- XtDispatchEvent(&event);
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
/* Time out after 2 to 3 seconds to avoid that we hang when the
|
|
Karsten Hopp |
8b5295 |
* other process doesn't respond. Note that the SelectionNotify
|
|
Karsten Hopp |
8b5295 |
* event may still come later when the selection owner comes back
|
|
Karsten Hopp |
8b5295 |
! * to life and the text gets inserted unexpectedly (by xterm).
|
|
Karsten Hopp |
8b5295 |
! * Don't know how to avoid that :-(. */
|
|
Karsten Hopp |
8b5295 |
if (time(NULL) > start_time + 2)
|
|
Karsten Hopp |
8b5295 |
{
|
|
Karsten Hopp |
8b5295 |
timed_out = TRUE;
|
|
Karsten Hopp |
8b5295 |
--- 2145,2171 ----
|
|
Karsten Hopp |
8b5295 |
* paste! Don't worry, we will catch up with any other events later.
|
|
Karsten Hopp |
8b5295 |
*/
|
|
Karsten Hopp |
8b5295 |
start_time = time(NULL);
|
|
Karsten Hopp |
8b5295 |
! while (success == MAYBE)
|
|
Karsten Hopp |
8b5295 |
{
|
|
Karsten Hopp |
8b5295 |
! if (XCheckTypedEvent(dpy, SelectionNotify, &event)
|
|
Karsten Hopp |
8b5295 |
! || XCheckTypedEvent(dpy, SelectionRequest, &event)
|
|
Karsten Hopp |
8b5295 |
! || XCheckTypedEvent(dpy, PropertyNotify, &event))
|
|
Karsten Hopp |
8b5295 |
{
|
|
Karsten Hopp |
8b5295 |
! /* This is where clip_x11_request_selection_cb() should be
|
|
Karsten Hopp |
8b5295 |
! * called. It may actually happen a bit later, so we loop
|
|
Karsten Hopp |
8b5295 |
! * until "success" changes.
|
|
Karsten Hopp |
8b5295 |
! * We may get a SelectionRequest here and if we don't handle
|
|
Karsten Hopp |
8b5295 |
! * it we hang. KDE klipper does this, for example.
|
|
Karsten Hopp |
8b5295 |
! * We need to handle a PropertyNotify for large selections. */
|
|
Karsten Hopp |
8b5295 |
XtDispatchEvent(&event);
|
|
Karsten Hopp |
8b5295 |
! continue;
|
|
Karsten Hopp |
8b5295 |
}
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
/* Time out after 2 to 3 seconds to avoid that we hang when the
|
|
Karsten Hopp |
8b5295 |
* other process doesn't respond. Note that the SelectionNotify
|
|
Karsten Hopp |
8b5295 |
* event may still come later when the selection owner comes back
|
|
Karsten Hopp |
8b5295 |
! * to life and the text gets inserted unexpectedly. Don't know
|
|
Karsten Hopp |
8b5295 |
! * why that happens or how to avoid that :-(. */
|
|
Karsten Hopp |
8b5295 |
if (time(NULL) > start_time + 2)
|
|
Karsten Hopp |
8b5295 |
{
|
|
Karsten Hopp |
8b5295 |
timed_out = TRUE;
|
|
Karsten Hopp |
8b5295 |
***************
|
|
Karsten Hopp |
8b5295 |
*** 2177,2183 ****
|
|
Karsten Hopp |
8b5295 |
ui_delay(1L, TRUE);
|
|
Karsten Hopp |
8b5295 |
}
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
! if (success)
|
|
Karsten Hopp |
8b5295 |
return;
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
/* don't do a retry with another type after timing out, otherwise we
|
|
Karsten Hopp |
8b5295 |
--- 2179,2185 ----
|
|
Karsten Hopp |
8b5295 |
ui_delay(1L, TRUE);
|
|
Karsten Hopp |
8b5295 |
}
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
! if (success == TRUE)
|
|
Karsten Hopp |
8b5295 |
return;
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
/* don't do a retry with another type after timing out, otherwise we
|
|
Karsten Hopp |
8b5295 |
*** ../vim-7.2.016/src/version.c Sun Sep 14 14:41:44 2008
|
|
Karsten Hopp |
8b5295 |
--- src/version.c Sun Sep 14 15:55:34 2008
|
|
Karsten Hopp |
8b5295 |
***************
|
|
Karsten Hopp |
8b5295 |
*** 678,679 ****
|
|
Karsten Hopp |
8b5295 |
--- 678,681 ----
|
|
Karsten Hopp |
8b5295 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
8b5295 |
+ /**/
|
|
Karsten Hopp |
8b5295 |
+ 17,
|
|
Karsten Hopp |
8b5295 |
/**/
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
--
|
|
Karsten Hopp |
8b5295 |
hundred-and-one symptoms of being an internet addict:
|
|
Karsten Hopp |
8b5295 |
54. You start tilting your head sideways to smile. :-)
|
|
Karsten Hopp |
8b5295 |
|
|
Karsten Hopp |
8b5295 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
8b5295 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
8b5295 |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
8b5295 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|