Changes in common/stdc/uchar.c [0600976:696b405] in mainline
- File:
-
- 1 edited
-
common/stdc/uchar.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
common/stdc/uchar.c
r0600976 r696b405 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 92 86 size_t mbrtoc32(char32_t *c, const char *s, size_t n, mbstate_t *mb) 93 87 { … … 145 139 146 140 if (_is_2_byte(b)) { 147 /* Reject non-shortest form. */148 if (!(b & 0b00011110)) {149 _set_ilseq();150 return UCHAR_ILSEQ;151 }152 153 141 /* 2 byte encoding 110xxxxx */ 154 142 mb->continuation = b ^ 0b0000000011000000; … … 164 152 } 165 153 166 for (; i < n; i++) {154 while (i < n) { 167 155 /* Read continuation bytes. */ 168 uint8_t b = s[i]; 169 170 if (!_is_continuation(b) || _is_non_shortest(mb->continuation, b)) { 156 157 if (!_is_continuation(s[i])) { 171 158 _set_ilseq(); 172 159 return UCHAR_ILSEQ; … … 175 162 /* Top bit becomes zero just before the last byte is shifted in. */ 176 163 if (!(mb->continuation & 0x8000)) { 177 *c = ((char32_t) mb->continuation) << 6 | ( b& 0x3f);164 *c = ((char32_t) mb->continuation) << 6 | (s[i++] & 0x3f); 178 165 mb->continuation = 0; 179 return ++i;180 } 181 182 mb->continuation = mb->continuation << 6 | ( b& 0x3f);166 return i; 167 } 168 169 mb->continuation = mb->continuation << 6 | (s[i++] & 0x3f); 183 170 } 184 171
Note:
See TracChangeset
for help on using the changeset viewer.
