Bug Summary

File:Frameworks/FriBidi Framework/fribidi-0.10.7/fribidi_char_sets_cap_rtl.c
Location:line 116, column 12
Description:dead store

Annotated Source Code

1/* FriBidi - Library of BiDi algorithm
2 * Copyright (C) 1999,2000 Dov Grobgeld, and
3 * Copyright (C) 2001,2002 Behdad Esfahbod.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library, in a file named COPYING; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA
19 *
20 * For licensing issues, contact <dov@imagic.weizmann.ac.il> and
21 * <fwpg@sharif.edu>.
22 */
23
24#include "fribidi_config.h"
25#ifndef FRIBIDI_NO_CHARSETS
26
27#include <stdlib.h>
28#include <string.h>
29#include <stdio.h>
30#include "fribidi.h"
31
32#define WS FRIBIDI_PROP_TYPE_WS
33#define BS FRIBIDI_PROP_TYPE_BS
34#define EO FRIBIDI_PROP_TYPE_EO
35#define CTL FRIBIDI_PROP_TYPE_CTL
36#define LRE FRIBIDI_PROP_TYPE_LRE
37#define RLE FRIBIDI_PROP_TYPE_RLE
38#define ES FRIBIDI_PROP_TYPE_ES
39#define LRO FRIBIDI_PROP_TYPE_LRO
40#define RLO FRIBIDI_PROP_TYPE_RLO
41#define AL FRIBIDI_PROP_TYPE_AL
42#define SS FRIBIDI_PROP_TYPE_SS
43#define ET FRIBIDI_PROP_TYPE_ET
44#define NSM FRIBIDI_PROP_TYPE_NSM
45#define LTR FRIBIDI_PROP_TYPE_LTR
46#define ON FRIBIDI_PROP_TYPE_ON
47#define AN FRIBIDI_PROP_TYPE_AN
48#define BN FRIBIDI_PROP_TYPE_BN
49#define RTL FRIBIDI_PROP_TYPE_RTL
50#define CS FRIBIDI_PROP_TYPE_CS
51#define PDF FRIBIDI_PROP_TYPE_PDF
52#define EN FRIBIDI_PROP_TYPE_EN
53
54static FriBidiPropCharType CapRTLCharTypes[] = {
55/* *INDENT-OFF* */
56 ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, LTRFRIBIDI_PROP_TYPE_LTR,RTLFRIBIDI_PROP_TYPE_RTL,ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, BSFRIBIDI_PROP_TYPE_BS, RLOFRIBIDI_PROP_TYPE_RLO,RLEFRIBIDI_PROP_TYPE_RLE, /* 00-0f */
57 LROFRIBIDI_PROP_TYPE_LRO,LREFRIBIDI_PROP_TYPE_LRE,PDFFRIBIDI_PROP_TYPE_PDF,WSFRIBIDI_PROP_TYPE_WS, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, /* 10-1f */
58 WSFRIBIDI_PROP_TYPE_WS, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ONFRIBIDI_PROP_TYPE_ON, ETFRIBIDI_PROP_TYPE_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RIBIDI_PROP_TYPE_ON, SSFRIBIDI_PROP_TYPE_SS, ONFRIBIDI_PROP_TYPE_ON, WSFRIBIDI_PROP_TYPE_WS, ONFRIBIDI_PROP_TYPE_ON, /* 70-7f */
64/* *INDENT-ON* */
65};
66
67#undef WS
68#undef BS
69#undef EO
70#undef CTL
71#undef LRE
72#undef RLE
73#undef ES
74#undef LRO
75#undef RLO
76#undef AL
77#undef SS
78#undef ET
79#undef NSM
80#undef LTR
81#undef ON
82#undef AN
83#undef BN
84#undef RTL
85#undef CS
86#undef PDF
87#undef EN
88
89#define CAPRTL_CHARS (sizeof CapRTLCharTypes / sizeof CapRTLCharTypes[0])
90
91static FriBidiChar *caprtl_to_unicode = NULL( ( void * ) 0 );
92
93char
94fribidi_unicode_to_cap_rtl_c (FriBidiChar uch)
95{
96 int i;
97 for (i = 0; i < CAPRTL_CHARS( sizeof CapRTLCharTypes / sizeof CapRTLCharTypes [ 0 ] ); i++)
98 if (uch == caprtl_to_unicode[i])
99 return (char) i;
100 return '?';
101}
102
103int
104fribidi_cap_rtl_to_unicode (char *s, int len, FriBidiChar *us)
105{
106 int i, j;
107
108 j = 0;
109 for (i = 0; i < len; i++)
110 {
111 char ch;
112
113 ch = s[i];
114 if (ch == '_')
115 {
Although the value stored to 'ch' is used in the enclosing expression, the value is never actually read from 'ch'
116 switch (ch = s[++i])
117 {
118 case '>':
119 us[j++] = UNI_LRM0x200E;
120 break;
121 case '<':
122 us[j++] = UNI_RLM0x200F;
123 break;
124 case 'l':
125 us[j++] = UNI_LRE0x202A;
126 break;
127 case 'r':
128 us[j++] = UNI_RLE0x202B;
129 break;
130 case 'o':
131 us[j++] = UNI_PDF0x202C;
132 break;
133 case 'L':
134 us[j++] = UNI_LRO0x202D;
135 break;
136 case 'R':
137 us[j++] = UNI_RLO0x202E;
138 break;
139 case '_':
140 us[j++] = '_';
141 break;
142 default:
143 us[j++] = '_';
144 i--;
145 break;
146 }
147 }
148 else
149 us[j++] = caprtl_to_unicode[(int) s[i]];
150 }
151
152 return j;
153}
154
155int
156fribidi_unicode_to_cap_rtl (FriBidiChar *us, int length, char *s)
157{
158 int i, j;
159
160 j = 0;
161 for (i = 0; i < length; i++)
162 {
163 FriBidiChar ch = us[i];
164 if (!FRIBIDI_IS_EXPLICIT( ( fribidi_get_type ( ch ) ) & 0x00001000L ) (fribidi_get_type (ch)) && ch != '_'
165 && ch != UNI_LRM0x200E && ch != UNI_RLM0x200F)
166 s[j++] = fribidi_unicode_to_cap_rtl_c (ch);
167 else
168 {
169 s[j++] = '_';
170 switch (ch)
171 {
172 case UNI_LRM0x200E:
173 s[j++] = '>';
174 break;
175 case UNI_RLM0x200F:
176 s[j++] = '<';
177 break;
178 case UNI_LRE0x202A:
179 s[j++] = 'l';
180 break;
181 case UNI_RLE0x202B:
182 s[j++] = 'r';
183 break;
184 case UNI_PDF0x202C:
185 s[j++] = 'o';
186 break;
187 case UNI_LRO0x202D:
188 s[j++] = 'L';
189 break;
190 case UNI_RLO0x202E:
191 s[j++] = 'R';
192 break;
193 case '_':
194 s[j++] = '_';
195 break;
196 default:
197 j--;
198 if (ch < 256)
199 s[j++] = fribidi_unicode_to_cap_rtl_c (ch);
200 else
201 s[j++] = '?';
202 break;
203 }
204 }
205 }
206 s[j] = 0;
207
208 return j;
209}
210
211char *
212fribidi_char_set_desc_cap_rtl (void)
213{
214 static char *s = 0;
215 int l, i, j;
216
217 if (s)
218 return s;
219
220 l = 4000;
221 s = (char *) malloc (l);
222 i = 0;
223 i += snprintf (s + i, l - i,
224 "CapRTL is a character set for testing with the reference\n"
225 "implementation, with explicit marks escape strings, and\n"
226 "the property that contains all unicode character types in\n"
227 "ASCII range 1-127.\n"
228 "\n"
229 "Warning: CapRTL character types are subject to change.\n"
230 "\n" "CapRTL's character types:\n");
231 for (j = 0; j < CAPRTL_CHARS( sizeof CapRTLCharTypes / sizeof CapRTLCharTypes [ 0 ] ); j++)
232 {
233 if (j % 4 == 0)
234 s[i++] = '\n';
235 i += snprintf (s + i, l - i, " * 0x%02x %c%c %-3s ", j,
236 j < 0x20 ? '^' : ' ',
237 j < 0x20 ? j + '@' : j < 0x7f ? j : ' ',
238 fribidi_type_name (fribidi_prop_to_type
239 [(unsigned char)
240 CapRTLCharTypes[j]]));
241 }
242 i += snprintf (s + i, l - i,
243 "\n\n"
244 "Escape sequences:\n"
245 " Character `_' is used to escape explicit marks. The list is:\n"
246 " * _> LRM\n"
247 " * _< RLM\n"
248 " * _l LRE\n"
249 " * _r RLE\n"
250 " * _L LRO\n"
251 " * _R RLO\n" " * _o PDF\n" " * __ `_' itself\n"
252 "\n");
253 return s;
254}
255
256fribidi_boolean
257fribidi_char_set_enter_cap_rtl (void)
258{
259 if (!caprtl_to_unicode)
260 {
261 int request[FRIBIDI_TYPES_COUNT + 1];
262 int i, count;
263
264 caprtl_to_unicode =
265 (FriBidiChar *) malloc (CAPRTL_CHARS( sizeof CapRTLCharTypes / sizeof CapRTLCharTypes [ 0 ] ) * sizeof caprtl_to_unicode[0]);
266 for (i = 0; i < FRIBIDI_TYPES_COUNT; i++)
267 request[i] = 0;
268 for (i = 0; i < CAPRTL_CHARS( sizeof CapRTLCharTypes / sizeof CapRTLCharTypes [ 0 ] ); i++)
269 if (fribidi_get_mirror_char (i, NULL( ( void * ) 0 )))
270 caprtl_to_unicode[i] = i;
271 for (count = 0, i = 0; i < CAPRTL_CHARS( sizeof CapRTLCharTypes / sizeof CapRTLCharTypes [ 0 ] ); i++)
272 if (caprtl_to_unicode[i] == 0)
273 {
274 request[(unsigned char) CapRTLCharTypes[i]]++;
275 count++;
276 }
277 for (i = 1; i < 0x10000 && count; i++) /* Assign BMP chars to CapRTL entries */
278 if (!fribidi_get_mirror_char (i, NULL( ( void * ) 0 )))
279 {
280 int j, k;
281 for (j = 0; j < FRIBIDI_TYPES_COUNT; j++)
282 if (fribidi_prop_to_type[j] == fribidi_get_type (i))
283 break;
284 if (!request[j]) /* Do not need this type */
285 continue;
286 for (k = 0; k < CAPRTL_CHARS( sizeof CapRTLCharTypes / sizeof CapRTLCharTypes [ 0 ] ); k++)
287 if (!caprtl_to_unicode[k] && j == CapRTLCharTypes[k])
288 break;
289 if (k < CAPRTL_CHARS( sizeof CapRTLCharTypes / sizeof CapRTLCharTypes [ 0 ] ))
290 {
291 request[j]--;
292 count--;
293 caprtl_to_unicode[k] = i;
294 }
295 }
296 }
297
298 return FRIBIDI_TRUE1;
299}
300
301fribidi_boolean
302fribidi_char_set_leave_cap_rtl (void)
303{
304 return FRIBIDI_TRUE1;
305}
306
307#endif