wrong iseq conversion flag

parent 3492be40
...@@ -974,7 +974,7 @@ mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, int debug_info, FILE* fp) ...@@ -974,7 +974,7 @@ mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, int debug_info, FILE* fp)
return MRB_DUMP_INVALID_ARGUMENT; return MRB_DUMP_INVALID_ARGUMENT;
} }
result = dump_irep(mrb, irep, debug_info, &bin, &bin_size, FLAG_BYTEORDER_NATIVE); result = dump_irep(mrb, irep, debug_info, &bin, &bin_size, FLAG_BYTEORDER_NONATIVE);
if (result == MRB_DUMP_OK) { if (result == MRB_DUMP_OK) {
if (fwrite(bin, sizeof(bin[0]), bin_size, fp) != bin_size) { if (fwrite(bin, sizeof(bin[0]), bin_size, fp) != bin_size) {
result = MRB_DUMP_WRITE_FAULT; result = MRB_DUMP_WRITE_FAULT;
......
...@@ -507,20 +507,22 @@ read_binary_header(const uint8_t *bin, size_t *bin_size, uint16_t *crc, mrb_bool ...@@ -507,20 +507,22 @@ read_binary_header(const uint8_t *bin, size_t *bin_size, uint16_t *crc, mrb_bool
{ {
const struct rite_binary_header *header = (const struct rite_binary_header *)bin; const struct rite_binary_header *header = (const struct rite_binary_header *)bin;
*byteorder = FALSE; if (byteorder) *byteorder = FALSE;
if (memcmp(header->binary_identify, RITE_BINARY_IDENTIFIER, sizeof(header->binary_identify)) != 0) { if (memcmp(header->binary_identify, RITE_BINARY_IDENTIFIER, sizeof(header->binary_identify)) != 0) {
uint32_t ident = 0; if (byteorder) {
size_t i; uint32_t ident = 0;
size_t i;
for(i=0; i<sizeof(ident); i++) { for(i=0; i<sizeof(ident); i++) {
ident<<=8; ident<<=8;
ident|=RITE_BINARY_IDENTIFIER[i]; ident|=RITE_BINARY_IDENTIFIER[i];
} }
if (ident == *(uint32_t*)header->binary_identify) { if (ident == *(uint32_t*)header->binary_identify) {
*byteorder = TRUE; *byteorder = TRUE;
} }
else { else {
return MRB_DUMP_INVALID_FILE_HEADER; return MRB_DUMP_INVALID_FILE_HEADER;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment