+ d = get_16((void *)(*in + 2), type);
+ if ((unsigned)(d-0xdc00) >= 0x400) goto ilseq;
+ c = ((c-0xd7c0)<<10) + (d-0xdc00);
+ }
+ break;
+ case SHIFT_JIS:
+ if (c < 128) break;
+ if (c-0xa1 <= 0xdf-0xa1) {
+ c += 0xff61-0xa1;
+ break;
+ }
+ l = 2;
+ if (*inb < 2) goto starved;
+ d = *((unsigned char *)*in + 1);
+ if (c-129 <= 159-129) c -= 129;
+ else if (c-224 <= 239-224) c -= 193;
+ else goto ilseq;
+ c *= 2;
+ if (d-64 <= 158-64) {
+ if (d==127) goto ilseq;
+ if (d>127) d--;
+ d -= 64;
+ } else if (d-159 <= 252-159) {
+ c++;
+ d -= 159;
+ }
+ c = jis0208[c][d];
+ if (!c) goto ilseq;
+ break;
+ case EUC_JP:
+ if (c < 128) break;
+ l = 2;
+ if (*inb < 2) goto starved;
+ d = *((unsigned char *)*in + 1);
+ if (c==0x8e) {
+ c = d;
+ if (c-0xa1 > 0xdf-0xa1) goto ilseq;
+ c += 0xff61 - 0xa1;
+ break;
+ }
+ c -= 0xa1;
+ d -= 0xa1;
+ if (c >= 84 || d >= 94) goto ilseq;
+ c = jis0208[c][d];
+ if (!c) goto ilseq;
+ break;
+ case ISO2022_JP:
+ if (c >= 128) goto ilseq;
+ if (c == '\033') {
+ l = 3;
+ if (*inb < 3) goto starved;
+ c = *((unsigned char *)*in + 1);
+ d = *((unsigned char *)*in + 2);
+ if (c != '(' && c != '$') goto ilseq;
+ switch (128*(c=='$') + d) {
+ case 'B': scd->state=0; continue;
+ case 'J': scd->state=1; continue;
+ case 'I': scd->state=4; continue;
+ case 128+'@': scd->state=2; continue;
+ case 128+'B': scd->state=3; continue;
+ }
+ goto ilseq;
+ }
+ switch (scd->state) {
+ case 1:
+ if (c=='\\') c = 0xa5;
+ if (c=='~') c = 0x203e;
+ break;
+ case 2:
+ case 3:
+ l = 2;
+ if (*inb < 2) goto starved;
+ d = *((unsigned char *)*in + 1);
+ c -= 0x21;
+ d -= 0x21;
+ if (c >= 84 || d >= 94) goto ilseq;
+ c = jis0208[c][d];
+ if (!c) goto ilseq;
+ break;
+ case 4:
+ if (c-0x60 < 0x1f) goto ilseq;
+ if (c-0x21 < 0x5e) c += 0xff61-0x21;
+ break;
+ }
+ break;
+ case GB2312:
+ if (c < 128) break;
+ if (c < 0xa1) goto ilseq;
+ case GBK:
+ case GB18030:
+ if (c < 128) break;
+ c -= 0x81;
+ if (c >= 126) goto ilseq;
+ l = 2;
+ if (*inb < 2) goto starved;
+ d = *((unsigned char *)*in + 1);
+ if (d < 0xa1 && type == GB2312) goto ilseq;
+ if (d-0x40>=191 || d==127) {
+ if (d-'0'>9 || type != GB18030)
+ goto ilseq;
+ l = 4;
+ if (*inb < 4) goto starved;
+ c = (10*c + d-'0') * 1260;
+ d = *((unsigned char *)*in + 2);
+ if (d-0x81>126) goto ilseq;
+ c += 10*(d-0x81);
+ d = *((unsigned char *)*in + 3);
+ if (d-'0'>9) goto ilseq;
+ c += d-'0';
+ c += 128;
+ for (d=0; d<=c; ) {
+ k = 0;
+ for (int i=0; i<126; i++)
+ for (int j=0; j<190; j++)
+ if (gb18030[i][j]-d <= c-d)
+ k++;
+ d = c+1;
+ c += k;
+ }
+ break;