src/stdlib/SDL_iconv.c
changeset 1513 13a3520a13f9
parent 1510 720f8bb49d7d
child 1519 c99e7a9c9bc9
equal deleted inserted replaced
1512:845b1619c8f6 1513:13a3520a13f9
   381 				Uint8 *p = (Uint8 *)src;
   381 				Uint8 *p = (Uint8 *)src;
   382 				Uint16 W1, W2;
   382 				Uint16 W1, W2;
   383 				if ( srclen < 2 ) {
   383 				if ( srclen < 2 ) {
   384 					return SDL_ICONV_EINVAL;
   384 					return SDL_ICONV_EINVAL;
   385 				}
   385 				}
   386 				W1 = ((Uint32)p[0] << 8) |
   386 				W1 = ((Uint16)p[0] << 8) |
   387 				      (Uint32)p[1];
   387 				      (Uint16)p[1];
   388 				src += 2;
   388 				src += 2;
   389 				srclen -= 2;
   389 				srclen -= 2;
   390 				if ( W1 < 0xD800 || W1 > 0xDFFF ) {
   390 				if ( W1 < 0xD800 || W1 > 0xDFFF ) {
   391 					ch = (Uint32)W1;
   391 					ch = (Uint32)W1;
   392 					break;
   392 					break;
   400 				}
   400 				}
   401 				if ( srclen < 2 ) {
   401 				if ( srclen < 2 ) {
   402 					return SDL_ICONV_EINVAL;
   402 					return SDL_ICONV_EINVAL;
   403 				}
   403 				}
   404 				p = (Uint8 *)src;
   404 				p = (Uint8 *)src;
   405 				W2 = ((Uint32)p[0] << 8) |
   405 				W2 = ((Uint16)p[0] << 8) |
   406 				      (Uint32)p[1];
   406 				      (Uint16)p[1];
   407 				src += 2;
   407 				src += 2;
   408 				srclen -= 2;
   408 				srclen -= 2;
   409 				if ( W2 < 0xDC00 || W2 > 0xDFFF ) {
   409 				if ( W2 < 0xDC00 || W2 > 0xDFFF ) {
   410 					/* Skip illegal sequences
   410 					/* Skip illegal sequences
   411 					return SDL_ICONV_EILSEQ;
   411 					return SDL_ICONV_EILSEQ;
   422 				Uint8 *p = (Uint8 *)src;
   422 				Uint8 *p = (Uint8 *)src;
   423 				Uint16 W1, W2;
   423 				Uint16 W1, W2;
   424 				if ( srclen < 2 ) {
   424 				if ( srclen < 2 ) {
   425 					return SDL_ICONV_EINVAL;
   425 					return SDL_ICONV_EINVAL;
   426 				}
   426 				}
   427 				W1 = ((Uint32)p[1] << 8) |
   427 				W1 = ((Uint16)p[1] << 8) |
   428 				      (Uint32)p[0];
   428 				      (Uint16)p[0];
   429 				src += 2;
   429 				src += 2;
   430 				srclen -= 2;
   430 				srclen -= 2;
   431 				if ( W1 < 0xD800 || W1 > 0xDFFF ) {
   431 				if ( W1 < 0xD800 || W1 > 0xDFFF ) {
   432 					ch = (Uint32)W1;
   432 					ch = (Uint32)W1;
   433 					break;
   433 					break;
   441 				}
   441 				}
   442 				if ( srclen < 2 ) {
   442 				if ( srclen < 2 ) {
   443 					return SDL_ICONV_EINVAL;
   443 					return SDL_ICONV_EINVAL;
   444 				}
   444 				}
   445 				p = (Uint8 *)src;
   445 				p = (Uint8 *)src;
   446 				W2 = ((Uint32)p[1] << 8) |
   446 				W2 = ((Uint16)p[1] << 8) |
   447 				      (Uint32)p[0];
   447 				      (Uint16)p[0];
   448 				src += 2;
   448 				src += 2;
   449 				srclen -= 2;
   449 				srclen -= 2;
   450 				if ( W2 < 0xDC00 || W2 > 0xDFFF ) {
   450 				if ( W2 < 0xDC00 || W2 > 0xDFFF ) {
   451 					/* Skip illegal sequences
   451 					/* Skip illegal sequences
   452 					return SDL_ICONV_EILSEQ;
   452 					return SDL_ICONV_EILSEQ;