aboutsummaryrefslogtreecommitdiffstats
path: root/testing/motif/17-switch-to-system-iswspace.patch
blob: a77b8793a8eaa5f47a26c2214e313b40e6b22c6e (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
Description: Switch to system iswspace() function
 This patch replaces calls to _XmDataFieldIsWSpace() in lib/Xm/DataF.c
 and _XmTextFieldIsWSpace() in lib/Xm/TextF.c with calls to the system
 iswspace() function.
 .
 It fixes an array bounds error in lib/Xm/DataF.c where 
 _XmDataFieldIsWSpace() is called with num_entries = 3.
Author: Graham Inggs <graham@nerve.org.za>
Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1629
Last-Update: 2013-11-18
--- a/lib/Xm/DataF.c
+++ b/lib/Xm/DataF.c
@@ -208,7 +208,6 @@
 static Boolean df_VerifyLeave() ;
 static Boolean _XmDataFieldIsWordBoundary() ;
 static int _XmGetImage(Screen *, char *, XImage **);
-static Boolean _XmDataFieldIsWSpace() ;
 static void df_FindWord() ;
 static void df_FindPrevWord() ;
 static void df_FindNextWord() ;
@@ -549,10 +548,6 @@
                         XmDataFieldWidget tf,
                         XmTextPosition pos1,
                         XmTextPosition pos2) ;
-static Boolean _XmDataFieldIsWSpace( 
-                        wchar_t wide_char,
-                        wchar_t *white_space,
-                        int num_entries) ;
 static void df_FindWord( 
                         XmDataFieldWidget tf,
                         XmTextPosition begin,
@@ -4549,40 +4544,6 @@
    return False;
 }
 
-/* This routine accepts an array of wchar_t's containing wchar encodings
- * of whitespace characters (and the number of array elements), comparing
- * the wide character passed to each element of the array.  If a match
- * is found, we got a white space.  This routine exists only because
- * iswspace(3c) is not yet standard.  If a system has isw* available,
- * calls to this routine should be changed to iswspace(3c) (and callers
- * should delete initialization of the array), and this routine should
- * be deleted.  Its a stop gap measure to avoid allocating an instance
- * variable for the white_space array and/or declaring a widget wide
- * global for the data and using a macro.  Its ugly, but it works and 
- * in the long run will be replaced by standard functionality. */
-
-/* ARGSUSED */
-static Boolean
-#ifdef _NO_PROTO
-_XmDataFieldIsWSpace( wide_char, white_space, num_entries )
-	wchar_t wide_char ;
-	wchar_t * white_space ;
-	int num_entries ;
-#else
-_XmDataFieldIsWSpace(
-	wchar_t wide_char,
-	wchar_t * white_space ,
-	int num_entries )
-#endif /* _NO_PROTO */
-{
-   int i;
-
-   for (i=num_entries; i > 0; i--){
-      if (wide_char == white_space[i]) return True;
-   }
-   return False;
-}
-
 static void 
 #ifdef _NO_PROTO
 df_FindWord( tf, begin, left, right )
@@ -4599,7 +4560,6 @@
 #endif /* _NO_PROTO */
 {
     XmTextPosition start, end;
-    wchar_t white_space[3];
 
     if (XmTextF_max_char_size(tf) == 1) {
        for (start = begin; start > 0; start--) {
@@ -4617,11 +4577,8 @@
        }
        *right = end - 1;
     } else { /* check for iswspace and iswordboundary in each direction */
-       (void)mbtowc(&white_space[0], " ", 1);
-       (void)mbtowc(&white_space[1], "\n", 1);
-       (void)mbtowc(&white_space[2], "\t", 1);
        for (start = begin; start > 0; start --) {
-          if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[start-1],white_space, 3)
+          if (iswspace(XmTextF_wc_value(tf)[start-1])
 	      || _XmDataFieldIsWordBoundary(tf, (XmTextPosition) start - 1, 
 					    start)) {
 		 break;
@@ -4630,7 +4587,7 @@
        *left = start;
 
        for (end = begin; end <= XmTextF_string_length(tf); end++) {
-	   if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[end], white_space, 3)){
+	   if (iswspace(XmTextF_wc_value(tf)[end])){
 	      end++;
 	      break;
 	   } else if (end < XmTextF_string_length(tf)) {
@@ -4659,14 +4616,6 @@
 {
 
     XmTextPosition start = XmTextF_cursor_position(tf);
-    wchar_t white_space[3];
-
-    if (XmTextF_max_char_size(tf) != 1) {
-       (void)mbtowc(&white_space[0], " ", 1);
-       (void)mbtowc(&white_space[1], "\n", 1);
-       (void)mbtowc(&white_space[2], "\t", 1);
-    }
-
 
     if (XmTextF_max_char_size(tf) == 1) {
        if ((start > 0) && 
@@ -4680,11 +4629,9 @@
        }
        df_FindWord(tf, start, left, right);
     } else { 
-       if ((start > 0) && (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[start - 1],
-						white_space, 3))) {
+       if ((start > 0) && (iswspace(XmTextF_wc_value(tf)[start - 1]))) {
           for (; start > 0; start--) {
-	     if (!_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[start -1], 
-				       white_space, 3)){
+	     if (!iswspace(XmTextF_wc_value(tf)[start -1])){
 		start--;
 		break;
              }
@@ -4713,14 +4660,6 @@
 {
 
     XmTextPosition end = XmTextF_cursor_position(tf);
-    wchar_t white_space[3];
-
-    if (XmTextF_max_char_size(tf) != 1) {
-       (void)mbtowc(&white_space[0], " ", 1);
-       (void)mbtowc(&white_space[1], "\n", 1);
-       (void)mbtowc(&white_space[2], "\t", 1);
-    }
-
 
     if(XmTextF_max_char_size(tf) == 1) {
        if (isspace((int)(unsigned char)XmTextF_value(tf)[end])) {
@@ -4742,9 +4681,9 @@
        if (*right < XmTextF_string_length(tf))
           *right = *right - 1;
    } else {
-      if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[end], white_space, 3)) {
+      if (iswspace(XmTextF_wc_value(tf)[end])) {
 	 for ( ; end < XmTextF_string_length(tf); end ++) {
-	   if (!_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[end], white_space, 3)) {
+	   if (!iswspace(XmTextF_wc_value(tf)[end])) {
 	       break;
            }
          }
@@ -4758,10 +4697,9 @@
        * If word boundary caused by whitespace, set right to the last 
        * whitespace following the end of the current word.
        */
-      if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[(int)*right], white_space, 3))      {
+      if (iswspace(XmTextF_wc_value(tf)[(int)*right]))      {
          while (*right < XmTextF_string_length(tf) &&
-               _XmDataFieldIsWSpace(XmTextF_wc_value(tf)[(int)*right], 
-				    white_space, 3)) {
+               iswspace(XmTextF_wc_value(tf)[(int)*right])) {
             *right = *right + 1;
 	 }
 	 if (*right < XmTextF_string_length(tf))
@@ -5872,13 +5810,6 @@
 {
     XmDataFieldWidget tf = (XmDataFieldWidget) w;
     XmTextPosition cursorPos, position, dummy;
-    wchar_t white_space[3];
-
-    if (XmTextF_max_char_size(tf) != 1) {
-       (void)mbtowc(&white_space[0], " ", 1);
-       (void)mbtowc(&white_space[1], "\n", 1);
-       (void)mbtowc(&white_space[2], "\t", 1);
-    }
 
     cursorPos = XmTextF_cursor_position(tf);
 
@@ -5896,16 +5827,13 @@
              }
           }
        } else {
-	  if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[cursorPos],
-				   white_space, 3))
+	  if (iswspace(XmTextF_wc_value(tf)[cursorPos]))
 	     df_FindWord(tf, cursorPos, &dummy, &position);
 	  else
 	     df_FindNextWord(tf, &dummy, &position);
-          if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[position],
-				   white_space, 3)){
+          if (iswspace(XmTextF_wc_value(tf)[position])){
 	     for (; position < XmTextF_string_length(tf); position++) {
-		if (!_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[position], 
-					  white_space, 3))
+		if (!iswspace(XmTextF_wc_value(tf)[position]))
 		   break;
 	     }
 	  }
--- a/lib/Xm/TextF.c
+++ b/lib/Xm/TextF.c
@@ -360,10 +360,6 @@
 					  XmTextPosition pos1,
 					  XmTextPosition pos2);
 
-static Boolean _XmTextFieldIsWSpace(wchar_t wide_char,
-				    wchar_t *white_space,
-				    int num_entries);
-
 static void FindWord(XmTextFieldWidget tf,
 		     XmTextPosition begin,
 		     XmTextPosition *left,
@@ -3514,32 +3510,6 @@
   return False;
 }
 
-/* This routine accepts an array of wchar_t's containing wchar encodings
- * of whitespace characters (and the number of array elements), comparing
- * the wide character passed to each element of the array.  If a match
- * is found, we got a white space.  This routine exists only because
- * iswspace(3c) is not yet standard.  If a system has isw* available,
- * calls to this routine should be changed to iswspace(3c) (and callers
- * should delete initialization of the array), and this routine should
- * be deleted.  Its a stop gap measure to avoid allocating an instance
- * variable for the white_space array and/or declaring a widget wide
- * global for the data and using a macro.  Its ugly, but it works and 
- * in the long run will be replaced by standard functionality. */
-
-/* ARGSUSED */
-static Boolean
-_XmTextFieldIsWSpace(wchar_t wide_char,
-		     wchar_t * white_space ,
-		     int num_entries)
-{
-  int i;
-  
-  for (i=0; i < num_entries; i++) {
-    if (wide_char == white_space[i]) return True;
-  }
-  return False;
-}
-
 static void 
 FindWord(XmTextFieldWidget tf,
 	 XmTextPosition begin,
@@ -3547,7 +3517,6 @@
 	 XmTextPosition *right)
 {
   XmTextPosition start, end;
-  wchar_t white_space[3];
   
   if (tf->text.max_char_size == 1) {
     for (start = begin; start > 0; start--) {
@@ -3565,11 +3534,8 @@
     }
     *right = end - 1;
   } else { /* check for iswspace and iswordboundary in each direction */
-    (void)mbtowc(&white_space[0], " ", 1);
-    (void)mbtowc(&white_space[1], "\n", 1);
-    (void)mbtowc(&white_space[2], "\t", 1);
     for (start = begin; start > 0; start --) {
-      if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[start-1],white_space, 3)
+      if (iswspace(TextF_WcValue(tf)[start-1])
 	  || _XmTextFieldIsWordBoundary(tf, (XmTextPosition) start - 1, 
 					start)) {
 	break;
@@ -3578,7 +3544,7 @@
     *left = start;
     
     for (end = begin; end <= tf->text.string_length; end++) {
-      if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[end], white_space, 3)) {
+      if (iswspace(TextF_WcValue(tf)[end])) {
 	end++;
 	break;
       } else if (end < tf->text.string_length) {
@@ -3599,14 +3565,6 @@
 {
   
   XmTextPosition start = TextF_CursorPosition(tf);
-  wchar_t white_space[3];
-  
-  if (tf->text.max_char_size != 1) {
-    (void)mbtowc(&white_space[0], " ", 1);
-    (void)mbtowc(&white_space[1], "\n", 1);
-    (void)mbtowc(&white_space[2], "\t", 1);
-  }
-  
   
   if (tf->text.max_char_size == 1) {
     if ((start > 0) && 
@@ -3620,11 +3578,9 @@
     }
     FindWord(tf, start, left, right);
   } else { 
-    if ((start > 0) && (_XmTextFieldIsWSpace(TextF_WcValue(tf)[start - 1],
-					     white_space, 3))) {
+    if ((start > 0) && (iswspace(TextF_WcValue(tf)[start - 1]))) {
       for (; start > 0; start--) {
-	if (!_XmTextFieldIsWSpace(TextF_WcValue(tf)[start -1], 
-				  white_space, 3)) {
+	if (!iswspace(TextF_WcValue(tf)[start -1])) {
 	  start--;
 	  break;
 	}
@@ -3645,14 +3601,6 @@
 {
   
   XmTextPosition end = TextF_CursorPosition(tf);
-  wchar_t white_space[3];
-  
-  if (tf->text.max_char_size != 1) {
-    (void)mbtowc(&white_space[0], " ", 1);
-    (void)mbtowc(&white_space[1], "\n", 1);
-    (void)mbtowc(&white_space[2], "\t", 1);
-  }
-  
   
   if(tf->text.max_char_size == 1) {
     if (isspace((unsigned char)TextF_Value(tf)[end])) {
@@ -3674,9 +3622,9 @@
     if (*right < tf->text.string_length)
       *right = *right - 1;
   } else {
-    if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[end], white_space, 3)) {
+    if (iswspace(TextF_WcValue(tf)[end])) {
       for (; end < tf->text.string_length; end ++) {
-	if (!_XmTextFieldIsWSpace(TextF_WcValue(tf)[end], white_space, 3)) {
+	if (!iswspace(TextF_WcValue(tf)[end])) {
 	  break;
 	}
       }
@@ -3690,10 +3638,9 @@
      * If word boundary caused by whitespace, set right to the last 
      * whitespace following the end of the current word.
      */
-    if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[(int)*right], white_space, 3)) {
+    if (iswspace(TextF_WcValue(tf)[(int)*right])) {
       while (*right < tf->text.string_length &&
-	     _XmTextFieldIsWSpace(TextF_WcValue(tf)[(int)*right], 
-				  white_space, 3)) {
+	     iswspace(TextF_WcValue(tf)[(int)*right])) {
 	*right = *right + 1;
       }
       if (*right < tf->text.string_length)
@@ -4546,13 +4493,6 @@
 {
   XmTextFieldWidget tf = (XmTextFieldWidget) w;
   XmTextPosition cursorPos, position, dummy;
-  wchar_t white_space[3];
-  
-  if (tf->text.max_char_size != 1) {
-    (void)mbtowc(&white_space[0], " ", 1);
-    (void)mbtowc(&white_space[1], "\n", 1);
-    (void)mbtowc(&white_space[2], "\t", 1);
-  }
   
   cursorPos = TextF_CursorPosition(tf);
   
@@ -4570,16 +4510,13 @@
 	}
       }
     } else {
-      if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[cursorPos],
-			       white_space, 3))
+      if (iswspace(TextF_WcValue(tf)[cursorPos]))
 	FindWord(tf, cursorPos, &dummy, &position);
       else
 	FindNextWord(tf, &dummy, &position);
-      if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[position],
-			       white_space, 3)) {
+      if (iswspace(TextF_WcValue(tf)[position])) {
 	for (; position < tf->text.string_length; position++) {
-	  if (!_XmTextFieldIsWSpace(TextF_WcValue(tf)[position], 
-				    white_space, 3))
+	  if (!iswspace(TextF_WcValue(tf)[position]))
 	    break;
 	}
       }