* coding.c (make_conversion_work_buffer): Disable buffer modification
[bpt/emacs.git] / src / xselect.c
index 0d09f13..9297310 100644 (file)
@@ -808,7 +808,7 @@ x_reply_selection_request (event, format, data, size, type)
        {
           int i = ((bytes_remaining < max_bytes)
                    ? bytes_remaining
-                   : max_bytes);
+                   : max_bytes) / format_bytes;
 
          BLOCK_INPUT;
 
@@ -816,15 +816,18 @@ x_reply_selection_request (event, format, data, size, type)
            = expect_property_change (display, window, reply.property,
                                      PropertyDelete);
 
-         TRACE1 ("Sending increment of %d bytes", i);
+         TRACE1 ("Sending increment of %d elements", i);
          TRACE1 ("Set %s to increment data",
                  XGetAtomName (display, reply.property));
 
          /* Append the next chunk of data to the property.  */
          XChangeProperty (display, window, reply.property, type, format,
-                          PropModeAppend, data, i / format_bytes);
-         bytes_remaining -= i;
-         data += i;
+                          PropModeAppend, data, i);
+         bytes_remaining -= i * format_bytes;
+         if (format == 32)
+           data += i * sizeof (long);
+         else
+           data += i * format_bytes;
          XFlush (display);
          had_errors = x_had_errors_p (display);
          UNBLOCK_INPUT;
@@ -1012,7 +1015,6 @@ x_handle_selection_clear (event)
 
   TRACE0 ("x_handle_selection_clear");
 
-#ifdef MULTI_KBOARD  
   /* If the new selection owner is also Emacs,
      don't clear the new selection.  */
   BLOCK_INPUT;
@@ -1031,7 +1033,6 @@ x_handle_selection_clear (event)
          }
       }
   UNBLOCK_INPUT;
-#endif
   
   selection_symbol = x_atom_to_symbol (display, selection);
 
@@ -1470,7 +1471,7 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
   if (NILP (XCAR (reading_selection_reply)))
     error ("Timed out waiting for reply from selection owner");
   if (EQ (XCAR (reading_selection_reply), Qlambda))
-    error ("No `%s' selection", SDATA (SYMBOL_NAME (selection_symbol)));
+    return Qnil;
 
   /* Otherwise, the selection is waiting for us on the requested property.  */
   return
@@ -1670,7 +1671,7 @@ receive_incremental_selection (display, window, property, target_type,
            XSelectInput (display, window, STANDARD_EVENT_SET);
          /* Use xfree, not XFree, because x_get_window_property
             calls xmalloc itself.  */
-         if (tmp_data) xfree (tmp_data);
+         xfree (tmp_data);
          break;
        }
 
@@ -2368,7 +2369,7 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,
 {
   Window window;
   Atom buffer_atom;
-  unsigned char *data;
+  unsigned char *data = NULL;
   int bytes;
   Atom type;
   int format;
@@ -2391,8 +2392,13 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,
 
   x_get_window_property (display, window, buffer_atom, &data, &bytes,
                         &type, &format, &size, 0);
+
   if (!data || !format)
-    return Qnil;
+    {
+      if (data)
+       xfree (data);
+      return Qnil;
+    }
 
   if (format != 8 || type != XA_STRING)
     signal_error ("Cut buffer doesn't contain 8-bit data",
@@ -2474,8 +2480,8 @@ DEFUN ("x-store-cut-buffer-internal", Fx_store_cut_buffer_internal,
 
 DEFUN ("x-rotate-cut-buffers-internal", Fx_rotate_cut_buffers_internal,
        Sx_rotate_cut_buffers_internal, 1, 1, 0,
-       doc: /* Rotate the values of the cut buffers by the given number of step.
-Positive means shift the values forward, negative means backward.  */)
+       doc: /* Rotate the values of the cut buffers by N steps.
+Positive means shift the values forward, negative means backward.  */)
      (n)
      Lisp_Object n;
 {
@@ -2823,7 +2829,7 @@ If DEST is a cons, it is converted to a 32 bit number
 with the high 16 bits from the car and the lower 16 bit from the cdr.  That
 number is then used as a window id.
 If DEST is a frame the event is sent to the outer window of that frame.
-Nil means the currently selected frame.
+A value of nil means the currently selected frame.
 If DEST is the string "PointerWindow" the event is sent to the window that
 contains the pointer.  If DEST is the string "InputFocus" the event is
 sent to the window that has the input focus.