summaryrefslogtreecommitdiff
path: root/data/vim/patches/7.2.017
blob: 99979a152fbb128c592cb07cbc40655b033c4c40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
To: vim-dev@vim.org
Subject: Patch 7.2.017
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.017
Problem:    strlen() used on text that may not end in a NUL. (Dominique Pelle)
	    Pasting a very big selection doesn't work.
Solution:   Use the length passed to the XtSelectionCallbackProc() function.
	    After getting the SelectionNotify event continue dispatching
	    events until the callback is actually called.  Also dispatch the
	    PropertyNotify event.
Files:	    src/ui.c


*** ../vim-7.2.016/src/ui.c	Sun Sep  7 21:47:51 2008
--- src/ui.c	Sun Sep 14 15:52:19 2008
***************
*** 2020,2026 ****
  
      if (value == NULL || *length == 0)
      {
! 	clip_free_selection(cbd);	/* ???  [what's the query?] */
  	*(int *)success = FALSE;
  	return;
      }
--- 2020,2026 ----
  
      if (value == NULL || *length == 0)
      {
! 	clip_free_selection(cbd);	/* nothing received, clear register */
  	*(int *)success = FALSE;
  	return;
      }
***************
*** 2076,2082 ****
  	text_prop.value = (unsigned char *)value;
  	text_prop.encoding = *type;
  	text_prop.format = *format;
! 	text_prop.nitems = STRLEN(value);
  	status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
  							 &text_list, &n_text);
  	if (status != Success || n_text < 1)
--- 2076,2082 ----
  	text_prop.value = (unsigned char *)value;
  	text_prop.encoding = *type;
  	text_prop.format = *format;
! 	text_prop.nitems = len;
  	status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
  							 &text_list, &n_text);
  	if (status != Success || n_text < 1)
***************
*** 2131,2137 ****
  	    case 3:  type = text_atom;		break;
  	    default: type = XA_STRING;
  	}
! 	success = FALSE;
  	XtGetSelectionValue(myShell, cbd->sel_atom, type,
  	    clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
  
--- 2131,2137 ----
  	    case 3:  type = text_atom;		break;
  	    default: type = XA_STRING;
  	}
! 	success = MAYBE;
  	XtGetSelectionValue(myShell, cbd->sel_atom, type,
  	    clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
  
***************
*** 2145,2169 ****
  	 * paste!  Don't worry, we will catch up with any other events later.
  	 */
  	start_time = time(NULL);
! 	for (;;)
  	{
! 	    if (XCheckTypedEvent(dpy, SelectionNotify, &event))
  	    {
! 		/* this is where clip_x11_request_selection_cb() is actually
! 		 * called */
  		XtDispatchEvent(&event);
! 		break;
  	    }
- 	    if (XCheckTypedEvent(dpy, SelectionRequest, &event))
- 		/* We may get a SelectionRequest here and if we don't handle
- 		 * it we hang.  KDE klipper does this, for example. */
- 		XtDispatchEvent(&event);
  
  	    /* Time out after 2 to 3 seconds to avoid that we hang when the
  	     * other process doesn't respond.  Note that the SelectionNotify
  	     * event may still come later when the selection owner comes back
! 	     * to life and the text gets inserted unexpectedly (by xterm).
! 	     * Don't know how to avoid that :-(. */
  	    if (time(NULL) > start_time + 2)
  	    {
  		timed_out = TRUE;
--- 2145,2171 ----
  	 * paste!  Don't worry, we will catch up with any other events later.
  	 */
  	start_time = time(NULL);
! 	while (success == MAYBE)
  	{
! 	    if (XCheckTypedEvent(dpy, SelectionNotify, &event)
! 		    || XCheckTypedEvent(dpy, SelectionRequest, &event)
! 		    || XCheckTypedEvent(dpy, PropertyNotify, &event))
  	    {
! 		/* This is where clip_x11_request_selection_cb() should be
! 		 * called.  It may actually happen a bit later, so we loop
! 		 * until "success" changes.
! 		 * We may get a SelectionRequest here and if we don't handle
! 		 * it we hang.  KDE klipper does this, for example.
! 		 * We need to handle a PropertyNotify for large selections. */
  		XtDispatchEvent(&event);
! 		continue;
  	    }
  
  	    /* Time out after 2 to 3 seconds to avoid that we hang when the
  	     * other process doesn't respond.  Note that the SelectionNotify
  	     * event may still come later when the selection owner comes back
! 	     * to life and the text gets inserted unexpectedly.  Don't know
! 	     * why that happens or how to avoid that :-(. */
  	    if (time(NULL) > start_time + 2)
  	    {
  		timed_out = TRUE;
***************
*** 2177,2183 ****
  	    ui_delay(1L, TRUE);
  	}
  
! 	if (success)
  	    return;
  
  	/* don't do a retry with another type after timing out, otherwise we
--- 2179,2185 ----
  	    ui_delay(1L, TRUE);
  	}
  
! 	if (success == TRUE)
  	    return;
  
  	/* don't do a retry with another type after timing out, otherwise we
*** ../vim-7.2.016/src/version.c	Sun Sep 14 14:41:44 2008
--- src/version.c	Sun Sep 14 15:55:34 2008
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     17,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
54. You start tilting your head sideways to smile. :-)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///