* 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
- {
- r = (d & 0x1f) << 6;
- d = buf[index];
- if (!d) return 0;
- index++;
+ if ((d & 0xe0) == 0xc0)
+ { // 2 byte (11bit) - 110xxxxx 10xxxxxx
+ r = (d & 0x1f) << 6;
+ 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
- {
- r = (d & 0x0f) << 12;
- d = buf[index];
- if (!d) return 0;
- index++;
+ if ((d & 0xf0) == 0xe0)
+ { // 3 byte (16bit) - 1110xxxx 10xxxxxx 10xxxxxx
+ r = (d & 0x0f) << 12;
+ 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
- {
- r = (d & 0x07) << 18;
- d = buf[index];
- if (!d) return 0;
- index++;
+ if ((d & 0xf8) == 0xf0)
+ { // 4 byte (21bit) - 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+ r = (d & 0x07) << 18;
+ 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
- {
- r = (d & 0x03) << 24;
- d = buf[index];
- if (!d) return 0;
- index++;
+ if ((d & 0xfc) == 0xf8)
+ { // 5 byte (26bit) - 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+ r = (d & 0x03) << 24;
+ 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
- {
- r = (d & 0x01) << 30;
- d = buf[index];
- if (!d) return 0;
- index++;
+ if ((d & 0xfe) == 0xfc)
+ { // 6 byte (31bit) - 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+ r = (d & 0x01) << 30;
+ 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;
}
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);
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
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;
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