From: raster Date: Sun, 16 Jan 2011 06:00:12 +0000 (+0000) Subject: in case we access other footer elements in future - align it. X-Git-Tag: submit/trunk/20120815.174732~2153 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=087dd557513bb2a0ad8528308fc3c25018696420;p=profile%2Fivi%2Fevas.git in case we access other footer elements in future - align it. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@56174 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/engines/common/evas_encoding.c b/src/lib/engines/common/evas_encoding.c index c641830..2d2a842 100644 --- a/src/lib/engines/common/evas_encoding.c +++ b/src/lib/engines/common/evas_encoding.c @@ -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 - { - 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; } diff --git a/src/modules/loaders/tga/evas_image_load_tga.c b/src/modules/loaders/tga/evas_image_load_tga.c index 4eae600..93d63c4 100644 --- a/src/modules/loaders/tga/evas_image_load_tga.c +++ b/src/modules/loaders/tga/evas_image_load_tga.c @@ -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