Skip to content

Commit 72f214d

Browse files
committed
[[ UnicodeFileFormat ]] Further updates to unicodify file format for 7.0.
1 parent f59ff0e commit 72f214d

31 files changed

+638
-339
lines changed

engine/src/aclip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,5 +1025,5 @@ IO_stat MCAudioClip::load(IO_handle stream, uint32_t version)
10251025
if (flags & F_LOUDNESS)
10261026
if ((stat = IO_read_uint2(&loudness, stream)) != IO_NORMAL)
10271027
return stat;
1028-
return loadpropsets(stream);
1028+
return loadpropsets(stream, version);
10291029
}

engine/src/block.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
204204
// MW-2013-11-19: [[ UnicodeFileFormat ]] The storage of this is ignored,
205205
// so is legacy,
206206
char *colorname;
207-
if ((stat = IO_read_string_legacy(colorname, stream)) != IO_NORMAL)
207+
if ((stat = IO_read_cstring_legacy(colorname, stream, 2)) != IO_NORMAL)
208208
return stat;
209209
delete colorname;
210210
flags &= ~F_HAS_COLOR_NAME;
@@ -222,7 +222,7 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
222222
// MW-2013-11-19: [[ UnicodeFileFormat ]] The storage of this is ignored,
223223
// so is legacy,
224224
char *backcolorname;
225-
if ((stat = IO_read_string_legacy(backcolorname, stream)) != IO_NORMAL)
225+
if ((stat = IO_read_cstring_legacy(backcolorname, stream, 2)) != IO_NORMAL)
226226
return stat;
227227
delete backcolorname;
228228
flags &= ~F_HAS_BACK_COLOR_NAME;

engine/src/button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4502,7 +4502,7 @@ IO_stat MCButton::load(IO_handle stream, uint32_t version)
45024502
flags |= F_OPAQUE | F_TRAVERSAL_ON;
45034503
}
45044504

4505-
if ((stat = loadpropsets(stream)) != IO_NORMAL)
4505+
if ((stat = loadpropsets(stream, version)) != IO_NORMAL)
45064506
return stat;
45074507

45084508
while (True)

engine/src/card.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,7 @@ IO_stat MCCard::load(IO_handle stream, uint32_t version)
32933293
//---- 2.7+
32943294

32953295
rect.y = 0; // in case saved on mac with editMenus false
3296-
if ((stat = loadpropsets(stream)) != IO_NORMAL)
3296+
if ((stat = loadpropsets(stream, version)) != IO_NORMAL)
32973297
return stat;
32983298
while (True)
32993299
{

engine/src/cdata.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ IO_stat MCCdata::load(IO_handle stream, MCObject *parent, uint32_t version)
100100
{
101101
if (id & COMPACT_PARAGRAPHS)
102102
{
103+
// MW-2013-11-19: [[ UnicodeFileFormat ]] This flag is never set by newer engines
104+
// so is just legacy.
103105
char *string;
104-
if ((stat = IO_read_string(string, stream, sizeof(uint1))) != IO_NORMAL)
106+
if ((stat = IO_read_cstring_legacy(string, stream, sizeof(uint1))) != IO_NORMAL)
105107
return stat;
106108
data = string;
107109
}
@@ -164,7 +166,11 @@ IO_stat MCCdata::save(IO_handle stream, Object_type type, uint4 p_part)
164166
}
165167
else
166168
if (id & COMPACT_PARAGRAPHS)
167-
return IO_write_string((char *)data, stream, sizeof(uint1));
169+
{
170+
// MW-2013-11-19: [[ UnicodeFileFormat ]] This flag is never set by newer engines
171+
// so is just legacy. (Indeed, this codepath should never be hit!).
172+
return IO_write_cstring_legacy((char *)data, stream, sizeof(uint1));
173+
}
168174
else
169175
{
170176
MCParagraph *tptr = (MCParagraph *)data;

engine/src/cpalette.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,5 @@ IO_stat MCColors::load(IO_handle stream, uint32_t version)
313313
IO_stat stat;
314314
if ((stat = MCObject::load(stream, version)) != IO_NORMAL)
315315
return stat;
316-
return loadpropsets(stream);
316+
return loadpropsets(stream, version);
317317
}

engine/src/dispatch.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,12 @@ IO_stat MCDispatch::readstartupstack(IO_handle stream, MCStack*& r_stack)
527527
uint32_t version;
528528
uint1 charset, type;
529529
char *newsf;
530+
531+
// MW-2013-11-19: [[ UnicodeFileFormat ]] newsf is no longer used.
530532
if (readheader(stream, version) != IO_NORMAL
531533
|| IO_read_uint1(&charset, stream) != IO_NORMAL
532534
|| IO_read_uint1(&type, stream) != IO_NORMAL
533-
|| IO_read_string(newsf, stream) != IO_NORMAL)
535+
|| IO_read_cstring_legacy(newsf, stream, 2) != IO_NORMAL)
534536
return IO_ERROR;
535537

536538
// MW-2008-10-20: [[ ParentScripts ]] Set the boolean flag that tells us whether
@@ -618,12 +620,13 @@ IO_stat MCDispatch::doreadfile(MCStringRef p_openpath, MCStringRef p_name, IO_ha
618620
// MW-2008-10-20: [[ ParentScripts ]] Set the boolean flag that tells us whether
619621
// parentscript resolution is required to false.
620622
s_loaded_parent_script_reference = false;
621-
623+
624+
// MW-2013-11-19: [[ UnicodeFileFormat ]] newsf is no longer used.
622625
uint1 charset, type;
623626
char *newsf;
624627
if (IO_read_uint1(&charset, stream) != IO_NORMAL
625628
|| IO_read_uint1(&type, stream) != IO_NORMAL
626-
|| IO_read_string(newsf, stream) != IO_NORMAL)
629+
|| IO_read_cstring_legacy(newsf, stream, 2) != IO_NORMAL)
627630
{
628631
MCresult->sets("stack is corrupted, check for ~ backup file");
629632
return IO_ERROR;
@@ -641,10 +644,12 @@ IO_stat MCDispatch::doreadfile(MCStringRef p_openpath, MCStringRef p_name, IO_ha
641644

642645
if (MCModeCanLoadHome() && type == OT_HOME)
643646
{
647+
// MW-2013-11-19: [[ UnicodeFileFormat ]] These strings are never written out, so
648+
// legacy.
644649
char *lstring = NULL;
645650
char *cstring = NULL;
646-
IO_read_string(lstring, stream);
647-
IO_read_string(cstring, stream);
651+
IO_read_cstring_legacy(lstring, stream, 2);
652+
IO_read_cstring_legacy(cstring, stream, 2);
648653
delete lstring;
649654
delete cstring;
650655
}
@@ -941,9 +946,11 @@ IO_stat MCDispatch::dosavestack(MCStack *sptr, const MCStringRef p_fname)
941946
cleanup(stream, *t_linkname, *t_backup);
942947
return IO_ERROR;
943948
}
944-
949+
950+
// MW-2013-11-19: [[ UnicodeFileFormat ]] Writing out for backwards-compatibility,
951+
// so legacy.
945952
if (IO_write_uint1(OT_NOTHOME, stream) != IO_NORMAL
946-
|| IO_write_string(NULL, stream) != IO_NORMAL)
953+
|| IO_write_cstring_legacy(NULL, stream, 2) != IO_NORMAL)
947954
{ // was stackfiles
948955
MCresult->sets(errstring);
949956
cleanup(stream, *t_linkname, *t_backup);

engine/src/eps.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ IO_stat MCEPS::save(IO_handle stream, uint4 p_part, bool p_force_ext)
447447
return stat;
448448
if ((stat = IO_write(postscript, sizeof(char), size, stream)) != IO_NORMAL)
449449
return stat;
450-
if ((stat = IO_write_string(prolog, stream)) != IO_NORMAL)
450+
// MW-2013-11-19: [[ UnicodeFileFormat ]] EPS is always ASCII so legacy.
451+
if ((stat = IO_write_cstring_legacy(prolog, stream, 2)) != IO_NORMAL)
451452
return stat;
452453
if ((stat = IO_write_int4(MCU_r8toi4(xscale), stream)) != IO_NORMAL)
453454
return stat;
@@ -574,7 +575,8 @@ IO_stat MCEPS::load(IO_handle stream, uint32_t version)
574575
if ((stat = IO_read(postscript, size, stream)) != IO_NORMAL)
575576
return stat;
576577
postscript[size] = '\0';
577-
if ((stat = IO_read_string(prolog, stream)) != IO_NORMAL)
578+
// MW-2013-11-19: [[ UnicodeFileFormat ]] EPS is always ASCII so legacy.
579+
if ((stat = IO_read_cstring_legacy(prolog, stream, 2)) != IO_NORMAL)
578580
return stat;
579581
int4 i;
580582
if ((stat = IO_read_int4(&i, stream)) != IO_NORMAL)
@@ -619,7 +621,7 @@ IO_stat MCEPS::load(IO_handle stream, uint32_t version)
619621
return stat;
620622
}
621623
}
622-
return loadpropsets(stream);
624+
return loadpropsets(stream, version);
623625
}
624626

625627
void MCEPS::setextents()

engine/src/exec-array.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,11 @@ void MCArraysEvalArrayEncode(MCExecContext& ctxt, MCArrayRef p_array, MCStringRe
314314
if (t_success)
315315
if (t_stream -> WriteU8(kMCEncodedValueTypeArray) != IO_NORMAL)
316316
t_success = false;
317-
317+
318+
// MW-2013-11-20: [[ UnicodeFileFormat ]] ArrayEncode / Decode use version 2.7
319+
// pickling.
318320
if (t_success)
319-
if (MCArraySaveToStream(p_array, false, *t_stream) != IO_NORMAL)
321+
if (MCArraySaveToStream(p_array, false, *t_stream, 2700) != IO_NORMAL)
320322
t_success = false;
321323

322324
if (t_success)
@@ -377,8 +379,10 @@ void MCArraysEvalArrayDecode(MCExecContext& ctxt, MCStringRef p_encoding, MCArra
377379
if (t_success)
378380
t_success = MCArrayCreateMutable(t_array);
379381

382+
// MW-2013-11-20: [[ UnicodeFileFormat ]] ArrayEncode / Decode use version 2.7
383+
// pickling.
380384
if (t_success)
381-
if (MCArrayLoadFromStream(t_array, *t_stream) != IO_NORMAL)
385+
if (MCArrayLoadFromStream(t_array, *t_stream, 2700) != IO_NORMAL)
382386
t_success = false;
383387

384388
delete t_stream;

engine/src/field.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3084,7 +3084,7 @@ IO_stat MCField::load(IO_handle stream, uint32_t version)
30843084
}
30853085
if (flags & F_VGRID)
30863086
flags |= F_DONT_WRAP;
3087-
if ((stat = loadpropsets(stream)) != IO_NORMAL)
3087+
if ((stat = loadpropsets(stream, version)) != IO_NORMAL)
30883088
return stat;
30893089
while (True)
30903090
{

0 commit comments

Comments
 (0)