svnno****@sourc*****
svnno****@sourc*****
2009年 6月 10日 (水) 01:27:34 JST
Revision: 157 http://svn.sourceforge.jp/view?root=swfed&view=rev&rev=157 Author: yoya Date: 2009-06-10 01:27:34 +0900 (Wed, 10 Jun 2009) Log Message: ----------- union swf_shape_record_t 定義の修正 自己参照構造体の作り方を誤っていた Modified Paths: -------------- trunk/src/swf_shape_record.c trunk/src/swf_shape_record.h -------------- next part -------------- Modified: trunk/src/swf_shape_record.c =================================================================== --- trunk/src/swf_shape_record.c 2009-06-09 16:26:15 UTC (rev 156) +++ trunk/src/swf_shape_record.c 2009-06-09 16:27:34 UTC (rev 157) @@ -9,28 +9,33 @@ swf_shape_record_t *current = shape_record; int limit; for (limit = 1; current ; limit ++) { - shape_record->first_6bits = bitstream_getbits(bs, 6); - first_bit = (shape_record->first_6bits >> 5) & 1; - next_5bits = shape_record->first_6bits & 0x1f; + current->next = NULL; // fail safe + int result = bitstream_getbits(bs, 6); + if (result == -1) { + fprintf(stderr, "swf_shape_record_parse: bitstream_getbits failed at L%d\n", __LINE__); + return 1; + } + shape_record->shape.first_6bits = result; + first_bit = (shape_record->shape.first_6bits >> 5) & 1; + next_5bits = shape_record->shape.first_6bits & 0x1f; bitstream_incrpos(bs, 0, -6); // 6 bit back if ((first_bit == 0) && (next_5bits == 0)) { - swf_shape_record_end_parse(bs, &(current->shape_end)); + swf_shape_record_end_parse(bs, &(current->shape.shape_end)); current->next = NULL; break; } if (first_bit == 0) { - swf_shape_record_setup_parse(bs, &(current->shape_setup), tag, - count); + swf_shape_record_setup_parse(bs, &(current->shape.shape_setup), + tag, count); } else { - swf_shape_record_edge_parse(bs, &(current->shape_edge)); + swf_shape_record_edge_parse(bs, &(current->shape.shape_edge)); } - if (100 <= limit) { + if (10000 <= limit) { // XXX 10000??? current->next = NULL; fprintf(stderr, "swf_shape_record_parse: limit(%d) over\n", limit); return 1; } current->next = calloc(1, sizeof(swf_shape_record_t)); current = current->next; - current->next = NULL; // fail safe } return 0; } @@ -41,16 +46,16 @@ int first_bit, next_5bits; swf_shape_record_t *current = shape_record; while (current) { - first_bit = (shape_record->first_6bits >> 5) & 1; - next_5bits = shape_record->first_6bits & 0x1f; + first_bit = (shape_record->shape.first_6bits >> 5) & 1; + next_5bits = shape_record->shape.first_6bits & 0x1f; if ((first_bit == 0) && (next_5bits == 0)) { - swf_shape_record_end_build(bs, &(current->shape_end)); + swf_shape_record_end_build(bs, &(current->shape.shape_end)); break; } if (first_bit == 0) { - swf_shape_record_setup_build(bs, &(current->shape_setup), tag, - count); + swf_shape_record_setup_build(bs, &(current->shape.shape_setup), + tag, count); } else { - swf_shape_record_edge_build(bs, &(current->shape_edge)); + swf_shape_record_edge_build(bs, &(current->shape.shape_edge)); } current = current->next; } @@ -64,18 +69,20 @@ swf_shape_record_t *current = shape_record; int i; for (i = 0 ; current ; i++) { - first_bit = (shape_record->first_6bits >> 5) & 1; - next_5bits = shape_record->first_6bits & 0x1f; + first_bit = (shape_record->shape.first_6bits >> 5) & 1; + next_5bits = shape_record->shape.first_6bits & 0x1f; print_indent(indent_depth); printf("shape_record [%d]\n", i); if ((first_bit == 0) && (next_5bits == 0)) { - swf_shape_record_end_print(&(current->shape_end), indent_depth); + swf_shape_record_end_print(&(current->shape.shape_end), + indent_depth); break; } if (first_bit == 0) { - swf_shape_record_setup_print(&(current->shape_setup), + swf_shape_record_setup_print(&(current->shape.shape_setup), indent_depth, tag, count); } else { - swf_shape_record_edge_print(&(current->shape_edge), indent_depth); + swf_shape_record_edge_print(&(current->shape.shape_edge), + indent_depth); } current = current->next; } Modified: trunk/src/swf_shape_record.h =================================================================== --- trunk/src/swf_shape_record.h 2009-06-09 16:26:15 UTC (rev 156) +++ trunk/src/swf_shape_record.h 2009-06-09 16:27:34 UTC (rev 157) @@ -13,12 +13,14 @@ #include "swf_shape_record_setup.h" #include "swf_shape_record_edge.h" -typedef union swf_shape_record_ { - unsigned char first_6bits : 6; - swf_shape_record_end_t shape_end; - swf_shape_record_setup_t shape_setup; - swf_shape_record_edge_t shape_edge; - union swf_shape_record_ *next; +typedef struct swf_shape_record_ { + union { + unsigned char first_6bits : 6; + swf_shape_record_end_t shape_end; + swf_shape_record_setup_t shape_setup; + swf_shape_record_edge_t shape_edge; + } shape; + struct swf_shape_record_ *next; } swf_shape_record_t; extern int swf_shape_record_parse(bitstream_t *bs,