* The do_case_conv() looks at the mapping tables and returns found * bytes if any. If not found, the input bytes are returned. The function * always terminate the return bytes with a null character assuming that * there are plenty of room to do so. * * The case conversions are simple case conversions mapping a character to * another character as specified in the Unicode data. The byte size o
| 455 | * the terminating null byte. |
| 456 | */ |
| 457 | static size_t |
| 458 | do_case_conv(int uv, uchar_t *u8s, uchar_t *s, int sz, boolean_t is_it_toupper) |
| 459 | { |
| 460 | size_t i; |
| 461 | uint16_t b1 = 0; |
| 462 | uint16_t b2 = 0; |
| 463 | uint16_t b3 = 0; |
| 464 | uint16_t b3_tbl; |
| 465 | uint16_t b3_base; |
| 466 | uint16_t b4 = 0; |
| 467 | size_t start_id; |
| 468 | size_t end_id; |
| 469 | |
| 470 | /* |
| 471 | * At this point, the only possible values for sz are 2, 3, and 4. |
| 472 | * The u8s should point to a vector that is well beyond the size of |
| 473 | * 5 bytes. |
| 474 | */ |
| 475 | if (sz == 2) { |
| 476 | b3 = u8s[0] = s[0]; |
| 477 | b4 = u8s[1] = s[1]; |
| 478 | } else if (sz == 3) { |
| 479 | b2 = u8s[0] = s[0]; |
| 480 | b3 = u8s[1] = s[1]; |
| 481 | b4 = u8s[2] = s[2]; |
| 482 | } else if (sz == 4) { |
| 483 | b1 = u8s[0] = s[0]; |
| 484 | b2 = u8s[1] = s[1]; |
| 485 | b3 = u8s[2] = s[2]; |
| 486 | b4 = u8s[3] = s[3]; |
| 487 | } else { |
| 488 | /* This is not possible but just in case as a fallback. */ |
| 489 | if (is_it_toupper) |
| 490 | *u8s = U8_ASCII_TOUPPER(*s); |
| 491 | else |
| 492 | *u8s = U8_ASCII_TOLOWER(*s); |
| 493 | u8s[1] = '\0'; |
| 494 | |
| 495 | return (1); |
| 496 | } |
| 497 | u8s[sz] = '\0'; |
| 498 | |
| 499 | /* |
| 500 | * Let's find out if we have a corresponding character. |
| 501 | */ |
| 502 | b1 = u8_common_b1_tbl[uv][b1]; |
| 503 | if (b1 == U8_TBL_ELEMENT_NOT_DEF) |
| 504 | return ((size_t)sz); |
| 505 | |
| 506 | b2 = u8_case_common_b2_tbl[uv][b1][b2]; |
| 507 | if (b2 == U8_TBL_ELEMENT_NOT_DEF) |
| 508 | return ((size_t)sz); |
| 509 | |
| 510 | if (is_it_toupper) { |
| 511 | b3_tbl = u8_toupper_b3_tbl[uv][b2][b3].tbl_id; |
| 512 | if (b3_tbl == U8_TBL_ELEMENT_NOT_DEF) |
| 513 | return ((size_t)sz); |
| 514 |
no outgoing calls
no test coverage detected