@@ -22,6 +22,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2222#include " filedefs.h"
2323
2424#include " execpt.h"
25+ #include " exec.h"
2526#include " handler.h"
2627#include " scriptpt.h"
2728#include " variable.h"
@@ -1081,17 +1082,26 @@ static uint64_t MCWindowsVersionInfoParseVersion(const char *p_string)
10811082static bool add_version_info_entry (void *p_context, MCArrayRef p_array, MCNameRef p_key, MCValueRef p_value)
10821083{
10831084 MCExecPoint ep (NULL , NULL , NULL );
1084-
1085- if (!ep . setvalueref (p_value))
1085+ MCExecContext ctxt (ep);
1086+ if (!ctxt . SetValueRef (p_value))
10861087 return false ;
10871088
10881089 MCWindowsVersionInfo *t_string;
1089-
1090- if (ep . getsvalue () . getstring ()[ep . getsvalue () . getlength () - 1 ] != ' \0 ' )
1091- ep . appendchar (' \0 ' );
1092- ep . nativetoutf16 ();
1093- swap_uint16s ((uint16_t *)ep . getsvalue () . getstring (), ep . getsvalue () . getlength () / 2 );
1094- return MCWindowsVersionInfoAdd ((MCWindowsVersionInfo *)p_context, MCStringGetCString (MCNameGetString (p_key)), true , ep . getsvalue () . getstring (), ep . getsvalue () . getlength (), t_string);
1090+ MCAutoStringRef t_value;
1091+ /* UNCHECKED */ ctxt . CopyAsStringRef (&t_value);
1092+ if (MCStringGetNativeCharAtIndex (*t_value, MCStringGetLength (*t_value) - 1 ) != ' \0 ' )
1093+ {
1094+ MCAutoStringRef t_value_mutable_copy;
1095+ /* UNCHECKED */ MCStringMutableCopy (*t_value, &t_value_mutable_copy);
1096+ MCStringAppendNativeChar (*t_value_mutable_copy, ' \0 ' );
1097+ ctxt . SetValueRef (*t_value_mutable_copy);
1098+ }
1099+ ctxt . NativeToUtf16 ();
1100+ MCAutoStringRef t_new_value;
1101+ /* UNCHECKED */ ctxt . CopyAsStringRef (&t_new_value);
1102+
1103+ swap_uint16s ((uint16_t *)MCStringGetCString (*t_new_value), MCStringGetLength (*t_new_value) / 2 );
1104+ return MCWindowsVersionInfoAdd ((MCWindowsVersionInfo *)p_context, MCStringGetCString (MCNameGetString (p_key)), true , MCStringGetCString (*t_new_value), MCStringGetLength (*t_new_value), t_string);
10951105}
10961106
10971107static bool MCWindowsResourcesAddVersionInfo (MCWindowsResources& self, MCArrayRef p_info)
@@ -1105,10 +1115,18 @@ static bool MCWindowsResourcesAddVersionInfo(MCWindowsResources& self, MCArrayRe
11051115 t_file_version = t_product_version = 0 ;
11061116 if (t_success)
11071117 {
1108- if (ep . fetcharrayelement_cstring (p_info, " FileVersion" ) == ES_NORMAL )
1109- t_file_version = MCWindowsVersionInfoParseVersion (ep . getcstring ());
1110- if (ep . fetcharrayelement_cstring (p_info, " ProductVersion" ) == ES_NORMAL )
1111- t_product_version = MCWindowsVersionInfoParseVersion (ep . getcstring ());
1118+ MCNewAutoNameRef t_key1, t_key2;
1119+ MCNameCreateWithCString (" FileVersion" , &t_key1);
1120+ MCNameCreateWithCString (" ProductVersion" , &t_key2);
1121+
1122+ MCValueRef t_value1, t_value2;
1123+
1124+ if (MCArrayFetchValue (p_info, false , *t_key1, t_value1))
1125+ t_file_version = MCWindowsVersionInfoParseVersion (MCStringGetCString ((MCStringRef)t_value1));
1126+ if (MCArrayFetchValue (p_info, false , *t_key2, t_value2))
1127+ t_product_version = MCWindowsVersionInfoParseVersion (MCStringGetCString ((MCStringRef)t_value2));
1128+ MCValueRelease (t_value1);
1129+ MCValueRelease (t_value2);
11121130 }
11131131
11141132 MCWindowsVersionInfo *t_version_info;
0 commit comments