Skip to content

Commit f8d3a5c

Browse files
author
runrevali
committed
Update DivideAtChar to use exact comparison where possible; update any string comparisons with empty to use MCStringIsEmpty
1 parent c535992 commit f8d3a5c

13 files changed

+24
-20
lines changed

engine/src/bitmapeffect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ bool MCBitmapEffectsGetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
710710

711711
// If 'p_index' is the empty name, this is a whole array op.
712712
bool t_is_array;
713-
t_is_array = MCNameIsEqualTo(p_index, kMCEmptyName, kMCCompareCaseless);
713+
t_is_array = MCNameIsEmpty(p_index);
714714

715715
// Now fetch the bitmap effect we are processing - note that if this is
716716
// NULL it means it isn't set. In this case we still carry on since we
@@ -952,7 +952,7 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
952952

953953
// If 'p_index' is the empty name, this is a whole array op.
954954
bool t_is_array;
955-
t_is_array = MCNameIsEqualTo(p_index, kMCEmptyName, kMCCompareCaseless);
955+
t_is_array = MCNameIsEmpty(p_index);
956956

957957
if (t_is_array && p_value . type == kMCExecValueTypeValueRef && MCValueIsEmpty(p_value . valueref_value))
958958
{

engine/src/cmdss.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,6 +2878,10 @@ void MCSubwindow::exec_ctxt(MCExecContext &ctxt)
28782878
t_delimiter++;
28792879
MCStringCopySubstring(*t_position_data, MCRangeMake(t_delimiter, MCStringGetLength(*t_position_data) - t_delimiter), &t_alignment);
28802880
}
2881+
// AL-2014-04-07: [[ Bug 12138 ]] 'drawer ... at <position>' codepath resulted in t_position uninitialised
2882+
else
2883+
t_position = *t_position_data;
2884+
28812885
if (MCStringIsEqualToCString(*t_position, "right", kMCCompareCaseless))
28822886
t_pos = WP_PARENTRIGHT;
28832887
else if (MCStringIsEqualToCString(*t_position, "left", kMCCompareCaseless))

engine/src/debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ void MCB_parsebreaks(MCExecContext& ctxt, MCStringRef p_input)
527527
MCAutoStringRef t_info;
528528

529529
if (t_success)
530-
t_success = MCStringDivideAtChar(*t_tail, ',', kMCCompareCaseless, &t_line_string, &t_info);
530+
t_success = MCStringDivideAtChar(*t_tail, ',', kMCCompareExact, &t_line_string, &t_info);
531531

532532
int32_t t_line;
533533

engine/src/dispatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ Boolean MCDispatch::openenv(MCStringRef sname, MCStringRef env,
469469
{
470470
MCAutoStringRef t_env_path;
471471
MCStringRef t_next_rest_of_env;
472-
/* UNCHECKED */ MCStringDivideAtChar(t_rest_of_env, ENV_SEPARATOR, kMCStringOptionCompareCaseless, &t_env_path, t_next_rest_of_env);
472+
/* UNCHECKED */ MCStringDivideAtChar(t_rest_of_env, ENV_SEPARATOR, kMCStringOptionCompareExact, &t_env_path, t_next_rest_of_env);
473473
if (attempt_to_loadfile(stream, outpath, "%@/%@", *t_env_path, sname))
474474
t_found = true;
475475

engine/src/exec-interface-object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3976,7 +3976,7 @@ void MCObject::GetCustomPropertiesElement(MCExecContext& ctxt, MCNameRef p_index
39763976
void MCObject::SetCustomKeysElement(MCExecContext& ctxt, MCNameRef p_index, MCStringRef p_string)
39773977
{
39783978
MCObjectPropertySet *t_propset;
3979-
if (MCStringIsEqualTo(p_string, kMCEmptyString, kMCCompareCaseless))
3979+
if (MCStringIsEmpty(p_string))
39803980
{
39813981
if (findpropset(p_index, true, t_propset))
39823982
t_propset -> clear();

engine/src/exec-interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,7 @@ void MCInterfaceExecSelectTextOfButton(MCExecContext& ctxt, Preposition_type p_t
23872387
if (t_success)
23882388
{
23892389
uindex_t t_lines;
2390-
t_lines = MCStringCountChar(*t_text, MCRangeMake(0, p_target . mark . start), '\n', kMCStringOptionCompareCaseless);
2390+
t_lines = MCStringCountChar(*t_text, MCRangeMake(0, p_target . mark . start), '\n', kMCStringOptionCompareExact);
23912391

23922392
static_cast<MCButton *>(p_target . object) -> setmenuhistory(t_lines + 1);
23932393
}

engine/src/exec-network.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ void MCNetworkSetFtpProxy(MCExecContext& ctxt, MCStringRef p_value)
697697
{
698698

699699
MCAutoStringRef t_host, t_port;
700-
/* UNCHECKED */ MCStringDivideAtChar(p_value, ':', kMCCompareCaseless, &t_host, &t_port);
700+
/* UNCHECKED */ MCStringDivideAtChar(p_value, ':', kMCCompareExact, &t_host, &t_port);
701701
if (*t_port != nil)
702702
/* UNCHECKED */ MCStringToUInt16(*t_port, MCftpproxyport);
703703
else

engine/src/exec-printing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static void MCPrintingPrintDeviceOutputParse(MCExecContext& ctxt, MCStringRef p_
144144
}
145145

146146
MCAutoStringRef t_head, t_tail;
147-
if (MCStringDivideAtChar(p_input, ':', kMCCompareCaseless, &t_head, &t_tail))
147+
if (MCStringDivideAtChar(p_input, ':', kMCCompareExact, &t_head, &t_tail))
148148
{
149149
if (MCStringIsEqualToCString(*t_head, "file", kMCCompareCaseless))
150150
{
@@ -213,7 +213,7 @@ struct MCPrintingPrinterPageRange
213213
static void MCPrintingPrinterPageRangeParse(MCExecContext& ctxt, MCStringRef p_input, MCPrintingPrinterPageRange& r_output)
214214
{
215215
if (MCStringIsEqualToCString(p_input, "all", kMCCompareCaseless) ||
216-
MCStringIsEqualToCString(p_input, "", kMCCompareCaseless))
216+
MCStringIsEmpty(p_input))
217217
{
218218
r_output . count = PRINTER_PAGE_RANGE_ALL;
219219
r_output . ranges = nil;

engine/src/mblandroidbrowser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ JNIEXPORT void JNICALL Java_com_runrev_android_nativecontrol_BrowserControl_doJS
560560
char *t_tag = nil;
561561
MCJavaStringToNative(MCJavaGetThreadEnv(), tag, t_tag);
562562

563-
if (t_tag == nil || MCStringIsEqualTo(MCAndroidBrowserControl::s_js_tag, kMCEmptyString, kMCCompareExact) || !MCStringIsEqualToCString(MCAndroidBrowserControl::s_js_tag, t_tag, kMCCompareExact))
563+
if (t_tag == nil || MCStringIsEmpty(MCAndroidBrowserControl::s_js_tag) || !MCStringIsEqualToCString(MCAndroidBrowserControl::s_js_tag, t_tag, kMCCompareExact))
564564
t_match = false;
565565

566566
if (t_match)

engine/src/mbliphonemail.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static void iphone_send_email_prewait(void *p_context)
148148

149149
NSArray *t_recipients;
150150
t_recipients = nil;
151-
if (ctxt -> to_addresses != nil && !MCStringIsEqualTo(ctxt -> to_addresses, kMCEmptyString, kMCCompareCaseless))
151+
if (ctxt -> to_addresses != nil && !MCStringIsEmpty(ctxt -> to_addresses))
152152
t_recipients = [[NSString stringWithMCStringRef: ctxt -> to_addresses] componentsSeparatedByString: @","];
153153

154154
NSArray *t_ccs;
@@ -502,17 +502,17 @@ static void compose_mail_prewait(void *p_context)
502502

503503
NSArray *t_ns_to;
504504
t_ns_to = nil;
505-
if (ctxt -> to != nil && !MCStringIsEqualTo(ctxt -> to, kMCEmptyString, kMCCompareCaseless))
505+
if (ctxt -> to != nil && !MCStringIsEmpty(ctxt -> to))
506506
t_ns_to = mcstringref_to_nsarray(ctxt -> to, t_separator_set);
507507

508508
NSArray *t_ns_cc;
509509
t_ns_cc = nil;
510-
if (ctxt -> cc != nil && !MCStringIsEqualTo(ctxt -> cc, kMCEmptyString, kMCCompareCaseless))
510+
if (ctxt -> cc != nil && !MCStringIsEmpty(ctxt -> cc))
511511
t_ns_cc = mcstringref_to_nsarray(ctxt -> cc, t_separator_set);
512512

513513
NSArray *t_ns_bcc;
514514
t_ns_bcc = nil;
515-
if (ctxt -> bcc != nil && !MCStringIsEqualTo(ctxt -> bcc, kMCEmptyString, kMCCompareCaseless))
515+
if (ctxt -> bcc != nil && !MCStringIsEmpty(ctxt -> bcc))
516516
t_ns_bcc = mcstringref_to_nsarray(ctxt -> bcc, t_separator_set);
517517

518518
[ ctxt -> dialog setSubject: t_ns_subject ];

0 commit comments

Comments
 (0)