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

Commit 8216b22

Browse files
committed
Updates after feedback #1
1 parent cb8d2f2 commit 8216b22

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

engine/src/exec-engine.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,22 +1207,21 @@ static void MCEngineSendOrCall(MCExecContext& ctxt, MCStringRef p_script, MCObje
12071207
ctxt . LegacyThrow(EE_SEND_BADEXP, *t_message);
12081208
else
12091209
{
1210-
MCStringRef tptr;
1211-
tptr = MCNameGetString(*t_message);
1212-
// char *tptr = (char *)MCNameGetCString(*t_message);
1210+
MCAutoStringRef tptr;
1211+
12131212
if (t_params != NULL)
12141213
{
12151214
t_params->eval(ctxt . GetEP());
1216-
char *p = ctxt . GetEP() . getsvalue() . clone();
1217-
// tptr = new char[strlen(MCNameGetCString(*t_message)) + ctxt . GetEP() . getsvalue() . getlength() + 2];
1218-
// sprintf(tptr, "%s %s", MCNameGetCString(*t_message), p);
1219-
MCStringFormat(tptr, "%s %s", MCNameGetCString(*t_message), p);
1220-
delete p;
1215+
MCAutoStringRef t_value;
1216+
ctxt . GetEP() . copyasstringref(&t_value);
1217+
MCStringFormat(&tptr, "%@ %@", *t_message, *t_value);
1218+
12211219
}
1222-
if ((stat = optr->domess(tptr)) == ES_ERROR)
1220+
else
1221+
tptr = MCNameGetString(*t_message);
1222+
1223+
if ((stat = optr->domess(&tptr)) == ES_ERROR)
12231224
ctxt . LegacyThrow(EE_STATEMENT_BADCOMMAND, *t_message);
1224-
if (tptr != MCNameGetString(*t_message))
1225-
MCValueRelease(tptr);
12261225
}
12271226
}
12281227
else if (stat == ES_PASS)

engine/src/lnxspec.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,12 +1634,11 @@ void MCS_launch_url(const char *p_document)
16341634
}
16351635
else
16361636
{
1637-
MCStringRef t_handler = nil;
1638-
/* UNCHECKED */ MCStringFormat(t_handler, LAUNCH_URL_SCRIPT, p_document);
1637+
MCAutoStringRef t_handler;
1638+
/* UNCHECKED */ MCStringFormat(&t_handler, LAUNCH_URL_SCRIPT, p_document);
16391639
MCExecPoint ep (NULL, NULL, NULL) ;
1640-
MCdefaultstackptr->domess(t_handler);
1640+
MCdefaultstackptr->domess(*t_handler);
16411641
MCresult->eval(ep);
1642-
MCValueRelease(t_handler);
16431642
}
16441643
}
16451644

engine/src/object.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -769,24 +769,25 @@ void MCObject::timer(MCNameRef mptr, MCParameter *params)
769769
Exec_stat stat = message(mptr, params, True, True);
770770
if (stat == ES_NOT_HANDLED && !handler.getpass())
771771
{
772-
MCStringRef tptr = nil;
773-
MCStringRef t_mptr_string;
774-
t_mptr_string = MCNameGetString(mptr);
775-
if (params != NULL)
772+
MCAutoStringRef tptr;
773+
MCAutoStringRef t_mptr_string;
774+
775+
if (params != nil)
776776
{
777777
MCExecPoint ep(this, NULL, NULL);
778778
params->eval(ep);
779-
char *p = ep.getsvalue().clone();
780-
MCStringFormat(tptr, "%s %s", MCStringGetCString(t_mptr_string), p);
781-
delete p;
779+
MCAutoStringRef t_value;
780+
ep . copyasstringref(&t_value);
781+
MCStringFormat(&tptr, "%@ %@", *t_mptr_string, *t_value);
782782
}
783+
else
784+
t_mptr_string = MCNameGetString(mptr);
783785

784786
MCHandler *t_handler;
785787
t_handler = findhandler(HT_MESSAGE, mptr);
786788
if (t_handler == NULL || !t_handler -> isprivate())
787-
domess(params == NULL ? t_mptr_string : tptr);
789+
domess(params == NULL ? *t_mptr_string : *tptr);
788790

789-
MCValueRelease(tptr);
790791
}
791792
if (stat == ES_ERROR && !MCNameIsEqualTo(mptr, MCM_error_dialog, kMCCompareCaseless))
792793
senderror();
@@ -2528,7 +2529,7 @@ void MCObject::positionrel(const MCRectangle &drect,
25282529
Exec_stat MCObject::domess(MCStringRef sptr)
25292530
{
25302531
MCAutoStringRef t_temp_script;
2531-
/* UNCHECKED */ MCStringFormat(&t_temp_script, "on message\n%s\nend message\n", MCStringGetCString(sptr));
2532+
/* UNCHECKED */ MCStringFormat(&t_temp_script, "on message\n%@\nend message\n", sptr);
25322533

25332534
MCHandlerlist *handlist = new MCHandlerlist;
25342535
// SMR 1947, suppress parsing errors

engine/src/srvdebug.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,11 @@ void MCServerDebugBreakpoint(const char *p_action, const char *p_file, uint32_t
383383

384384
// Construct the absolute file path.
385385
MCAutoStringRef t_filename;
386-
/* UNCHECKED */ MCStringCreateWithCString(MCservercgidocumentroot, &t_filename);
386+
387387
if (p_file[0] != '/')
388-
MCStringAppendNativeChar(*t_filename, '/');
389-
MCStringAppendNativeChars(*t_filename, (const char_t *) p_file, strlen(p_file));
388+
/* UNCHECKED */ MCStringFormat(&t_filename, "%s/%s", MCservercgidocumentroot, p_file);
389+
else
390+
/* UNCHECKED */ MCStringCreateWithCString(p_file, &t_filename);
390391

391392
// Lookup the file's index - creating an entry if we are 'adding' a breakpoint.
392393
uint4 t_file;

engine/src/srvscript.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Parse_stat MCServerScript::ParseNextStatement(MCScriptPoint& sp, MCStatement*& r
303303
// MW-2009-06-02: Add support for 'require' style includes.
304304
bool MCServerScript::Include(MCExecPoint& outer_ep, MCStringRef p_filename, bool p_require)
305305
{
306-
if (p_filename == nil || MCStringGetNativeCharAtIndex(p_filename, 0) == '\0')
306+
if (MCStringIsEmpty(p_filename))
307307
{
308308
MCeerror->add(EE_INCLUDE_BADFILENAME, 0, 0, p_filename);
309309
return false;

0 commit comments

Comments
 (0)