From: Adrian M. <ame...@hm...> - 2004-04-22 03:01:12
|
This is sent from my primary (more or less spam-free... knock on wood)=20 address. Sorry about the mailer splitting some of the lines. --Adrian --- files8x.c.bak 2003-08-27 02:30:44.000000000 -0700 +++ files8x.c 2003-11-27 10:38:33.000000000 -0800 @@ -194,6 +194,8 @@ int i; int ti83p_flag =3D 0; uint8_t name_length =3D 8; // ti85/86 only + uint16_t data_size; + uint8_t test_space; char signature[9]; if (!tifiles_is_a_ti_file(filename)) @@ -213,18 +215,45 @@ return ERR_INVALID_FILE; fskip(f, 3); fread_n_chars(f, 42, content->comment); - fread_word(f, NULL); + fread_word(f, &data_size); // search for the number of entries by parsing the whole file offset =3D ftell(f); for (i =3D 0;; i++) { + int current_offset =3D (int)ftell(f); + /* We are done finding entries once we reach the end of the data=20 segment + * as defined in the header. This works better than magic numbers, = as + * as there exist files in the wild with incorrect magic numbers tha= t + * transmit correctly with TI's software and with this code. + */ + //printf("current_offset: %x, offset + data_size: %x\n", + // current_offset, (uint16_t) offset + data_size); + if (current_offset >=3D offset + data_size) + break; + fread_word(f, &tmp); if (tmp =3D=3D 0x0D) ti83p_flag =3D !0; // true TI83+ file (2 extra bytes) - if ((tmp !=3D 0x0B) && (tmp !=3D 0x0C) && (tmp !=3D 0x0D)) - break; + //if ((tmp !=3D 0x0B) && (tmp !=3D 0x0C) && (tmp !=3D 0x0D)) + // break; if (is_ti8586(content->calc_type)) - fskip(f, 12); + { + /* name may follow one of three conventions: padded with zeroes + * (most correct, generated by TI's software), padded with null=20 bytes, + * or unpadded. TI's software accepts all three, so we should too. + */ + fskip(f, 3); + fread_byte(f, &name_length); + fskip(f, name_length); + + fread_byte(f, &test_space); + fskip (f, -1); + + //printf("test_space: %x at %x\n", test_space, (int)ftell(f)); + + if (test_space =3D=3D '\0' || test_space =3D=3D ' ') // skip padd= ing if=20 padded + fskip(f, 8 - name_length); + } else if (content->calc_type =3D=3D CALC_TI83P) fskip(f, 13); else @@ -254,7 +283,16 @@ tixx_translate_varname(entry->name, entry->trans, entry->type, content->calc_type); if (is_ti8586(content->calc_type)) - fskip(f, 8 - name_length); + { + /* Again, compatibility with padded and unpadded files + */ + fread_byte(f, &test_space); + fskip (f, -1); + + if (test_space =3D=3D '\0' || test_space =3D=3D ' ') // skip padd= ing if=20 padded + fskip(f, 8 - name_length); + } + if (ti83p_flag) { entry->attr =3D (fgetc(f) =3D=3D 0x80 ? ATTRB_ARCHIVED : ATTRB_NO= NE); fgetc(f); @@ -639,7 +677,7 @@ fwrite_word(f, content->data_length4); fwrite(content->data_part4, 1, content->data_length4, f); } - // checksum =3D sum of all bytes in bachup headers and data num_entrie= s + // checksum =3D sum of all bytes in backup headers and data num_entrie= s sum =3D 0; sum +=3D 9; sum +=3D --- Romain Li=E9vin <ro...@us...> wrote: > > Hi, > > > > could you send to me your patch in unified diff > format (diff > > -Naur) ? > > > > You can mail me at <ro...@ti...> or > til...@li.... > > > > It will be easier to communicate by this way rather > than by > > the BugTracker. > > > > thx, roms. |