Changeset 0600976 in mainline for common/stdc/uchar.c
- Timestamp:
- 2025-04-14T11:23:38Z (3 months ago)
- Branches:
- master
- Children:
- 5d2bdaa
- Parents:
- 11782da
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-14 10:57:38)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-14 11:23:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/stdc/uchar.c
r11782da r0600976 84 84 } 85 85 86 static bool _is_non_shortest(unsigned short cont, uint8_t b) 87 { 88 return (cont == 0b1111110000000000 && !(b & 0b00100000)) || 89 (cont == 0b1111111111110000 && !(b & 0b00110000)); 90 } 91 86 92 size_t mbrtoc32(char32_t *c, const char *s, size_t n, mbstate_t *mb) 87 93 { … … 139 145 140 146 if (_is_2_byte(b)) { 147 /* Reject non-shortest form. */ 148 if (!(b & 0b00011110)) { 149 _set_ilseq(); 150 return UCHAR_ILSEQ; 151 } 152 141 153 /* 2 byte encoding 110xxxxx */ 142 154 mb->continuation = b ^ 0b0000000011000000; … … 152 164 } 153 165 154 while (i < n) {166 for (; i < n; i++) { 155 167 /* Read continuation bytes. */ 156 157 if (!_is_continuation(s[i])) { 168 uint8_t b = s[i]; 169 170 if (!_is_continuation(b) || _is_non_shortest(mb->continuation, b)) { 158 171 _set_ilseq(); 159 172 return UCHAR_ILSEQ; … … 162 175 /* Top bit becomes zero just before the last byte is shifted in. */ 163 176 if (!(mb->continuation & 0x8000)) { 164 *c = ((char32_t) mb->continuation) << 6 | ( s[i++]& 0x3f);177 *c = ((char32_t) mb->continuation) << 6 | (b & 0x3f); 165 178 mb->continuation = 0; 166 return i;167 } 168 169 mb->continuation = mb->continuation << 6 | ( s[i++]& 0x3f);179 return ++i; 180 } 181 182 mb->continuation = mb->continuation << 6 | (b & 0x3f); 170 183 } 171 184
Note:
See TracChangeset
for help on using the changeset viewer.