summaryrefslogtreecommitdiffstats
path: root/source/l/gtk+/gtk+-1.2.10-ctext.patch
blob: 28fca0cdf10762817238cd4f54c7ae049e7c16b8 (about) (plain) (blame)
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
--- gtk+-1.2.10/gdk/gdkselection.c.ctext	Thu Jul  5 12:41:42 2001
+++ gtk+-1.2.10/gdk/gdkselection.c	Thu Jul  5 12:45:25 2001
@@ -191,73 +191,6 @@
   gdk_send_xevent (requestor, False, NoEventMask, (XEvent*) &xevent);
 }
 
-
-/* The output of XmbTextPropertyToTextList may include stuff not valid
- * for COMPOUND_TEXT. This routine tries to correct this by:
- *
- * a) Canonicalizing CR LF and CR to LF
- * b) Stripping out all other non-allowed control characters
- *
- * See the COMPOUND_TEXT spec distributed with X for explanations
- * what is allowed.
- */
-static gchar *
-sanitize_ctext (const char *str,
-		gint       *length)
-{
-  gchar *result = g_malloc (*length + 1);
-  gint out_length = 0;
-  gint i;
-  const guchar *ustr = (const guchar *)str;
-
-  for (i=0; i < *length; i++)
-    {
-      guchar c = ustr[i];
-      
-      if (c == '\r')
-	{
-	  result[out_length++] = '\n';
-	  if (i + 1 < *length && ustr[i + 1] == '\n')
-	    i++;
-	}
-      else if (c == 27 /* ESC */)
-	{
-	  /* Check for "extended segments, which can contain arbitrary
-	   * octets. See CTEXT spec, section 6.
-	   */
-
-	  if (i + 5 < *length &&
-	      ustr[i + 1] == '%' &&
-	      ustr[i + 2] == '/' &&
-	      (ustr[i + 3] >= 48 && ustr[i + 3] <= 52) &&
-	      ustr[i + 4] >= 128 &&
-	      ustr[i + 5] >= 128)
-	    {
-	      int extra_len = 6 + (ustr[i + 4] - 128) * 128 + ustr[i + 5] - 128;
-	      extra_len = MAX (extra_len, *length - i);
-
-	      memcpy (result + out_length, ustr + i, extra_len);
-	      out_length += extra_len;
-	      i += extra_len - 1;
-	    }
-	  else
-	    result[out_length++] = c;	    
-	}
-      else if (c == '\n' || c == '\t' || c == 27 /* ESC */ ||
-	       (c >= 32 && c <= 127) ||	/* GL */
-	       c == 155 /* CONTROL SEQUENCE INTRODUCER */ ||	
-	       (c >= 160 && c <= 255)) /* GR */
-	{
-	  result[out_length++] = c;
-	}
-    }
-
-  result[out_length] = '\0';
-  *length = out_length;
-  
-  return result;
-}
-
 gint
 gdk_text_property_to_text_list (GdkAtom encoding, gint format, 
 				guchar *text, gint length,
@@ -266,32 +199,16 @@
   XTextProperty property;
   gint count = 0;
   gint res;
-  gchar *sanitized_text = NULL;
 
   if (!list) 
     return 0;
 
   property.encoding = encoding;
   property.format = format;
-
-  if (encoding == gdk_atom_intern ("COMPOUND_TEXT", FALSE) && format == 8)
-    {
-      gint sanitized_text_length = length;
-      
-      property.value = sanitized_text = sanitize_ctext (text, &sanitized_text_length);
-      property.nitems = sanitized_text_length;
-    }
-  else
-    {
-      property.value = text;
-      property.nitems = length;
-    }
-  
+  property.value = text;
+  property.nitems = length;
   res = XmbTextPropertyToTextList (GDK_DISPLAY(), &property, list, &count);
 
-  if (sanitized_text)
-    g_free (sanitized_text);
-
   if (res == XNoMemory || res == XLocaleNotSupported || 
       res == XConverterNotFound)
     return 0;
@@ -314,8 +231,6 @@
 {
   gint res;
   XTextProperty property;
-  gint sanitized_text_length;
-  gchar *sanitized_text;
 
   res = XmbTextListToTextProperty (GDK_DISPLAY(), 
 				   (char **)&str, 1, XCompoundTextStyle,
@@ -334,17 +249,10 @@
     *encoding = property.encoding;
   if (format)
     *format = property.format;
-
-  sanitized_text_length = property.nitems;
-  sanitized_text = sanitize_ctext (property.value, &sanitized_text_length);
-
   if (ctext)
-    *ctext = sanitized_text;
-  else
-    g_free (sanitized_text);
-  
+    *ctext = g_strdup (property.value);
   if (length)
-    *length = sanitized_text_length;
+    *length = property.nitems;
 
   if (property.value)
     XFree (property.value);