forked from enlightenment/efl
in case we access other footer elements in future - align it.
SVN revision: 56174
This commit is contained in:
parent
2ba6051649
commit
e7bd084847
|
@ -11,106 +11,80 @@ evas_common_encoding_utf8_get_next(const char *buf, int *iindex)
|
|||
* Returns 0 to indicate there is no next char
|
||||
*/
|
||||
#if 1
|
||||
int index = *iindex, r;
|
||||
int index = *iindex;
|
||||
Eina_Unicode r;
|
||||
unsigned char d;
|
||||
|
||||
/* if this char is the null terminator, exit */
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
|
||||
if ((d & 0x80) == 0) // 1 byte ascii (7bit) - 0xxxxxxx
|
||||
{
|
||||
if ((d & 0x80) == 0)
|
||||
{ // 1 byte (7bit) - 0xxxxxxx
|
||||
*iindex = index;
|
||||
return d;
|
||||
}
|
||||
if ((d & 0xe0) == 0xc0) // 2 byte utf8 (11bit) - 110xxxxx 10xxxxxx
|
||||
{
|
||||
if ((d & 0xe0) == 0xc0)
|
||||
{ // 2 byte (11bit) - 110xxxxx 10xxxxxx
|
||||
r = (d & 0x1f) << 6;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f);
|
||||
if (!r) return 0;
|
||||
*iindex = index;
|
||||
return r;
|
||||
}
|
||||
if ((d & 0xf0) == 0xe0) // 3 byte utf8 (16bit) - 1110xxxx 10xxxxxx 10xxxxxx
|
||||
{
|
||||
if ((d & 0xf0) == 0xe0)
|
||||
{ // 3 byte (16bit) - 1110xxxx 10xxxxxx 10xxxxxx
|
||||
r = (d & 0x0f) << 12;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 6;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f);
|
||||
if (!r) return 0;
|
||||
*iindex = index;
|
||||
return r;
|
||||
}
|
||||
if ((d & 0xf8) == 0xf0) // 4 byte utf8 (21bit) - 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
{
|
||||
if ((d & 0xf8) == 0xf0)
|
||||
{ // 4 byte (21bit) - 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
r = (d & 0x07) << 18;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 12;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 6;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f);
|
||||
if (!r) return 0;
|
||||
*iindex = index;
|
||||
return r;
|
||||
}
|
||||
if ((d & 0xfc) == 0xf8) // 5 byte utf8 (26bit) - 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
{
|
||||
if ((d & 0xfc) == 0xf8)
|
||||
{ // 5 byte (26bit) - 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
r = (d & 0x03) << 24;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 18;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 12;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 6;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f);
|
||||
if (!r) return 0;
|
||||
*iindex = index;
|
||||
return r;
|
||||
}
|
||||
if ((d & 0xfe) == 0xfc) // 6 byte utf8 (31bit) - 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
{
|
||||
if ((d & 0xfe) == 0xfc)
|
||||
{ // 6 byte (31bit) - 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
r = (d & 0x01) << 30;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 24;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 18;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 12;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f) << 6;
|
||||
d = buf[index];
|
||||
if (!d) return 0;
|
||||
index++;
|
||||
if ((d = buf[index++]) == 0) return 0;
|
||||
r |= (d & 0x3f);
|
||||
if (!r) return 0;
|
||||
*iindex = index;
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -73,9 +73,8 @@ evas_image_load_file_head_tga(Image_Entry *ie, const char *file, const char *key
|
|||
unsigned char *seg = MAP_FAILED, *filedata;
|
||||
struct stat ss;
|
||||
tga_header *header;
|
||||
tga_footer *footer;
|
||||
tga_footer *footer, tfooter;
|
||||
char hasa = 0, footer_present = 0, vinverted = 0;
|
||||
// char rle = 0;
|
||||
int w = 0, h = 0, bpp;
|
||||
|
||||
fd = open(file, O_RDONLY);
|
||||
|
@ -94,7 +93,8 @@ evas_image_load_file_head_tga(Image_Entry *ie, const char *file, const char *key
|
|||
header = (tga_header *)filedata;
|
||||
// no unaligned data accessed, so ok
|
||||
footer = (tga_footer *)(filedata + (ss.st_size - sizeof(tga_footer)));
|
||||
if (!memcmp(footer->signature, TGA_SIGNATURE, sizeof(footer->signature)))
|
||||
memcpy(&tfooter, footer, sizeof(tga_footer));
|
||||
if (!memcmp(tfooter.signature, TGA_SIGNATURE, sizeof(tfooter.signature)))
|
||||
{
|
||||
// footer is there and matches. this is a tga file - any problems now
|
||||
// are a corrupt file
|
||||
|
@ -149,7 +149,7 @@ evas_image_load_file_data_tga(Image_Entry *ie, const char *file, const char *key
|
|||
unsigned char *seg = MAP_FAILED, *filedata;
|
||||
struct stat ss;
|
||||
tga_header *header;
|
||||
tga_footer *footer;
|
||||
tga_footer *footer, tfooter;
|
||||
char hasa = 0, footer_present = 0, vinverted = 0, rle = 0;
|
||||
int w = 0, h = 0, x, y, bpp;
|
||||
unsigned int *surface, *dataptr;
|
||||
|
@ -172,7 +172,8 @@ evas_image_load_file_data_tga(Image_Entry *ie, const char *file, const char *key
|
|||
header = (tga_header *)filedata;
|
||||
// no unaligned data accessed, so ok
|
||||
footer = (tga_footer *)(filedata + (ss.st_size - sizeof(tga_footer)));
|
||||
if (!memcmp(footer->signature, TGA_SIGNATURE, sizeof(footer->signature)))
|
||||
memcpy(&tfooter, footer, sizeof(tga_footer));
|
||||
if (!memcmp(tfooter.signature, TGA_SIGNATURE, sizeof(tfooter.signature)))
|
||||
{
|
||||
// footer is there and matches. this is a tga file - any problems now
|
||||
// are a corrupt file
|
||||
|
|
Loading…
Reference in New Issue