Changeset f94a11f in mainline
- Timestamp:
- 2025-04-15T18:38:48Z (19 hours ago)
- Branches:
- master
- Children:
- 65bf084
- Parents:
- 5d2bdaa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/_bits/mbstate_t.h
r5d2bdaa rf94a11f 37 37 38 38 typedef struct { 39 unsigned short continuation;39 unsigned short state; 40 40 } mbstate_t; 41 41 -
common/stdc/uchar.c
r5d2bdaa rf94a11f 111 111 if (!s) { 112 112 // Equivalent to mbrtoc32(NULL, "", 1, mb). 113 if (mb-> continuation) {113 if (mb->state) { 114 114 _set_ilseq(); 115 115 return UCHAR_ILSEQ; … … 121 121 size_t i = 0; 122 122 123 if (!mb-> continuation) {123 if (!mb->state) { 124 124 /* Clean slate, read initial byte. */ 125 125 … … 152 152 153 153 /* 2 byte encoding 110xxxxx */ 154 mb-> continuation= b ^ 0b0000000011000000;154 mb->state = b ^ 0b0000000011000000; 155 155 156 156 } else if (_is_3_byte(b)) { 157 157 /* 3 byte encoding 1110xxxx */ 158 mb-> continuation= b ^ 0b1111110011100000;158 mb->state = b ^ 0b1111110011100000; 159 159 160 160 } else if (_is_4_byte(b)) { 161 161 /* 4 byte encoding 11110xxx */ 162 mb-> continuation= b ^ 0b1111111100000000;162 mb->state = b ^ 0b1111111100000000; 163 163 } 164 164 } … … 168 168 uint8_t b = s[i]; 169 169 170 if (!_is_continuation(b) || _is_non_shortest(mb-> continuation, b)) {170 if (!_is_continuation(b) || _is_non_shortest(mb->state, b)) { 171 171 _set_ilseq(); 172 172 return UCHAR_ILSEQ; … … 174 174 175 175 /* Top bit becomes zero just before the last byte is shifted in. */ 176 if (!(mb-> continuation& 0x8000)) {177 *c = ((char32_t) mb-> continuation) << 6 | (b & 0x3f);178 mb-> continuation= 0;176 if (!(mb->state & 0x8000)) { 177 *c = ((char32_t) mb->state) << 6 | (b & 0x3f); 178 mb->state = 0; 179 179 return ++i; 180 180 } 181 181 182 mb-> continuation = mb->continuation<< 6 | (b & 0x3f);182 mb->state = mb->state << 6 | (b & 0x3f); 183 183 } 184 184 … … 253 253 if (!s) { 254 254 /* Equivalent to mbrtoc16(NULL, "", 1, mb). */ 255 if (mb-> continuation) {255 if (mb->state) { 256 256 _set_ilseq(); 257 257 return UCHAR_ILSEQ; … … 261 261 } 262 262 263 if ((mb-> continuation& 0xD000) == 0xD000) {263 if ((mb->state & 0xD000) == 0xD000) { 264 264 /* mbstate_t contains the second surrogate character. */ 265 265 /* mbrtoc32() will never set it to such value. */ 266 *c = mb-> continuation;267 mb-> continuation= 0;266 *c = mb->state; 267 mb->state = 0; 268 268 return UCHAR_CONTINUED; 269 269 } … … 276 276 } else { 277 277 /* Encode UTF-16 surrogates. */ 278 mb-> continuation= (c32 & 0x3FF) + 0xDC00;278 mb->state = (c32 & 0x3FF) + 0xDC00; 279 279 *c = (c32 >> 10) + 0xD7C0; 280 280 } … … 298 298 if (!s) { 299 299 // Equivalent to c16rtomb(buf, L’\0’, mb). 300 if (mb-> continuation) {300 if (mb->state) { 301 301 _set_ilseq(); 302 302 return UCHAR_ILSEQ; … … 307 307 308 308 if (!_is_surrogate(c)) { 309 if (mb-> continuation) {309 if (mb->state) { 310 310 _set_ilseq(); 311 311 return UCHAR_ILSEQ; … … 315 315 } 316 316 317 if (!mb-> continuation) {318 mb-> continuation= c;317 if (!mb->state) { 318 mb->state = c; 319 319 return 0; 320 320 } … … 323 323 324 324 /* Decode UTF-16 surrogates. */ 325 if (_is_low_surrogate(mb-> continuation) && _is_high_surrogate(c)) {326 c32 = ((c - 0xD7C0) << 10) | (mb-> continuation- 0xDC00);327 } else if (_is_high_surrogate(mb-> continuation) && _is_low_surrogate(c)) {328 c32 = ((mb-> continuation- 0xD7C0) << 10) | (c - 0xDC00);325 if (_is_low_surrogate(mb->state) && _is_high_surrogate(c)) { 326 c32 = ((c - 0xD7C0) << 10) | (mb->state - 0xDC00); 327 } else if (_is_high_surrogate(mb->state) && _is_low_surrogate(c)) { 328 c32 = ((mb->state - 0xD7C0) << 10) | (c - 0xDC00); 329 329 } else { 330 330 _set_ilseq(); … … 332 332 } 333 333 334 mb-> continuation= 0;334 mb->state = 0; 335 335 return c32rtomb(s, c32, mb); 336 336 } -
common/stdc/wchar.c
r5d2bdaa rf94a11f 46 46 int mbsinit(const mbstate_t *ps) 47 47 { 48 return ps == NULL || ps-> continuation== 0;48 return ps == NULL || ps->state == 0; 49 49 } 50 50
Note:
See TracChangeset
for help on using the changeset viewer.