@@ -332,14 +332,14 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
332332 return IO_NORMAL;
333333}
334334
335- IO_stat MCBlock::save (IO_handle stream, uint4 p_part)
335+ IO_stat MCBlock::save (IO_handle stream, uint4 p_part, uint32_t p_version )
336336{
337337 IO_stat stat;
338338
339339 // MW-2012-03-04: [[ StackFile5500 ]] If the block has metadata and 5.5 stackfile
340340 // format has been requested then this is an extended block.
341341 bool t_is_ext;
342- if (MCstackfileversion >= 5500 && getflag (F_HAS_METADATA))
342+ if (p_version >= 5500 && getflag (F_HAS_METADATA))
343343 t_is_ext = true ;
344344 else
345345 t_is_ext = false ;
@@ -352,7 +352,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
352352 // MW-2012-03-04: [[ StackFile5500 ]] If this is an extended block then write out
353353 // the length of the attrs.
354354 if (t_is_ext)
355- if ((stat = IO_write_uint2or4 (measureattrs (), stream)) != IO_NORMAL)
355+ if ((stat = IO_write_uint2or4 (measureattrs (p_version ), stream)) != IO_NORMAL)
356356 return stat;
357357
358358 uint4 oldflags = flags;
@@ -368,7 +368,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
368368
369369 // The "has unicode" flag depends on whether the paragraph is native
370370 bool t_is_unicode;
371- if (MCstackfileversion < 7000 && MCStringIsNative (parent->GetInternalStringRef ()))
371+ if (p_version < 7000 && MCStringIsNative (parent->GetInternalStringRef ()))
372372 {
373373 t_is_unicode = false ;
374374 flags &= ~F_HAS_UNICODE;
@@ -380,7 +380,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
380380 }
381381
382382 // SN-2014-12-04: [[ Bug 14149 ]] Add the F_HAS_TAB flag, for legacy saving
383- if (MCstackfileversion < 7000 )
383+ if (p_version < 7000 )
384384 {
385385 if (segment && segment != segment -> next ())
386386 flags |= F_HAS_TAB;
@@ -437,11 +437,11 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
437437 // strings.
438438 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
439439 if (flags & F_HAS_LINK)
440- if ((stat = IO_write_stringref_new (atts->linktext , stream, MCstackfileversion >= 7000 )) != IO_NORMAL)
440+ if ((stat = IO_write_stringref_new (atts->linktext , stream, p_version >= 7000 )) != IO_NORMAL)
441441 return stat;
442442 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
443443 if (flags & F_HAS_IMAGE)
444- if ((stat = IO_write_stringref_new (atts->imagesource , stream, MCstackfileversion >= 7000 )) != IO_NORMAL)
444+ if ((stat = IO_write_stringref_new (atts->imagesource , stream, p_version >= 7000 )) != IO_NORMAL)
445445 return stat;
446446
447447 // MW-2012-03-04: [[ StackFile5500 ]] If this is an extended block then emit the
@@ -450,7 +450,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
450450 {
451451 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
452452 if (flags & F_HAS_METADATA)
453- if ((stat = IO_write_stringref_new (atts -> metadata, stream, MCstackfileversion >= 7000 )) != IO_NORMAL)
453+ if ((stat = IO_write_stringref_new (atts -> metadata, stream, p_version >= 7000 )) != IO_NORMAL)
454454 return stat;
455455 }
456456
@@ -2245,13 +2245,13 @@ void MCBlock::importattrs(const MCFieldCharacterStyle& p_style)
22452245}
22462246
22472247// SN-2014-10-31: [[ Bug 13879 ]] Update the way the string is measured.
2248- uint32_t measure_stringref (MCStringRef p_string)
2248+ uint32_t measure_stringref (MCStringRef p_string, uint32_t p_version )
22492249{
22502250 MCStringEncoding t_encoding;
22512251 uint32_t t_additional_bytes = 0 ;
22522252
22532253
2254- if (MCstackfileversion < 7000 )
2254+ if (p_version < 7000 )
22552255 t_encoding = kMCStringEncodingNative ;
22562256 else
22572257 t_encoding = kMCStringEncodingUTF8 ;
@@ -2262,7 +2262,7 @@ uint32_t measure_stringref(MCStringRef p_string)
22622262 uint32_t t_length;
22632263 t_length = MCDataGetLength (*t_data);
22642264
2265- if (MCstackfileversion < 7000 )
2265+ if (p_version < 7000 )
22662266 {
22672267 // Full string is written in 5.5 format:
22682268 // - length is written as a uint2
@@ -2283,14 +2283,14 @@ uint32_t measure_stringref(MCStringRef p_string)
22832283
22842284// MW-2012-03-04: [[ StackFile5500 ]] Utility routine for computing the length of
22852285// a nameref when serialized to disk.
2286- uint32_t measure_nameref (MCNameRef p_name)
2286+ uint32_t measure_nameref (MCNameRef p_name, uint32_t p_version )
22872287{
2288- return measure_stringref (MCNameGetString (p_name));
2288+ return measure_stringref (MCNameGetString (p_name), p_version );
22892289}
22902290
22912291// MW-2012-03-04: [[ StackFile5500 ]] Compute the number of bytes the attributes will
22922292// take up when serialized.
2293- uint32_t MCBlock::measureattrs (void )
2293+ uint32_t MCBlock::measureattrs (uint32_t p_version )
22942294{
22952295 // If there are no attrs, then the size is 0.
22962296 if (!hasatts ())
@@ -2315,11 +2315,11 @@ uint32_t MCBlock::measureattrs(void)
23152315 // MW-2012-05-04: [[ Values ]] linkText / imageSource / metaData are now uniqued
23162316 // strings.
23172317 if ((flags & F_HAS_LINK) != 0 )
2318- t_size += measure_stringref (atts -> linktext);
2318+ t_size += measure_stringref (atts -> linktext, p_version );
23192319 if ((flags & F_HAS_IMAGE) != 0 )
2320- t_size += measure_stringref (atts -> imagesource);
2320+ t_size += measure_stringref (atts -> imagesource, p_version );
23212321 if ((flags & F_HAS_METADATA) != 0 )
2322- t_size += measure_stringref ((MCStringRef)atts -> metadata);
2322+ t_size += measure_stringref ((MCStringRef)atts -> metadata, p_version );
23232323
23242324 return t_size;
23252325}
0 commit comments