Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Commit 469ee88

Browse files
committed
Some more improvements after Mark's feedback livecode#5
1 parent 07d0c0c commit 469ee88

5 files changed

Lines changed: 40 additions & 47 deletions

File tree

engine/src/dispatch.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -847,20 +847,14 @@ IO_stat MCDispatch::dosavestack(MCStack *sptr, const MCStringRef p_fname)
847847
MCresult -> sets("stack does not have filename");
848848
return IO_ERROR;
849849
}
850-
851-
if (*t_linkname == NULL)
852-
{
853-
MCresult->sets("can't open stack file, bad path");
854-
return IO_ERROR;
855-
}
856850

857851
if (MCS_noperm(*t_linkname))
858852
{
859853
MCresult->sets("can't open stack file, no permission");
860854
return IO_ERROR;
861855
}
862856
char *oldfiletype = MCfiletype;
863-
MCfiletype = strdup(MCStringGetCString(MCstackfiletype));
857+
MCfiletype = (char *) MCStringGetCString(MCstackfiletype);
864858

865859
MCAutoStringRef t_backup;
866860
/* UNCHECKED */ MCStringFormat(&t_backup, "%s~", MCStringGetCString(*t_linkname));
@@ -935,13 +929,7 @@ IO_stat MCDispatch::dosavestack(MCStack *sptr, const MCStringRef p_fname)
935929
MCS_umask(oldmask);
936930

937931
MCS_chmod(*t_linkname, newmask);
938-
/*
939-
if (sptr->getfilename() != NULL && !strequal(linkname, sptr->getfilename()))
940-
MCS_copyresourcefork(sptr->getfilename(), linkname);
941-
else if (sptr -> getfilename() != NULL)
942-
MCS_copyresourcefork(backup, linkname);
943-
*/
944-
932+
945933
MCAutoStringRef t_filename;
946934
if (sptr -> getfilename() != nil)
947935
/* UNCHECKED */ MCStringCreateWithCString(sptr->getfilename(), &t_filename);

engine/src/opensslsocket.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,9 +1781,13 @@ Boolean MCSocket::initsslcontext()
17811781
/* UNCHECKED */ MCStringCreateWithCString(certs[i].clone(), &t_oldcertpath_string);
17821782
#ifdef _MACOSX
17831783
MCAutoStringRef t_certpath_string_tmp, t_certpath;
1784+
char *utf8str = NULL;
17841785
if (MCS_resolvepath(*t_oldcertpath_string, &t_certpath_string_tmp))
1785-
path2utf(*t_certpath_string_tmp, &t_certpath);
1786+
{
1787+
/* UNCHECKED */ MCStringConvertToUTF8String(*t_certpath_string_tmp, utf8str);
1788+
}
17861789
#else
1790+
17871791
MCAutoStringRef t_certpath;
17881792
MCS_resolvepath(*t_oldcertpath_string, &t_certpath);
17891793
#endif

engine/src/osxans.mm

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -200,36 +200,33 @@ static void resolve_alias(NSString *p_path, NSString *&r_path_resolved)
200200
char *t_path;
201201
t_path = nil;
202202
MCAutoStringRef t_path_str;
203+
if (strrchr(p_path, '/') != nil)
204+
{
205+
MCAutoStringRef t_original_path;
206+
/* UNCHECKED */ MCStringCreateWithCString(p_path, &t_original_path)
207+
if (*p_path != '/')
208+
MCS_resolvepath(t_original_path, &t_path_str);
209+
else
210+
t_path_str = t_original_path;
211+
}
212+
213+
char *t_folder;
214+
t_folder = nil;
203215

204-
if (strrchr(p_path, '/') != nil)
205-
{
206-
if (*p_path != '/')
207-
{
208-
MCAutoStringRef temp_path;
209-
/* UNCHECKED */ MCStringCreateWithCString(p_path, &temp_path);
210-
/* UNCHECKED */ MCS_resolvepath(*temp_path, &t_path_str);
211-
}
212-
else
213-
/* UNCHECKED */ MCCStringClone(p_path, t_path);
214-
}
215-
216-
char *t_folder;
217-
t_folder = nil;
218-
if (t_path != nil || *t_path_str != nil)
219-
{
220-
if (MCS_exists(*t_path_str, false))
221-
/* UNCHECKED */ MCCStringClone(t_path, t_folder);
222-
223-
else {
224-
char *t_last_slash;
225-
t_last_slash = strrchr(t_path, '/');
226-
if (t_last_slash != nil)
227-
/* UNCHECKED */ MCCStringCloneSubstring(t_path, t_last_slash - t_path, t_folder);
216+
if (MCS_exists(*t_path_str, false))
217+
/* UNCHECKED */ t_folder = strdup(MCStringGetCString(*t_path_str));
218+
else
219+
{
220+
uindex_t t_index;
221+
if (MCStringLastIndexOfLastChar(*t_path_str, '/', kMCStringCompareExact, UINDEX_MAX, t_index))
222+
{
223+
MCAutoStringRef t_folder_str;
224+
/* UNCHECKED */ MCStringCopySubstring(*t_path_str, MCRangeMake(0, t_index), &t_folder_str);
225+
t_folder = strdup(MCStringGetCString(*t_folder_str));
228226
}
229-
}
230-
231-
/* UNCHECKED */ MCCStringFree(t_path);
232-
return t_folder;
227+
}
228+
229+
return t_folder;
233230
}
234231

235232
static bool filter_to_type_list(const char *p_filter, char ***r_types, uint32_t &r_type_count)

engine/src/property.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,8 +1646,8 @@ Exec_stat MCProperty::set(MCExecPoint &ep)
16461646
MChcstat = ep.getsvalue().clone();
16471647
break;
16481648
case P_SCRIPT_TEXT_FONT:
1649-
MCValueRelease(MCscriptfont);
1650-
MCscriptfont = MCSTR(ep.getsvalue());
1649+
delete MCscriptfont;
1650+
MCscriptfont = ep.getsvalue();
16511651
break;
16521652
case P_SCRIPT_TEXT_SIZE:
16531653
return ep.getuint2(MCscriptsize, line, pos, EE_PROPERTY_NAN);

engine/src/srvmac.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,9 @@ static Boolean do_backup(const char *p_src_path, const char *p_dst_path)
10851085
if (!t_error)
10861086
{
10871087
OSErr t_os_error;
1088-
t_os_error = do_nativepathtoref(MCSTR(p_src_path), &t_src_ref);
1088+
MCAutoStringRef t_src_path_str;
1089+
/* UNCHECKED */ MCStringCreateWithCString(p_src_path, &t_src_path_str);
1090+
t_os_error = do_nativepathtoref(*t_src_path_str, &t_src_ref);
10891091
if (t_os_error != noErr)
10901092
t_error = true;
10911093
}
@@ -1098,7 +1100,9 @@ static Boolean do_backup(const char *p_src_path, const char *p_dst_path)
10981100
if (!t_error)
10991101
{
11001102
OSErr t_os_error;
1101-
t_os_error = do_nativepathtoref(MCSTR(p_dst_path), &t_dst_ref);
1103+
MCAutoStringRef t_dst_path_str;
1104+
/* UNCHECKED */ MCStringCreateWithCString(p_dst_path, &t_dst_path_str);
1105+
t_os_error = do_nativepathtoref(*t_dst_path_str, &t_dst_ref);
11021106
if (t_os_error == noErr)
11031107
FSDeleteObject(&t_dst_ref);
11041108

0 commit comments

Comments
 (0)