| 498 | | /* So we have a multibyte mapping, i.e., Unicode. */ |
| 499 | | |
| 500 | | /* binary search for the proper description */ |
| 501 | | a = 0; |
| 502 | | b = cs->u_symb - 1; |
| 503 | | c = 0; /* shut up the compiler. */ |
| 504 | | found = 0; |
| 505 | | |
| 506 | | while (!found && b - a > 1) |
| 507 | | { |
| 508 | | c = (a + b) / 2; |
| 509 | | |
| 510 | | if (cs->description[c]->repr == repr) |
| 511 | | { |
| 512 | | found = 1; |
| 513 | | break; |
| 514 | | } |
| 515 | | else if (cs->description[c]->repr < repr) |
| 516 | | a = c; |
| 517 | | else if (cs->description[c]->repr > repr) |
| 518 | | b = c; |
| 519 | | } |
| 520 | | |
| 521 | | if (!found) |
| 522 | | { |
| 523 | | if (cs->description[(c = a)]->repr == repr) |
| 524 | | found = 1; |
| 525 | | else if (cs->description[(c = b)]->repr == repr) |
| 526 | | found = 1; |
| 527 | | } |
| 528 | | |
| 529 | | if (found) |
| 530 | | { |
| 531 | | dprint (5, (debugfile, "repr2descr: %x -> { %x, %s }\n", |
| 532 | | repr, cs->description[c]->repr, cs->description[c]->symbol)); |
| 533 | | return cs->description[c]; |
| 534 | | } |
| 535 | | else |
| 536 | | dprint (5, (debugfile, "Couldn't file a symbol for %x\n", |
| 537 | | repr)); |
| 538 | | |
| 539 | | return NULL; |
| | 497 | key.repr = repr; |
| | 498 | return bsearch (&key, cs->description, cs->u_symb, |
| | 499 | sizeof (CHARDESC *), _cd_compar); |