| File: | src/xlibi18n/lcGeneric.c |
| Location: | line 67, column 17 |
| Description: | Result of 'calloc' is converted to a pointer of type 'struct XLCdCoreRec', which is incompatible with sizeof operand type 'XLCdGenericRec' |
| 1 | /* |
| 2 | * Copyright 1992, 1993 by TOSHIBA Corp. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and distribute this software and its |
| 5 | * documentation for any purpose and without fee is hereby granted, provided |
| 6 | * that the above copyright notice appear in all copies and that both that |
| 7 | * copyright notice and this permission notice appear in supporting |
| 8 | * documentation, and that the name of TOSHIBA not be used in advertising |
| 9 | * or publicity pertaining to distribution of the software without specific, |
| 10 | * written prior permission. TOSHIBA make no representations about the |
| 11 | * suitability of this software for any purpose. It is provided "as is" |
| 12 | * without express or implied warranty. |
| 13 | * |
| 14 | * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING |
| 15 | * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL |
| 16 | * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR |
| 17 | * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
| 18 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
| 19 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 20 | * SOFTWARE. |
| 21 | * |
| 22 | * Author: Katsuhisa Yano TOSHIBA Corp. |
| 23 | * mopi@osa.ilab.toshiba.co.jp |
| 24 | */ |
| 25 | /* |
| 26 | * (c) Copyright 1995 FUJITSU LIMITED |
| 27 | * This is source code modified by FUJITSU LIMITED under the Joint |
| 28 | * Development Agreement for the CDE/Motif PST. |
| 29 | */ |
| 30 | |
| 31 | #ifdef HAVE_CONFIG_H1 |
| 32 | #include <config.h> |
| 33 | #endif |
| 34 | #include <stdio.h> |
| 35 | #include "Xlibint.h" |
| 36 | #include "XlcGeneric.h" |
| 37 | |
| 38 | static XLCd create (const char *name, XLCdMethods methods); |
| 39 | static Boolint initialize (XLCd lcd); |
| 40 | static void destroy (XLCd lcd); |
| 41 | |
| 42 | static XLCdPublicMethodsRec genericMethods = { |
| 43 | { NULL((void*)0) }, /* use default methods */ |
| 44 | { |
| 45 | NULL((void*)0), |
| 46 | create, |
| 47 | initialize, |
| 48 | destroy, |
| 49 | NULL((void*)0) |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | XLCdMethods _XlcGenericMethods = (XLCdMethods) &genericMethods; |
| 54 | |
| 55 | static XLCd |
| 56 | create( |
| 57 | const char *name, |
| 58 | XLCdMethods methods) |
| 59 | { |
| 60 | XLCd lcd; |
| 61 | XLCdPublicMethods new; |
| 62 | |
| 63 | lcd = Xcalloc(1, sizeof(XLCdRec))calloc(((1) == 0 ? 1 : (1)), (sizeof(XLCdRec))); |
| 64 | if (lcd == NULL((void*)0)) |
| 65 | return (XLCd) NULL((void*)0); |
| 66 | |
| 67 | lcd->core = Xcalloc(1, sizeof(XLCdGenericRec))calloc(((1) == 0 ? 1 : (1)), (sizeof(XLCdGenericRec))); |
Result of 'calloc' is converted to a pointer of type 'struct XLCdCoreRec', which is incompatible with sizeof operand type 'XLCdGenericRec' | |
| 68 | if (lcd->core == NULL((void*)0)) |
| 69 | goto err; |
| 70 | |
| 71 | new = Xmalloc(sizeof(XLCdPublicMethodsRec))malloc(((sizeof(XLCdPublicMethodsRec)) == 0 ? 1 : (sizeof(XLCdPublicMethodsRec )))); |
| 72 | if (new == NULL((void*)0)) |
| 73 | goto err; |
| 74 | memcpy(new,methods,sizeof(XLCdPublicMethodsRec))__builtin___memcpy_chk (new, methods, sizeof(XLCdPublicMethodsRec ), __builtin_object_size (new, 0)); |
| 75 | lcd->methods = (XLCdMethods) new; |
| 76 | |
| 77 | return lcd; |
| 78 | |
| 79 | err: |
| 80 | Xfree(lcd)free((lcd)); |
| 81 | return (XLCd) NULL((void*)0); |
| 82 | } |
| 83 | |
| 84 | static Boolint |
| 85 | string_to_encoding( |
| 86 | const char *str, |
| 87 | char *encoding) |
| 88 | { |
| 89 | char *next; |
| 90 | long value; |
| 91 | int base; |
| 92 | |
| 93 | while (*str) { |
| 94 | if (*str == '\\') { |
| 95 | switch (*(str + 1)) { |
| 96 | case 'x': |
| 97 | case 'X': |
| 98 | base = 16; |
| 99 | break; |
| 100 | default: |
| 101 | base = 8; |
| 102 | break; |
| 103 | } |
| 104 | value = strtol(str + 2, &next, base); |
| 105 | if (str + 2 != next) { |
| 106 | *((unsigned char *) encoding++) = (unsigned char) value; |
| 107 | str = next; |
| 108 | continue; |
| 109 | } |
| 110 | } |
| 111 | *encoding++ = *str++; |
| 112 | } |
| 113 | |
| 114 | *encoding = '\0'; |
| 115 | |
| 116 | return True1; |
| 117 | } |
| 118 | |
| 119 | static Boolint |
| 120 | string_to_ulong( |
| 121 | const char *str, |
| 122 | unsigned long *value) |
| 123 | { |
| 124 | const char *tmp1 = str; |
| 125 | int base; |
| 126 | |
| 127 | if (*tmp1++ != '\\') { |
| 128 | tmp1--; |
| 129 | base = 10; |
| 130 | } else { |
| 131 | switch (*tmp1++) { |
| 132 | case 'x': |
| 133 | base = 16; |
| 134 | break; |
| 135 | case 'o': |
| 136 | base = 8; |
| 137 | break; |
| 138 | case 'd': |
| 139 | base = 10; |
| 140 | break; |
| 141 | default: |
| 142 | return(False0); |
| 143 | } |
| 144 | } |
| 145 | *value = (unsigned long) strtol(tmp1, NULL((void*)0), base); |
| 146 | return(True1); |
| 147 | } |
| 148 | |
| 149 | |
| 150 | static Boolint |
| 151 | add_charset( |
| 152 | CodeSet codeset, |
| 153 | XlcCharSet charset) |
| 154 | { |
| 155 | XlcCharSet *new_list; |
| 156 | int num; |
| 157 | |
| 158 | if ((num = codeset->num_charsets)) |
| 159 | new_list = Xrealloc(codeset->charset_list,realloc((codeset->charset_list), (((num + 1) * sizeof(XlcCharSet )) == 0 ? 1 : ((num + 1) * sizeof(XlcCharSet)))) |
| 160 | (num + 1) * sizeof(XlcCharSet))realloc((codeset->charset_list), (((num + 1) * sizeof(XlcCharSet )) == 0 ? 1 : ((num + 1) * sizeof(XlcCharSet)))); |
| 161 | else |
| 162 | new_list = Xmalloc(sizeof(XlcCharSet))malloc(((sizeof(XlcCharSet)) == 0 ? 1 : (sizeof(XlcCharSet))) ); |
| 163 | |
| 164 | if (new_list == NULL((void*)0)) |
| 165 | return False0; |
| 166 | |
| 167 | new_list[num] = charset; |
| 168 | codeset->charset_list = new_list; |
| 169 | codeset->num_charsets = num + 1; |
| 170 | |
| 171 | return True1; |
| 172 | } |
| 173 | |
| 174 | static CodeSet |
| 175 | add_codeset( |
| 176 | XLCdGenericPart *gen) |
| 177 | { |
| 178 | CodeSet new, *new_list; |
| 179 | int num; |
| 180 | |
| 181 | new = Xcalloc(1, sizeof(CodeSetRec))calloc(((1) == 0 ? 1 : (1)), (sizeof(CodeSetRec))); |
| 182 | if (new == NULL((void*)0)) |
| 183 | return NULL((void*)0); |
| 184 | |
| 185 | if ((num = gen->codeset_num)) |
| 186 | new_list = Xrealloc(gen->codeset_list,realloc((gen->codeset_list), (((num + 1) * sizeof(CodeSet) ) == 0 ? 1 : ((num + 1) * sizeof(CodeSet)))) |
| 187 | (num + 1) * sizeof(CodeSet))realloc((gen->codeset_list), (((num + 1) * sizeof(CodeSet) ) == 0 ? 1 : ((num + 1) * sizeof(CodeSet)))); |
| 188 | else |
| 189 | new_list = Xmalloc(sizeof(CodeSet))malloc(((sizeof(CodeSet)) == 0 ? 1 : (sizeof(CodeSet)))); |
| 190 | |
| 191 | if (new_list == NULL((void*)0)) |
| 192 | goto err; |
| 193 | |
| 194 | new_list[num] = new; |
| 195 | gen->codeset_list = new_list; |
| 196 | gen->codeset_num = num + 1; |
| 197 | |
| 198 | return new; |
| 199 | |
| 200 | err: |
| 201 | Xfree(new)free((new)); |
| 202 | |
| 203 | return NULL((void*)0); |
| 204 | } |
| 205 | |
| 206 | static Boolint |
| 207 | add_parse_list( |
| 208 | XLCdGenericPart *gen, |
| 209 | EncodingType type, |
| 210 | const char *encoding, |
| 211 | CodeSet codeset) |
| 212 | { |
| 213 | ParseInfo new, *new_list; |
| 214 | char *str; |
| 215 | unsigned char ch; |
| 216 | int num; |
| 217 | |
| 218 | str = strdup(encoding); |
| 219 | if (str == NULL((void*)0)) |
| 220 | return False0; |
| 221 | |
| 222 | new = Xcalloc(1, sizeof(ParseInfoRec))calloc(((1) == 0 ? 1 : (1)), (sizeof(ParseInfoRec))); |
| 223 | if (new == NULL((void*)0)) |
| 224 | goto err; |
| 225 | |
| 226 | if (gen->mb_parse_table == NULL((void*)0)) { |
| 227 | gen->mb_parse_table = Xcalloc(1, 256)calloc(((1) == 0 ? 1 : (1)), (256)); /* 2^8 */ |
| 228 | if (gen->mb_parse_table == NULL((void*)0)) |
| 229 | goto err; |
| 230 | } |
| 231 | |
| 232 | if ((num = gen->mb_parse_list_num)) |
| 233 | new_list = Xrealloc(gen->mb_parse_list,realloc((gen->mb_parse_list), (((num + 2) * sizeof(ParseInfo )) == 0 ? 1 : ((num + 2) * sizeof(ParseInfo)))) |
| 234 | (num + 2) * sizeof(ParseInfo))realloc((gen->mb_parse_list), (((num + 2) * sizeof(ParseInfo )) == 0 ? 1 : ((num + 2) * sizeof(ParseInfo)))); |
| 235 | else { |
| 236 | new_list = Xmalloc(2 * sizeof(ParseInfo))malloc(((2 * sizeof(ParseInfo)) == 0 ? 1 : (2 * sizeof(ParseInfo )))); |
| 237 | } |
| 238 | |
| 239 | if (new_list == NULL((void*)0)) |
| 240 | goto err; |
| 241 | |
| 242 | new_list[num] = new; |
| 243 | new_list[num + 1] = NULL((void*)0); |
| 244 | gen->mb_parse_list = new_list; |
| 245 | gen->mb_parse_list_num = num + 1; |
| 246 | |
| 247 | ch = (unsigned char) *str; |
| 248 | if (gen->mb_parse_table[ch] == 0) |
| 249 | gen->mb_parse_table[ch] = num + 1; |
| 250 | |
| 251 | new->type = type; |
| 252 | new->encoding = str; |
| 253 | new->codeset = codeset; |
| 254 | |
| 255 | if (codeset->parse_info == NULL((void*)0)) |
| 256 | codeset->parse_info = new; |
| 257 | |
| 258 | return True1; |
| 259 | |
| 260 | err: |
| 261 | Xfree(str)free((str)); |
| 262 | |
| 263 | Xfree(new)free((new)); |
| 264 | |
| 265 | return False0; |
| 266 | } |
| 267 | |
| 268 | static void |
| 269 | free_charset( |
| 270 | XLCd lcd) |
| 271 | { |
| 272 | XLCdGenericPart *gen = XLC_GENERIC_PART(lcd)(&(((XLCdGeneric) lcd->core)->gen)); |
| 273 | ParseInfo *parse_info; |
| 274 | int num; |
| 275 | |
| 276 | Xfree(gen->mb_parse_table)free((gen->mb_parse_table)); |
| 277 | if ((num = gen->mb_parse_list_num) > 0) { |
| 278 | for (parse_info = gen->mb_parse_list; num-- > 0; parse_info++) { |
| 279 | Xfree((*parse_info)->encoding)free(((*parse_info)->encoding)); |
| 280 | Xfree(*parse_info)free((*parse_info)); |
| 281 | } |
| 282 | Xfree(gen->mb_parse_list)free((gen->mb_parse_list)); |
| 283 | } |
| 284 | |
| 285 | if ((num = gen->codeset_num) > 0) |
| 286 | Xfree(gen->codeset_list)free((gen->codeset_list)); |
| 287 | } |
| 288 | |
| 289 | /* For VW/UDC */ |
| 290 | |
| 291 | #define FORWARD(unsigned long)'+' (unsigned long)'+' |
| 292 | #define BACKWARD(unsigned long)'-' (unsigned long)'-' |
| 293 | |
| 294 | static const char * |
| 295 | getscope( |
| 296 | const char *str, |
| 297 | FontScope scp) |
| 298 | { |
| 299 | unsigned long start = 0; |
| 300 | unsigned long end = 0; |
| 301 | unsigned long dest = 0; |
| 302 | unsigned long shift = 0; |
| 303 | unsigned long direction = 0; |
| 304 | sscanf(str,"[\\x%lx,\\x%lx]->\\x%lx", &start, &end, &dest); |
| 305 | if (dest) { |
| 306 | if (dest >= start) { |
| 307 | shift = dest - start; |
| 308 | direction = FORWARD(unsigned long)'+' ; |
| 309 | } else { |
| 310 | shift = start - dest; |
| 311 | direction = BACKWARD(unsigned long)'-'; |
| 312 | } |
| 313 | } |
| 314 | scp->start = start ; |
| 315 | scp->end = end ; |
| 316 | scp->shift = shift ; |
| 317 | scp->shift_direction |
| 318 | = direction ; |
| 319 | /* .......... */ |
| 320 | while (*str) { |
| 321 | if (*str == ',' && *(str+1) == '[') |
| 322 | break; |
| 323 | str++; |
| 324 | } |
| 325 | return str+1; |
| 326 | } |
| 327 | |
| 328 | static int |
| 329 | count_scopemap( |
| 330 | const char *str) |
| 331 | { |
| 332 | const char *ptr; |
| 333 | int num=0; |
| 334 | for (ptr=str; *ptr; ptr++) { |
| 335 | if (*ptr == ']') { |
| 336 | num++; |
| 337 | } |
| 338 | } |
| 339 | return num; |
| 340 | } |
| 341 | |
| 342 | FontScope |
| 343 | _XlcParse_scopemaps( |
| 344 | const char *str, |
| 345 | int *size) |
| 346 | { |
| 347 | int num=0,i; |
| 348 | FontScope scope,sc_ptr; |
| 349 | const char *str_sc; |
| 350 | |
| 351 | num = count_scopemap(str); |
| 352 | scope = Xmalloc(num * sizeof(FontScopeRec))malloc(((num * sizeof(FontScopeRec)) == 0 ? 1 : (num * sizeof (FontScopeRec)))); |
| 353 | if (scope == NULL((void*)0)) |
| 354 | return NULL((void*)0); |
| 355 | |
| 356 | for (i=0, str_sc=str, sc_ptr=scope; i < num; i++, sc_ptr++) { |
| 357 | str_sc = getscope(str_sc, sc_ptr); |
| 358 | } |
| 359 | *size = num; |
| 360 | return scope; |
| 361 | } |
| 362 | |
| 363 | void |
| 364 | _XlcDbg_printValue( |
| 365 | const char *str, |
| 366 | char **value, |
| 367 | int num) |
| 368 | { |
| 369 | /* |
| 370 | int i; |
| 371 | for (i = 0; i < num; i++) |
| 372 | fprintf(stderr, "%s value[%d] = %s\n", str, i, value[i]); |
| 373 | */ |
| 374 | } |
| 375 | |
| 376 | static void |
| 377 | dmpscope( |
| 378 | const char* name, |
| 379 | FontScope sc, |
| 380 | int num) |
| 381 | { |
| 382 | /* |
| 383 | int i; |
| 384 | fprintf(stderr, "dmpscope %s\n", name); |
| 385 | for (i=0; i<num; i++) |
| 386 | fprintf(stderr,"%x %x %x %x \n", |
| 387 | sc[i].start, |
| 388 | sc[i].end, |
| 389 | sc[i].shift, |
| 390 | sc[i].shift_direction); |
| 391 | fprintf(stderr, "dmpscope end\n"); |
| 392 | */ |
| 393 | } |
| 394 | |
| 395 | static XlcCharSet |
| 396 | srch_charset_define( |
| 397 | const char *name, |
| 398 | int *new) |
| 399 | { |
| 400 | XlcCharSet charset; |
| 401 | |
| 402 | *new = 0; |
| 403 | charset = _XlcGetCharSet(name); |
| 404 | if (charset == NULL((void*)0) && |
| 405 | (charset = _XlcCreateDefaultCharSet(name, ""))) { |
| 406 | _XlcAddCharSet(charset); |
| 407 | *new = 1; |
| 408 | charset->source = CSsrcXLC; |
| 409 | } |
| 410 | return charset; |
| 411 | } |
| 412 | |
| 413 | static void |
| 414 | read_charset_define( |
| 415 | XLCd lcd, |
| 416 | XLCdGenericPart *gen) |
| 417 | { |
| 418 | int i; |
| 419 | char csd[16], cset_name[256]; |
| 420 | char name[BUFSIZ1024]; |
| 421 | XlcCharSet charsetd; |
| 422 | char **value; |
| 423 | int num, new = 0; |
| 424 | XlcSide side = XlcUnknown; |
| 425 | char *tmp; |
| 426 | |
| 427 | for (i=0; ; i++) { /* loop start */ |
| 428 | charsetd = 0; |
| 429 | snprintf(csd, sizeof(csd), "csd%d", i)__builtin___snprintf_chk (csd, sizeof(csd), 0, __builtin_object_size (csd, 2 > 1 ? 1 : 0), "csd%d", i); |
| 430 | |
| 431 | /* charset_name */ |
| 432 | snprintf(name, sizeof(name), "%s.%s", csd, "charset_name")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", csd, "charset_name"); |
| 433 | _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); |
| 434 | _XlcDbg_printValue(name,value,num); |
| 435 | if (num > 0) { |
| 436 | /* hackers will get truncated -- C'est la vie */ |
| 437 | strncpy(cset_name,value[0], sizeof cset_name - 1)__builtin___strncpy_chk (cset_name, value[0], sizeof cset_name - 1, __builtin_object_size (cset_name, 2 > 1 ? 1 : 0)); |
| 438 | cset_name[(sizeof cset_name) - 1] = '\0'; |
| 439 | snprintf(name, sizeof(name), "%s.%s", csd , "side")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", csd , "side"); |
| 440 | _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); |
| 441 | if (num > 0) { |
| 442 | _XlcDbg_printValue(name,value,num); |
| 443 | if (!_XlcNCompareISOLatin1(value[0], "none", 4)) { |
| 444 | side = XlcGLGR; |
| 445 | } else if (!_XlcNCompareISOLatin1(value[0], "GL", 2)) { |
| 446 | side = XlcGL; |
| 447 | strcat(cset_name,":GL")__builtin___strcat_chk (cset_name, ":GL", __builtin_object_size (cset_name, 2 > 1 ? 1 : 0)); |
| 448 | } else { |
| 449 | side = XlcGR; |
| 450 | strcat(cset_name,":GR")__builtin___strcat_chk (cset_name, ":GR", __builtin_object_size (cset_name, 2 > 1 ? 1 : 0)); |
| 451 | } |
| 452 | if (charsetd == NULL((void*)0) && |
| 453 | (charsetd = srch_charset_define(cset_name,&new)) == NULL((void*)0)) |
| 454 | return; |
| 455 | } |
| 456 | } else { |
| 457 | if (i == 0) |
| 458 | continue; |
| 459 | else |
| 460 | break; |
| 461 | } |
| 462 | if (new) { |
| 463 | tmp = strdup(cset_name); |
| 464 | if (tmp == NULL((void*)0)) |
| 465 | return; |
| 466 | charsetd->name = tmp; |
| 467 | } |
| 468 | /* side */ |
| 469 | charsetd->side = side ; |
| 470 | /* length */ |
| 471 | snprintf(name, sizeof(name), "%s.%s", csd, "length")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", csd, "length"); |
| 472 | _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); |
| 473 | if (num > 0) { |
| 474 | _XlcDbg_printValue(name,value,num); |
| 475 | charsetd->char_size = atoi(value[0]); |
| 476 | } |
| 477 | /* gc_number */ |
| 478 | snprintf(name, sizeof(name), "%s.%s", csd, "gc_number")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", csd, "gc_number"); |
| 479 | _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); |
| 480 | if (num > 0) { |
| 481 | _XlcDbg_printValue(name,value,num); |
| 482 | charsetd->set_size = atoi(value[0]); |
| 483 | } |
| 484 | /* string_encoding */ |
| 485 | snprintf(name, sizeof(name), "%s.%s", csd, "string_encoding")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", csd, "string_encoding"); |
| 486 | _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); |
| 487 | if (num > 0) { |
| 488 | _XlcDbg_printValue(name,value,num); |
| 489 | if (!strcmp("False",value[0])) { |
| 490 | charsetd->string_encoding = False0; |
| 491 | } else { |
| 492 | charsetd->string_encoding = True1; |
| 493 | } |
| 494 | } |
| 495 | /* sequence */ |
| 496 | snprintf(name, sizeof(name), "%s.%s", csd, "sequence")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", csd, "sequence"); |
| 497 | _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); |
| 498 | if (num > 0) { |
| 499 | _XlcDbg_printValue(name,value,num); |
| 500 | /* |
| 501 | if (charsetd->ct_sequence) { |
| 502 | Xfree(charsetd->ct_sequence); |
| 503 | } |
| 504 | */ |
| 505 | tmp = Xmalloc(strlen(value[0])+1)malloc(((strlen(value[0])+1) == 0 ? 1 : (strlen(value[0])+1)) ); |
| 506 | if (tmp == NULL((void*)0)) |
| 507 | return; |
| 508 | charsetd->ct_sequence = tmp; |
| 509 | string_to_encoding(value[0],tmp); |
| 510 | } |
| 511 | /* encoding_name */ |
| 512 | snprintf(name, sizeof(name), "%s.%s", csd, "encoding_name")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", csd, "encoding_name"); |
| 513 | _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); |
| 514 | if (num > 0) { |
| 515 | _XlcDbg_printValue(name,value,num); |
| 516 | /* |
| 517 | if (charsetd->encoding_name) { |
| 518 | Xfree(charsetd->encoding_name); |
| 519 | } |
| 520 | */ |
| 521 | tmp = strdup(value[0]); |
| 522 | charsetd->encoding_name = tmp; |
| 523 | charsetd->xrm_encoding_name = XrmStringToQuark(tmp); |
| 524 | } |
| 525 | _XlcAddCT(charsetd->name, charsetd->ct_sequence); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | static SegConv |
| 530 | add_conversion( |
| 531 | XLCdGenericPart *gen) |
| 532 | { |
| 533 | SegConv new_list; |
| 534 | int num; |
| 535 | |
| 536 | if ((num = gen->segment_conv_num) > 0) { |
| 537 | new_list = Xrealloc(gen->segment_conv,realloc((gen->segment_conv), (((num + 1) * sizeof(SegConvRec )) == 0 ? 1 : ((num + 1) * sizeof(SegConvRec)))) |
| 538 | (num + 1) * sizeof(SegConvRec))realloc((gen->segment_conv), (((num + 1) * sizeof(SegConvRec )) == 0 ? 1 : ((num + 1) * sizeof(SegConvRec)))); |
| 539 | } else { |
| 540 | new_list = Xmalloc(sizeof(SegConvRec))malloc(((sizeof(SegConvRec)) == 0 ? 1 : (sizeof(SegConvRec))) ); |
| 541 | } |
| 542 | |
| 543 | if (new_list == NULL((void*)0)) |
| 544 | return NULL((void*)0); |
| 545 | |
| 546 | gen->segment_conv = new_list; |
| 547 | gen->segment_conv_num = num + 1; |
| 548 | |
| 549 | return &new_list[num]; |
| 550 | |
| 551 | } |
| 552 | |
| 553 | static void |
| 554 | read_segmentconversion( |
| 555 | XLCd lcd, |
| 556 | XLCdGenericPart *gen) |
| 557 | { |
| 558 | int i; |
| 559 | char conv[16]; |
| 560 | char name[BUFSIZ1024]; |
| 561 | char **value; |
| 562 | int num,new; |
| 563 | SegConv conversion; |
| 564 | for (i=0 ; ; i++) { /* loop start */ |
| 565 | conversion = 0; |
| 566 | snprintf(conv, sizeof(conv), "conv%d", i)__builtin___snprintf_chk (conv, sizeof(conv), 0, __builtin_object_size (conv, 2 > 1 ? 1 : 0), "conv%d", i); |
| 567 | |
| 568 | /* length */ |
| 569 | snprintf(name, sizeof(name), "%s.%s", conv, "length")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", conv, "length"); |
| 570 | _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); |
| 571 | if (num > 0) { |
| 572 | if (conversion == NULL((void*)0) && |
| 573 | (conversion = add_conversion(gen)) == NULL((void*)0)) { |
| 574 | return; |
| 575 | } |
| 576 | _XlcDbg_printValue(name,value,num); |
| 577 | } else { |
| 578 | if (i == 0) |
| 579 | continue; |
| 580 | else |
| 581 | break; |
| 582 | } |
| 583 | conversion->length = atoi(value[0]); |
| 584 | |
| 585 | /* source_encoding */ |
| 586 | snprintf(name, sizeof(name), "%s.%s", conv, "source_encoding")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", conv, "source_encoding"); |
| 587 | _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); |
| 588 | if (num > 0) { |
| 589 | char *tmp; |
| 590 | _XlcDbg_printValue(name,value,num); |
| 591 | tmp = strdup(value[0]); |
| 592 | if (tmp == NULL((void*)0)) |
| 593 | return; |
| 594 | conversion->source_encoding = tmp; |
| 595 | conversion->source = srch_charset_define(tmp,&new); |
| 596 | } |
| 597 | /* destination_encoding */ |
| 598 | snprintf(name, sizeof(name), "%s.%s", conv, "destination_encoding")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", conv, "destination_encoding" ); |
| 599 | _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); |
| 600 | if (num > 0) { |
| 601 | char *tmp; |
| 602 | _XlcDbg_printValue(name,value,num); |
| 603 | tmp = strdup(value[0]); |
| 604 | if (tmp == NULL((void*)0)) |
| 605 | return; |
| 606 | conversion->destination_encoding = tmp; |
| 607 | conversion->dest = srch_charset_define(tmp,&new); |
| 608 | } |
| 609 | /* range */ |
| 610 | snprintf(name, sizeof(name), "%s.%s", conv, "range")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", conv, "range"); |
| 611 | _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); |
| 612 | if (num > 0) { |
| 613 | _XlcDbg_printValue(name,value,num); |
| 614 | sscanf(value[0],"\\x%lx,\\x%lx", |
| 615 | &(conversion->range.start), &(conversion->range.end)); |
| 616 | } |
| 617 | /* conversion */ |
| 618 | snprintf(name, sizeof(name), "%s.%s", conv, "conversion")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", conv, "conversion"); |
| 619 | _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); |
| 620 | if (num > 0) { |
| 621 | _XlcDbg_printValue(name,value,num); |
| 622 | conversion->conv = |
| 623 | _XlcParse_scopemaps(value[0],&conversion->conv_num); |
| 624 | } |
| 625 | } /* loop end */ |
| 626 | } |
| 627 | |
| 628 | static ExtdSegment |
| 629 | create_ctextseg( |
| 630 | char **value, |
| 631 | int num) |
| 632 | { |
| 633 | ExtdSegment ret; |
| 634 | char* ptr; |
| 635 | char* cset_name = NULL((void*)0); |
| 636 | size_t cset_len; |
| 637 | int i,new; |
| 638 | FontScope scope; |
| 639 | ret = Xmalloc(sizeof(ExtdSegmentRec))malloc(((sizeof(ExtdSegmentRec)) == 0 ? 1 : (sizeof(ExtdSegmentRec )))); |
| 640 | if (ret == NULL((void*)0)) |
| 641 | return NULL((void*)0); |
| 642 | ret->name = strdup(value[0]); |
| 643 | if (ret->name == NULL((void*)0)) { |
| 644 | Xfree (ret)free((ret)); |
| 645 | return NULL((void*)0); |
| 646 | } |
| 647 | cset_len = strlen(ret->name) + 1; |
| 648 | cset_name = Xmalloc (cset_len)malloc(((cset_len) == 0 ? 1 : (cset_len))); |
| 649 | if (cset_name == NULL((void*)0)) { |
| 650 | Xfree (ret->name)free((ret->name)); |
| 651 | Xfree (ret)free((ret)); |
| 652 | return NULL((void*)0); |
| 653 | } |
| 654 | if (strchr(value[0],':')) { |
| 655 | ptr = strchr(ret->name,':'); |
| 656 | *ptr = '\0'; |
| 657 | ptr++; |
| 658 | if (!_XlcNCompareISOLatin1(ptr, "GL", 2)) { |
| 659 | ret->side = XlcGL; |
| 660 | snprintf(cset_name, cset_len, "%s:%s", ret->name, "GL")__builtin___snprintf_chk (cset_name, cset_len, 0, __builtin_object_size (cset_name, 2 > 1 ? 1 : 0), "%s:%s", ret->name, "GL"); |
| 661 | } else { |
| 662 | ret->side = XlcGR; |
| 663 | snprintf(cset_name, cset_len, "%s:%s", ret->name, "GR")__builtin___snprintf_chk (cset_name, cset_len, 0, __builtin_object_size (cset_name, 2 > 1 ? 1 : 0), "%s:%s", ret->name, "GR"); |
| 664 | } |
| 665 | } else { |
| 666 | ret->side = XlcGLGR; |
| 667 | strcpy(cset_name,ret->name)__builtin___strcpy_chk (cset_name, ret->name, __builtin_object_size (cset_name, 2 > 1 ? 1 : 0)); |
| 668 | } |
| 669 | ret->area = Xmalloc((num - 1)*sizeof(FontScopeRec))malloc((((num - 1)*sizeof(FontScopeRec)) == 0 ? 1 : ((num - 1 )*sizeof(FontScopeRec)))); |
| 670 | if (ret->area == NULL((void*)0)) { |
| 671 | Xfree (cset_name)free((cset_name)); |
| 672 | Xfree (ret->name)free((ret->name)); |
| 673 | Xfree (ret)free((ret)); |
| 674 | return NULL((void*)0); |
| 675 | } |
| 676 | ret->area_num = num - 1; |
| 677 | scope = ret->area ; |
| 678 | for (i = 1; i < num; i++) { |
| 679 | sscanf(value[i],"\\x%lx,\\x%lx", |
| 680 | &scope[i-1].start, &scope[i-1].end); |
| 681 | } |
| 682 | ret->charset = srch_charset_define(cset_name,&new); |
| 683 | Xfree (cset_name)free((cset_name)); |
| 684 | |
| 685 | return ret; |
| 686 | } |
| 687 | /* For VW/UDC end */ |
| 688 | |
| 689 | static Boolint |
| 690 | load_generic( |
| 691 | XLCd lcd) |
| 692 | { |
| 693 | XLCdGenericPart *gen = XLC_GENERIC_PART(lcd)(&(((XLCdGeneric) lcd->core)->gen)); |
| 694 | char **value; |
| 695 | int num; |
| 696 | unsigned long l; |
| 697 | int i; |
| 698 | int M,ii; |
| 699 | XlcCharSet charset; |
| 700 | |
| 701 | gen->codeset_num = 0; |
| 702 | |
| 703 | /***** wc_encoding_mask *****/ |
| 704 | _XlcGetResource(lcd, "XLC_XLOCALE", "wc_encoding_mask", &value, &num); |
| 705 | if (num > 0) { |
| 706 | if (string_to_ulong(value[0], &l) == False0) |
| 707 | goto err; |
| 708 | gen->wc_encode_mask = l; |
| 709 | } |
| 710 | /***** wc_shift_bits *****/ |
| 711 | _XlcGetResource(lcd, "XLC_XLOCALE", "wc_shift_bits", &value, &num); |
| 712 | if (num > 0) |
| 713 | gen->wc_shift_bits = atoi(value[0]); |
| 714 | if (gen->wc_shift_bits < 1) |
| 715 | gen->wc_shift_bits = 8; |
| 716 | /***** use_stdc_env *****/ |
| 717 | _XlcGetResource(lcd, "XLC_XLOCALE", "use_stdc_env", &value, &num); |
| 718 | if (num > 0 && !_XlcCompareISOLatin1(value[0], "True")) |
| 719 | gen->use_stdc_env = True1; |
| 720 | else |
| 721 | gen->use_stdc_env = False0; |
| 722 | /***** force_convert_to_mb *****/ |
| 723 | _XlcGetResource(lcd, "XLC_XLOCALE", "force_convert_to_mb", &value, &num); |
| 724 | if (num > 0 && !_XlcCompareISOLatin1(value[0], "True")) |
| 725 | gen->force_convert_to_mb = True1; |
| 726 | else |
| 727 | gen->force_convert_to_mb = False0; |
| 728 | |
| 729 | for (i = 0; ; i++) { |
| 730 | CodeSetRec *codeset = NULL((void*)0); |
| 731 | char cs[16]; |
| 732 | char name[BUFSIZ1024]; |
| 733 | |
| 734 | snprintf(cs, sizeof(cs), "cs%d", i)__builtin___snprintf_chk (cs, sizeof(cs), 0, __builtin_object_size (cs, 2 > 1 ? 1 : 0), "cs%d", i); |
| 735 | |
| 736 | /***** codeset.side *****/ |
| 737 | snprintf(name, sizeof(name), "%s.%s", cs , "side")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs , "side"); |
| 738 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 739 | if (num > 0) { |
| 740 | char *tmp; |
| 741 | |
| 742 | if (codeset == NULL((void*)0) && (codeset = add_codeset(gen)) == NULL((void*)0)) |
| 743 | goto err; |
| 744 | |
| 745 | /* 3.4.1 side */ |
| 746 | if (!_XlcNCompareISOLatin1(value[0], "none", 4)) { |
| 747 | codeset->side = XlcNONE; |
| 748 | } else if (!_XlcNCompareISOLatin1(value[0], "GL", 2)) { |
| 749 | codeset->side = XlcGL; |
| 750 | } else { |
| 751 | codeset->side = XlcGR; |
| 752 | } |
| 753 | |
| 754 | tmp = strrchr(value[0], ':'); |
| 755 | if (tmp != NULL((void*)0) && !_XlcCompareISOLatin1(tmp + 1, "Default")) { |
| 756 | if (codeset->side == XlcGR) |
| 757 | gen->initial_state_GR = codeset; |
| 758 | else |
| 759 | gen->initial_state_GL = codeset; |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | /***** codeset.length *****/ |
| 764 | snprintf(name, sizeof(name), "%s.%s", cs , "length")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs , "length"); |
| 765 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 766 | if (num > 0) { |
| 767 | if (codeset == NULL((void*)0) && (codeset = add_codeset(gen)) == NULL((void*)0)) |
| 768 | goto err; |
| 769 | codeset->length = atoi(value[0]); |
| 770 | if (codeset->length < 1) |
| 771 | codeset->length = 1; |
| 772 | } |
| 773 | |
| 774 | /***** codeset.mb_encoding *****/ |
| 775 | snprintf(name, sizeof(name), "%s.%s", cs, "mb_encoding")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs, "mb_encoding"); |
| 776 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 777 | if (num > 0) { |
| 778 | static struct { |
| 779 | const char *str; |
| 780 | EncodingType type; |
| 781 | } shifts[] = { |
| 782 | {"<SS>", E_SS}, |
| 783 | {"<LSL>", E_LSL}, |
| 784 | {"<LSR>", E_LSR}, |
| 785 | {0} |
| 786 | }; |
| 787 | int j; |
| 788 | |
| 789 | if (codeset == NULL((void*)0) && (codeset = add_codeset(gen)) == NULL((void*)0)) |
| 790 | goto err; |
| 791 | for ( ; num-- > 0; value++) { |
| 792 | char encoding[256]; |
| 793 | char *tmp = *value; |
| 794 | EncodingType type = E_SS; /* for BC */ |
| 795 | for (j = 0; shifts[j].str; j++) { |
| 796 | if (!_XlcNCompareISOLatin1(tmp, shifts[j].str, |
| 797 | strlen(shifts[j].str))) { |
| 798 | type = shifts[j].type; |
| 799 | tmp += strlen(shifts[j].str); |
| 800 | break; |
| 801 | } |
| 802 | } |
| 803 | if (strlen (tmp) > sizeof encoding || |
| 804 | string_to_encoding(tmp, encoding) == False0) |
| 805 | goto err; |
| 806 | add_parse_list(gen, type, encoding, codeset); |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | /***** codeset.wc_encoding *****/ |
| 811 | snprintf(name, sizeof(name), "%s.%s", cs, "wc_encoding")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs, "wc_encoding"); |
| 812 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 813 | if (num > 0) { |
| 814 | if (codeset == NULL((void*)0) && (codeset = add_codeset(gen)) == NULL((void*)0)) |
| 815 | goto err; |
| 816 | if (string_to_ulong(value[0], &l) == False0) |
| 817 | goto err; |
| 818 | codeset->wc_encoding = l; |
| 819 | } |
| 820 | |
| 821 | /***** codeset.ct_encoding *****/ |
| 822 | snprintf(name, sizeof(name), "%s.%s", cs, "ct_encoding")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs, "ct_encoding"); |
| 823 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 824 | if (num > 0) { |
| 825 | char *encoding; |
| 826 | |
| 827 | if (codeset == NULL((void*)0) && (codeset = add_codeset(gen)) == NULL((void*)0)) |
| 828 | goto err; |
| 829 | for ( ; num-- > 0; value++) { |
| 830 | if (strlen (*value) > sizeof name) |
| 831 | goto err; |
| 832 | string_to_encoding(*value, name); |
| 833 | charset = NULL((void*)0); |
| 834 | if ((encoding = strchr(name, ':')) && |
| 835 | (encoding = strchr(encoding + 1, ':'))) { |
| 836 | *encoding++ = '\0'; |
| 837 | charset = _XlcAddCT(name, encoding); |
| 838 | } |
| 839 | if (charset == NULL((void*)0)) { |
| 840 | charset = _XlcGetCharSet(name); |
| 841 | if (charset == NULL((void*)0) && |
| 842 | (charset = _XlcCreateDefaultCharSet(name, ""))) { |
| 843 | charset->side = codeset->side; |
| 844 | charset->char_size = codeset->length; |
| 845 | _XlcAddCharSet(charset); |
| 846 | } |
| 847 | } |
| 848 | if (charset) { |
| 849 | if (add_charset(codeset, charset) == False0) |
| 850 | goto err; |
| 851 | } |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | if (codeset == NULL((void*)0)) |
| 856 | break; |
| 857 | codeset->cs_num = i; |
| 858 | /* For VW/UDC */ |
| 859 | /***** 3.4.2 byteM (1 <= M <= length)*****/ |
| 860 | for (M=1; M-1 < codeset->length; M++) { |
| 861 | unsigned long start,end; |
| 862 | ByteInfo tmpb; |
| 863 | |
| 864 | snprintf(name, sizeof(name),"%s.%s%d",cs,"byte",M)__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s%d",cs,"byte",M); |
| 865 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 866 | |
| 867 | if (M == 1) { |
| 868 | if (num < 1) { |
| 869 | codeset->byteM = NULL((void*)0); |
| 870 | break ; |
| 871 | } |
| 872 | codeset->byteM = Xmalloc(malloc((((codeset->length)*sizeof(ByteInfoListRec)) == 0 ? 1 : ((codeset->length)*sizeof(ByteInfoListRec)))) |
| 873 | (codeset->length)*sizeof(ByteInfoListRec))malloc((((codeset->length)*sizeof(ByteInfoListRec)) == 0 ? 1 : ((codeset->length)*sizeof(ByteInfoListRec)))); |
| 874 | if (codeset->byteM == NULL((void*)0)) { |
| 875 | goto err; |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | if (num > 0) { |
| 880 | _XlcDbg_printValue(name,value,num); |
| 881 | (codeset->byteM)[M-1].M = M; |
| 882 | (codeset->byteM)[M-1].byteinfo_num = num; |
| 883 | (codeset->byteM)[M-1].byteinfo = |
| 884 | Xmalloc(num * sizeof(ByteInfoRec))malloc(((num * sizeof(ByteInfoRec)) == 0 ? 1 : (num * sizeof( ByteInfoRec)))); |
| 885 | for (ii = 0 ; ii < num ; ii++) { |
| 886 | tmpb = (codeset->byteM)[M-1].byteinfo ; |
| 887 | /* default 0x00 - 0xff */ |
| 888 | sscanf(value[ii],"\\x%lx,\\x%lx",&start,&end); |
| 889 | tmpb[ii].start = (unsigned char)start; |
| 890 | tmpb[ii].end = (unsigned char)end; |
| 891 | } |
| 892 | } |
| 893 | /* .... */ |
| 894 | } |
| 895 | |
| 896 | |
| 897 | /***** codeset.mb_conversion *****/ |
| 898 | snprintf(name, sizeof(name), "%s.%s", cs, "mb_conversion")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs, "mb_conversion"); |
| 899 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 900 | if (num > 0) { |
| 901 | _XlcDbg_printValue(name,value,num); |
| 902 | codeset->mbconv = Xmalloc(sizeof(ConversionRec))malloc(((sizeof(ConversionRec)) == 0 ? 1 : (sizeof(ConversionRec )))); |
| 903 | codeset->mbconv->convlist = |
| 904 | _XlcParse_scopemaps(value[0],&(codeset->mbconv->conv_num)); |
| 905 | dmpscope("mb_conv",codeset->mbconv->convlist, |
| 906 | codeset->mbconv->conv_num); |
| 907 | /* [\x%x,\x%x]->\x%x,... */ |
| 908 | } |
| 909 | /***** codeset.ct_conversion *****/ |
| 910 | snprintf(name, sizeof(name), "%s.%s", cs, "ct_conversion")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs, "ct_conversion"); |
| 911 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 912 | if (num > 0) { |
| 913 | _XlcDbg_printValue(name,value,num); |
| 914 | codeset->ctconv = Xmalloc(sizeof(ConversionRec))malloc(((sizeof(ConversionRec)) == 0 ? 1 : (sizeof(ConversionRec )))); |
| 915 | codeset->ctconv->convlist = |
| 916 | _XlcParse_scopemaps(value[0],&(codeset->ctconv->conv_num)); |
| 917 | dmpscope("ctconv",codeset->ctconv->convlist, |
| 918 | codeset->ctconv->conv_num); |
| 919 | /* [\x%x,\x%x]->\x%x,... */ |
| 920 | } |
| 921 | /***** codeset.ct_conversion_file *****/ |
| 922 | snprintf(name, sizeof(name), "%s.%s", cs, "ct_conversion_file")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs, "ct_conversion_file"); |
| 923 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 924 | if (num > 0) { |
| 925 | _XlcDbg_printValue(name,value,num); |
| 926 | /* [\x%x,\x%x]->\x%x,... */ |
| 927 | } |
| 928 | /***** codeset.ct_extended_segment *****/ |
| 929 | snprintf(name, sizeof(name), "%s.%s", cs, "ct_extended_segment")__builtin___snprintf_chk (name, sizeof(name), 0, __builtin_object_size (name, 2 > 1 ? 1 : 0), "%s.%s", cs, "ct_extended_segment" ); |
| 930 | _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); |
| 931 | if (num > 0) { |
| 932 | _XlcDbg_printValue(name,value,num); |
| 933 | codeset->ctextseg = create_ctextseg(value,num); |
| 934 | /* [\x%x,\x%x]->\x%x,... */ |
| 935 | } |
| 936 | /* For VW/UDC end */ |
| 937 | |
| 938 | } |
| 939 | |
| 940 | read_charset_define(lcd,gen); /* For VW/UDC */ |
| 941 | read_segmentconversion(lcd,gen); /* For VW/UDC */ |
| 942 | |
| 943 | if (gen->initial_state_GL == NULL((void*)0)) { |
| 944 | CodeSetRec *codeset; |
| 945 | for (i = 0; i < gen->codeset_num; i++) { |
| 946 | codeset = gen->codeset_list[i]; |
| 947 | if (codeset->side == XlcGL) |
| 948 | gen->initial_state_GL = codeset; |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | if (gen->initial_state_GR == NULL((void*)0)) { |
| 953 | CodeSetRec *codeset; |
| 954 | for (i = 0; i < gen->codeset_num; i++) { |
| 955 | codeset = gen->codeset_list[i]; |
| 956 | if (codeset->side == XlcGR) |
| 957 | gen->initial_state_GR = codeset; |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | for (i = 0; i < gen->codeset_num; i++) { |
| 962 | CodeSetRec *codeset = gen->codeset_list[i]; |
| 963 | for (ii = 0; ii < codeset->num_charsets; ii++) { |
| 964 | charset = codeset->charset_list[ii]; |
| 965 | if (! strcmp(charset->encoding_name, "ISO8859-1")) |
| 966 | charset->string_encoding = True1; |
| 967 | if ( charset->string_encoding ) |
| 968 | codeset->string_encoding = True1; |
| 969 | } |
| 970 | } |
| 971 | return True1; |
| 972 | |
| 973 | err: |
| 974 | free_charset(lcd); |
| 975 | |
| 976 | return False0; |
| 977 | } |
| 978 | |
| 979 | #ifdef USE_DYNAMIC_LC |
| 980 | /* override the open_om and open_im methods which were set by |
| 981 | super_class's initialize method() */ |
| 982 | |
| 983 | static Boolint |
| 984 | initialize_core( |
| 985 | XLCd lcd) |
| 986 | { |
| 987 | _XInitDynamicOM(lcd); |
| 988 | |
| 989 | _XInitDynamicIM(lcd); |
| 990 | |
| 991 | return True1; |
| 992 | } |
| 993 | #endif |
| 994 | |
| 995 | static Boolint |
| 996 | initialize(XLCd lcd) |
| 997 | { |
| 998 | XLCdPublicMethods superclass = (XLCdPublicMethods) _XlcPublicMethods; |
| 999 | |
| 1000 | XLC_PUBLIC_METHODS(lcd)(&(((XLCdPublicMethods) lcd->methods)->pub))->superclass = superclass; |
| 1001 | |
| 1002 | if (superclass->pub.initialize) { |
| 1003 | if ((*superclass->pub.initialize)(lcd) == False0) |
| 1004 | return False0; |
| 1005 | } |
| 1006 | |
| 1007 | #ifdef USE_DYNAMIC_LC |
| 1008 | if (initialize_core(lcd) == False0) |
| 1009 | return False0; |
| 1010 | #endif |
| 1011 | |
| 1012 | if (load_generic(lcd) == False0) |
| 1013 | return False0; |
| 1014 | |
| 1015 | return True1; |
| 1016 | } |
| 1017 | |
| 1018 | /* VW/UDC start 95.01.08 */ |
| 1019 | static void |
| 1020 | freeByteM( |
| 1021 | CodeSet codeset) |
| 1022 | { |
| 1023 | int i; |
| 1024 | ByteInfoList blst; |
| 1025 | if (codeset->byteM == NULL((void*)0)) { |
| 1026 | return ; |
| 1027 | } |
| 1028 | blst = codeset->byteM; |
| 1029 | for (i = 0; i < codeset->length; i++) { |
| 1030 | if (blst[i].byteinfo) { |
| 1031 | Xfree(blst[i].byteinfo)free((blst[i].byteinfo)); |
| 1032 | blst[i].byteinfo = NULL((void*)0); |
| 1033 | } |
| 1034 | } |
| 1035 | Xfree(codeset->byteM)free((codeset->byteM)); |
| 1036 | codeset->byteM = NULL((void*)0); |
| 1037 | } |
| 1038 | |
| 1039 | static void |
| 1040 | freeConversion( |
| 1041 | CodeSet codeset) |
| 1042 | { |
| 1043 | Conversion mbconv,ctconv; |
| 1044 | if (codeset->mbconv) { |
| 1045 | mbconv = codeset->mbconv; |
| 1046 | /* ... */ |
| 1047 | if (mbconv->convlist) { |
| 1048 | Xfree(mbconv->convlist)free((mbconv->convlist)); |
| 1049 | mbconv->convlist = NULL((void*)0); |
| 1050 | } |
| 1051 | Xfree(mbconv)free((mbconv)); |
| 1052 | codeset->mbconv = NULL((void*)0); |
| 1053 | } |
| 1054 | if (codeset->ctconv) { |
| 1055 | ctconv = codeset->ctconv; |
| 1056 | /* ... */ |
| 1057 | if (ctconv->convlist) { |
| 1058 | Xfree(ctconv->convlist)free((ctconv->convlist)); |
| 1059 | ctconv->convlist = NULL((void*)0); |
| 1060 | } |
| 1061 | Xfree(ctconv)free((ctconv)); |
| 1062 | codeset->ctconv = NULL((void*)0); |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | static void |
| 1067 | freeExtdSegment( |
| 1068 | CodeSet codeset) |
| 1069 | { |
| 1070 | ExtdSegment ctextseg; |
| 1071 | if (codeset->ctextseg == NULL((void*)0)) { |
| 1072 | return; |
| 1073 | } |
| 1074 | ctextseg = codeset->ctextseg; |
| 1075 | if (ctextseg->name) { |
| 1076 | Xfree(ctextseg->name)free((ctextseg->name)); |
| 1077 | ctextseg->name = NULL((void*)0); |
| 1078 | } |
| 1079 | if (ctextseg->area) { |
| 1080 | Xfree(ctextseg->area)free((ctextseg->area)); |
| 1081 | ctextseg->area = NULL((void*)0); |
| 1082 | } |
| 1083 | Xfree(codeset->ctextseg)free((codeset->ctextseg)); |
| 1084 | codeset->ctextseg = NULL((void*)0); |
| 1085 | } |
| 1086 | |
| 1087 | static void |
| 1088 | freeParseInfo( |
| 1089 | CodeSet codeset) |
| 1090 | { |
| 1091 | ParseInfo parse_info; |
| 1092 | if (codeset->parse_info == NULL((void*)0)) { |
| 1093 | return; |
| 1094 | } |
| 1095 | parse_info = codeset->parse_info; |
| 1096 | if (parse_info->encoding) { |
| 1097 | Xfree(parse_info->encoding)free((parse_info->encoding)); |
| 1098 | parse_info->encoding = NULL((void*)0); |
| 1099 | } |
| 1100 | Xfree(codeset->parse_info)free((codeset->parse_info)); |
| 1101 | codeset->parse_info = NULL((void*)0); |
| 1102 | } |
| 1103 | |
| 1104 | static void |
| 1105 | destroy_CodeSetList( |
| 1106 | XLCdGenericPart *gen) |
| 1107 | { |
| 1108 | CodeSet *codeset = gen->codeset_list; |
| 1109 | int i; |
| 1110 | if (gen->codeset_num == 0) { |
| 1111 | return; |
| 1112 | } |
| 1113 | for (i=0;i<gen->codeset_num;i++) { |
| 1114 | freeByteM(codeset[i]); |
| 1115 | freeConversion(codeset[i]); |
| 1116 | freeExtdSegment(codeset[i]); |
| 1117 | freeParseInfo(codeset[i]); |
| 1118 | if (codeset[i]->charset_list) { |
| 1119 | Xfree(codeset[i]->charset_list)free((codeset[i]->charset_list)); |
| 1120 | codeset[i]->charset_list = NULL((void*)0); |
| 1121 | } |
| 1122 | Xfree(codeset[i])free((codeset[i])); codeset[i]=NULL((void*)0); |
| 1123 | } |
| 1124 | Xfree(codeset)free((codeset)); gen->codeset_list = NULL((void*)0); |
| 1125 | } |
| 1126 | |
| 1127 | static void |
| 1128 | destroy_SegConv( |
| 1129 | XLCdGenericPart *gen) |
| 1130 | { |
| 1131 | SegConv seg = gen->segment_conv; |
| 1132 | int i; |
| 1133 | if (gen->segment_conv_num == 0) { |
| 1134 | return; |
| 1135 | } |
| 1136 | for (i=0;i<gen->segment_conv_num;i++) { |
| 1137 | if (seg[i].source_encoding) { |
| 1138 | Xfree(seg[i].source_encoding)free((seg[i].source_encoding)); |
| 1139 | seg[i].source_encoding = NULL((void*)0); |
| 1140 | } |
| 1141 | if (seg[i].destination_encoding) { |
| 1142 | Xfree(seg[i].destination_encoding)free((seg[i].destination_encoding)); |
| 1143 | seg[i].destination_encoding = NULL((void*)0); |
| 1144 | } |
| 1145 | if (seg[i].conv) { |
| 1146 | Xfree(seg[i].conv)free((seg[i].conv)); seg[i].conv = NULL((void*)0); |
| 1147 | } |
| 1148 | } |
| 1149 | Xfree(seg)free((seg)); gen->segment_conv = NULL((void*)0); |
| 1150 | } |
| 1151 | |
| 1152 | static void |
| 1153 | destroy_gen( |
| 1154 | XLCd lcd) |
| 1155 | { |
| 1156 | XLCdGenericPart *gen = XLC_GENERIC_PART(lcd)(&(((XLCdGeneric) lcd->core)->gen)); |
| 1157 | destroy_SegConv(gen); |
| 1158 | destroy_CodeSetList(gen); |
| 1159 | if (gen->mb_parse_table) { |
| 1160 | Xfree(gen->mb_parse_table)free((gen->mb_parse_table)); |
| 1161 | gen->mb_parse_table = NULL((void*)0); |
| 1162 | } |
| 1163 | if (gen->mb_parse_list) { |
| 1164 | Xfree(gen->mb_parse_list)free((gen->mb_parse_list)); |
| 1165 | gen->mb_parse_list = NULL((void*)0); |
| 1166 | } |
| 1167 | } |
| 1168 | /* VW/UDC end 95.01.08 */ |
| 1169 | |
| 1170 | static void |
| 1171 | destroy( |
| 1172 | XLCd lcd) |
| 1173 | { |
| 1174 | XLCdPublicMethods superclass = XLC_PUBLIC_METHODS(lcd)(&(((XLCdPublicMethods) lcd->methods)->pub))->superclass; |
| 1175 | |
| 1176 | destroy_gen(lcd); /* ADD 1996.01.08 */ |
| 1177 | if (superclass && superclass->pub.destroy) |
| 1178 | (*superclass->pub.destroy)(lcd); |
| 1179 | } |