initscripts-shr: remove devtmpfs initscript for palmpre machine
[openembedded.git] / recipes / scim / files / 52_scim-1.4.7-imdkit-read-property-properly.dpatch
blob13540a34c5f5af6f82b040665ddc2533e4cb8dc0
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 52_scim-1.4.7-imdkit-read-property-properly.dpatch by Ikuya Awashiro <ikuya@fruitsbasket.info>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Correctly read XIM_FORWARD_EVENT, triggered when rapidly typing keys
6 ## DP: https://bugzilla.redhat.com/show_bug.cgi?id=466657
8 @DPATCH@
9 diff -urNad scim-1.4.9~/modules/FrontEnd/IMdkit/Xi18n.h scim-1.4.9/modules/FrontEnd/IMdkit/Xi18n.h
10 --- scim-1.4.9~/modules/FrontEnd/IMdkit/Xi18n.h 2008-11-02 06:42:13.000000000 +0000
11 +++ scim-1.4.9/modules/FrontEnd/IMdkit/Xi18n.h 2009-07-20 11:48:01.000000000 +0000
12 @@ -149,6 +149,8 @@
14 int sync;
15 XIMPending *pending;
16 + /* property offset to read next data */
17 + long property_offset;
18 void *trans_rec; /* contains transport specific data */
19 struct _Xi18nClient *next;
20 } Xi18nClient;
21 diff -urNad scim-1.4.9~/modules/FrontEnd/IMdkit/i18nUtil.c scim-1.4.9/modules/FrontEnd/IMdkit/i18nUtil.c
22 --- scim-1.4.9~/modules/FrontEnd/IMdkit/i18nUtil.c 2008-11-02 06:42:13.000000000 +0000
23 +++ scim-1.4.9/modules/FrontEnd/IMdkit/i18nUtil.c 2009-07-20 11:48:01.000000000 +0000
24 @@ -70,6 +70,7 @@
25 client->sync = False;
26 client->byte_order = '?'; /* initial value */
27 memset (&client->pending, 0, sizeof (XIMPending *));
28 + client->property_offset = 0;
29 client->next = i18n_core->address.clients;
30 i18n_core->address.clients = client;
32 diff -urNad scim-1.4.9~/modules/FrontEnd/IMdkit/i18nX.c scim-1.4.9/modules/FrontEnd/IMdkit/i18nX.c
33 --- scim-1.4.9~/modules/FrontEnd/IMdkit/i18nX.c 2008-11-02 06:42:12.000000000 +0000
34 +++ scim-1.4.9/modules/FrontEnd/IMdkit/i18nX.c 2009-07-20 11:48:01.000000000 +0000
35 @@ -29,6 +29,7 @@
37 ******************************************************************/
39 +#include <limits.h>
40 #include <X11/Xlib.h>
41 #include <X11/Xatom.h>
42 #include "FrameMgr.h"
43 @@ -128,6 +129,7 @@
44 else if (ev->format == 32) {
45 /* ClientMessage and WindowProperty */
46 unsigned long length = (unsigned long) ev->data.l[0];
47 + unsigned long get_length;
48 Atom atom = (Atom) ev->data.l[1];
49 int return_code;
50 Atom actual_type_ret;
51 @@ -136,11 +138,20 @@
52 unsigned char *prop;
53 unsigned long nitems;
55 + /* Round up length to next 4 byte value. */
56 + get_length = length + 3;
57 + if (get_length > LONG_MAX)
58 + get_length = LONG_MAX;
59 + get_length /= 4;
60 + if (get_length == 0) {
61 + fprintf(stderr, "%s: invalid length 0\n", __FUNCTION__);
62 + return NULL;
63 + }
64 return_code = XGetWindowProperty (i18n_core->address.dpy,
65 x_client->accept_win,
66 atom,
67 - 0L,
68 - length,
69 + client->property_offset / 4,
70 + get_length,
71 True,
72 AnyPropertyType,
73 &actual_type_ret,
74 @@ -151,15 +162,27 @@
75 if (return_code != Success || actual_format_ret == 0 || nitems == 0) {
76 if (return_code == Success)
77 XFree (prop);
78 + client->property_offset = 0;
79 return (unsigned char *) NULL;
81 - if (length != nitems)
82 - length = nitems;
83 - if (actual_format_ret == 16)
84 - length *= 2;
85 - else if (actual_format_ret == 32)
86 - length *= 4;
88 + /* Update the offset to read next time as needed */
89 + if (bytes_after_ret > 0)
90 + client->property_offset += length;
91 + else
92 + client->property_offset = 0;
93 + switch (actual_format_ret) {
94 + case 8:
95 + case 16:
96 + case 32:
97 + length = nitems * actual_format_ret / 8;
98 + break;
99 + default:
100 + fprintf(stderr, "%s: unknown property return format: %d\n",
101 + __FUNCTION__, actual_format_ret);
102 + XFree(prop);
103 + client->property_offset = 0;
104 + return NULL;
106 /* if hit, it might be an error */
107 if ((p = (unsigned char *) malloc (length)) == NULL)
108 return (unsigned char *) NULL;