| 3978 | } |
| 3979 | } |
| 3980 | return 0; |
| 3981 | } |
| 3982 | |
| 3983 | # ifdef _LIBC |
| 3984 | static unsigned int |
| 3985 | internal_function |
| 3986 | find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) |
| 3987 | { |
| 3988 | uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); |
| 3989 | if (nrules == 0) |
| 3990 | { |
| 3991 | if (mbs_len == 1) |
| 3992 | { |
| 3993 | /* No valid character. Match it as a single byte character. */ |
| 3994 | const unsigned char *collseq = (const unsigned char *) |
| 3995 | _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); |
| 3996 | return collseq[mbs[0]]; |
| 3997 | } |
| 3998 | return UINT_MAX; |
| 3999 | } |
| 4000 | else |
| 4001 | { |
| 4002 | int32_t idx; |
| 4003 | const unsigned char *extra = (const unsigned char *) |
| 4004 | _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); |
| 4005 | int32_t extrasize = (const unsigned char *) |
| 4006 | _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra; |
| 4007 | |
| 4008 | for (idx = 0; idx < extrasize;) |
| 4009 | { |
| 4010 | int mbs_cnt, found = 0; |
| 4011 | int32_t elem_mbs_len; |
| 4012 | /* Skip the name of collating element name. */ |
| 4013 | idx = idx + extra[idx] + 1; |
| 4014 | elem_mbs_len = extra[idx++]; |
| 4015 | if (mbs_len == elem_mbs_len) |
| 4016 | { |
| 4017 | for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt) |
| 4018 | if (extra[idx + mbs_cnt] != mbs[mbs_cnt]) |
| 4019 | break; |
| 4020 | if (mbs_cnt == elem_mbs_len) |
| 4021 | /* Found the entry. */ |
| 4022 | found = 1; |
| 4023 | } |
| 4024 | /* Skip the byte sequence of the collating element. */ |
| 4025 | idx += elem_mbs_len; |
| 4026 | /* Adjust for the alignment. */ |
| 4027 | idx = (idx + 3) & ~3; |
| 4028 | /* Skip the collation sequence value. */ |
| 4029 | idx += sizeof (uint32_t); |
| 4030 | /* Skip the wide char sequence of the collating element. */ |
| 4031 | idx = idx + sizeof (uint32_t) * (extra[idx] + 1); |
| 4032 | /* If we found the entry, return the sequence value. */ |
| 4033 | if (found) |
| 4034 | return *(uint32_t *) (extra + idx); |
| 4035 | /* Skip the collation sequence value. */ |
| 4036 | idx += sizeof (uint32_t); |
| 4037 | } |
no outgoing calls
no test coverage detected