Skip to content

Commit 9e83dea

Browse files
author
Fraser J. Gordon
committed
Merge branch 'develop' of https://github.com/runrev/livecode into modular
2 parents fcc53d2 + e4a0546 commit 9e83dea

19 files changed

+215
-160
lines changed

engine/src/button.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,6 @@ Boolean MCButton::mfocus(int2 x, int2 y)
973973
if (getstyleint(flags) == F_MENU && menumode == WM_TOP_LEVEL
974974
&& IsMacLF() && state & CS_MFOCUSED)
975975
{
976-
MCRectangle trect = rect;
977-
trect.height = 8 + MCFontGetAscent(m_font);
978976
// MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
979977
layer_redrawall();
980978
}

engine/src/card.cpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -994,18 +994,22 @@ void MCCard::timer(MCNameRef mptr, MCParameter *params)
994994
if (mfocused == NULL && MCbuttonstate)
995995
{
996996
if (tool == T_BROWSE)
997+
{
997998
if (message(MCM_mouse_still_down) == ES_ERROR)
998999
senderror();
9991000
else
10001001
again = True;
1002+
}
10011003
}
10021004
if (hashandlers & HH_IDLE)
10031005
{
10041006
if (tool == T_BROWSE)
1007+
{
10051008
if (message(MCM_idle) == ES_ERROR)
10061009
senderror();
10071010
else
10081011
again = True;
1012+
}
10091013
}
10101014
if (again)
10111015
MCscreen->addtimer(this, MCM_idle, MCidleRate);
@@ -1813,7 +1817,7 @@ void MCCard::relayercontrol_insert(MCControl *p_control, MCControl *p_target)
18131817

18141818
Exec_stat MCCard::relayer(MCControl *optr, uint2 newlayer)
18151819
{
1816-
if (!opened || !MCrelayergrouped && optr->getparent()->gettype() == CT_GROUP || (optr -> getparent() -> gettype() == CT_CARD && optr -> getparent() != this))
1820+
if (!opened || (!MCrelayergrouped && optr->getparent()->gettype() == CT_GROUP) || (optr -> getparent() -> gettype() == CT_CARD && optr -> getparent() != this))
18171821
return ES_ERROR;
18181822
uint2 oldlayer = 0;
18191823
if (!MCrelayergrouped)
@@ -1963,7 +1967,7 @@ MCCard *MCCard::findname(Chunk_term type, MCNameRef inname)
19631967

19641968
MCCard *MCCard::findid(Chunk_term type, uint4 inid, Boolean alt)
19651969
{
1966-
if (type == CT_CARD && (inid == obj_id || alt && inid == altid))
1970+
if (type == CT_CARD && (inid == obj_id || (alt && inid == altid)))
19671971
return this;
19681972
else
19691973
return NULL;
@@ -2007,9 +2011,9 @@ Boolean MCCard::count(Chunk_term otype, Chunk_term ptype,
20072011

20082012
// MW-2011-08-08: [[ Groups ]] Use 'isbackground()' rather than !F_GROUP_ONLY.
20092013
if (ptype == CT_UNDEFINED
2010-
|| otype == CT_GROUP && ttype == CT_GROUP
2011-
|| ptype != CT_BACKGROUND && ttype != CT_GROUP
2012-
|| (ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground())
2014+
|| (otype == CT_GROUP && ttype == CT_GROUP)
2015+
|| (ptype != CT_BACKGROUND && ttype != CT_GROUP)
2016+
|| ((ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground()))
20132017
if (optr->getref()->count(otype, stop, num))
20142018
{
20152019
if (!opened)
@@ -2052,9 +2056,9 @@ MCControl *MCCard::getnumberedchild(integer_t p_number, Chunk_term p_obj_type, C
20522056

20532057
// MW-2011-08-08: [[ Groups ]] Use 'isbackground()' rather than !F_GROUP_ONLY.
20542058
if (p_parent_type == CT_UNDEFINED
2055-
|| p_obj_type == CT_GROUP && t_type == CT_GROUP
2056-
|| p_parent_type != CT_BACKGROUND && t_type != CT_GROUP
2057-
|| (t_type == CT_GROUP && p_parent_type == CT_BACKGROUND) == static_cast<MCGroup *>(t_optr->getref())->isbackground())
2059+
|| (p_obj_type == CT_GROUP && t_type == CT_GROUP)
2060+
|| (p_parent_type != CT_BACKGROUND && t_type != CT_GROUP)
2061+
|| ((t_type == CT_GROUP && p_parent_type == CT_BACKGROUND) == static_cast<MCGroup *>(t_optr->getref())->isbackground()))
20582062
{
20592063
if (!t_optr->getref()->getopened())
20602064
t_optr->getref()->setparent(this);
@@ -2146,11 +2150,11 @@ MCControl *MCCard::getchild(Chunk_term etype, MCStringRef p_expression,
21462150
{
21472151
Chunk_term ttype = optr->getref()->gettype();
21482152
if (ptype == CT_UNDEFINED
2149-
|| otype == CT_GROUP && ttype == CT_GROUP
2150-
|| ptype != CT_BACKGROUND && ttype != CT_GROUP
2151-
|| (ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground())
2153+
|| (otype == CT_GROUP && ttype == CT_GROUP)
2154+
|| (ptype != CT_BACKGROUND && ttype != CT_GROUP)
2155+
|| ((ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground()))
21522156
{
2153-
if (otype == CT_LAYER && t_object -> gettype() > CT_CARD || t_object -> gettype() == otype)
2157+
if ((otype == CT_LAYER && t_object -> gettype() > CT_CARD) || t_object -> gettype() == otype)
21542158
return (MCControl *)t_object;
21552159
}
21562160
}
@@ -2163,9 +2167,9 @@ MCControl *MCCard::getchild(Chunk_term etype, MCStringRef p_expression,
21632167

21642168
// MW-2011-08-08: [[ Groups ]] Use 'isbackground()' rather than !F_GROUP_ONLY.
21652169
if (ptype == CT_UNDEFINED
2166-
|| otype == CT_GROUP && ttype == CT_GROUP
2167-
|| ptype != CT_BACKGROUND && ttype != CT_GROUP
2168-
|| (ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground())
2170+
|| (otype == CT_GROUP && ttype == CT_GROUP)
2171+
|| (ptype != CT_BACKGROUND && ttype != CT_GROUP)
2172+
|| ((ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground()))
21692173
{
21702174
if (!optr->getref()->getopened())
21712175
optr->getref()->setparent(this);
@@ -2205,9 +2209,9 @@ MCControl *MCCard::getchild(Chunk_term etype, MCStringRef p_expression,
22052209

22062210
// MW-2011-08-08: [[ Groups ]] Use 'isbackground()' rather than !F_GROUP_ONLY.
22072211
if (ptype == CT_UNDEFINED
2208-
|| otype == CT_GROUP && ttype == CT_GROUP
2209-
|| ptype != CT_BACKGROUND && ttype != CT_GROUP
2210-
|| (ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground())
2212+
|| (otype == CT_GROUP && ttype == CT_GROUP)
2213+
|| (ptype != CT_BACKGROUND && ttype != CT_GROUP)
2214+
|| ((ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground()))
22112215
foundobj = optr->getref()->findid(otype, tofindid, True);
22122216
if (foundobj != NULL)
22132217
{
@@ -2236,9 +2240,9 @@ MCControl *MCCard::getchild(Chunk_term etype, MCStringRef p_expression,
22362240
Chunk_term ttype = optr->getref()->gettype();
22372241
// MW-2011-08-08: [[ Groups ]] Use 'isbackground()' rather than !F_GROUP_ONLY.
22382242
if (ptype == CT_UNDEFINED
2239-
|| otype == CT_GROUP && ttype == CT_GROUP
2240-
|| ptype != CT_BACKGROUND && ttype != CT_GROUP
2241-
|| (ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground())
2243+
|| (otype == CT_GROUP && ttype == CT_GROUP)
2244+
|| (ptype != CT_BACKGROUND && ttype != CT_GROUP)
2245+
|| ((ttype == CT_GROUP && ptype == CT_BACKGROUND) == static_cast<MCGroup *>(optr->getref())->isbackground()))
22422246
{
22432247
if (!optr->getref()->getopened())
22442248
optr->getref()->setparent(this);
@@ -3085,10 +3089,12 @@ MCRectangle MCCard::computecrect()
30853089
do
30863090
{
30873091
if (optr->getref()->isvisible())
3092+
{
30883093
if (minrect.width == 0)
30893094
minrect = optr->getref()->getrect();
30903095
else
30913096
minrect = MCU_union_rect(optr->getref()->getrect(), minrect);
3097+
}
30923098
optr = optr->next();
30933099
}
30943100
while (optr != objptrs);

engine/src/cardlst.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void MCCardlist::getlongids(MCStack *stack, MCExecPoint &ep)
141141

142142
void MCCardlist::addcard(MCCard *card)
143143
{
144-
if (cards != NULL && cards->card == card || MClockrecent)
144+
if ((cards != NULL && cards->card == card) || MClockrecent)
145145
return;
146146
MCCardnode *nptr = new MCCardnode;
147147
nptr->card = card;

engine/src/cdata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ IO_stat MCCdata::load(IO_handle stream, MCObject *parent, uint32_t version)
9393
{
9494
uint1 set;
9595
stat = IO_read_uint1(&set, stream);
96-
data = (void *)(set ? 1 : 0);
96+
data = reinterpret_cast<void *>(set ? 1 : 0);
9797
return stat;
9898
}
9999
else

engine/src/chunk.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,15 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
201201
while (True)
202202
{
203203
if (sp.next(type) != PS_NORMAL)
204+
{
204205
if (need_target)
205206
{
206207
MCperror->add(PE_CHUNK_NOCHUNK, sp);
207208
return PS_ERROR;
208209
}
209210
else
210211
break;
212+
}
211213
if (type == ST_ID)
212214
{
213215
te = NULL;
@@ -222,10 +224,10 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
222224
// MW-2011-06-22: [[ SERVER ]] Update to use SP findvar method to take into account
223225
// execution outwith a handler.
224226
if (doingthe
225-
|| sp.findvar(sp.gettoken_nameref(), &destvar) != PS_NORMAL
227+
|| (sp.findvar(sp.gettoken_nameref(), &destvar) != PS_NORMAL
226228
&& (MCexplicitvariables
227229
|| sp.lookupconstant(&newfact) == PS_NORMAL
228-
|| sp.findnewvar(sp.gettoken_nameref(), kMCEmptyName, &destvar) != PS_NORMAL))
230+
|| sp.findnewvar(sp.gettoken_nameref(), kMCEmptyName, &destvar) != PS_NORMAL)))
229231
{
230232
delete newfact;
231233
MCperror->add(PE_CHUNK_NOVARIABLE, sp);
@@ -351,8 +353,8 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
351353
break;
352354
case CT_TYPES:
353355
// MW-2011-08-08: [[ Bug ]] Allow control ... of control ...
354-
if (lterm != CT_UNDEFINED && nterm > lterm
355-
|| nterm == lterm && nterm != CT_GROUP && nterm != CT_LAYER && nterm != CT_STACK)
356+
if ((lterm != CT_UNDEFINED && nterm > lterm)
357+
|| (nterm == lterm && nterm != CT_GROUP && nterm != CT_LAYER && nterm != CT_STACK))
356358
{
357359
MCperror->add(PE_CHUNK_BADORDER, sp);
358360
return PS_ERROR;

engine/src/cmds.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ if (sp.next(type) != PS_NORMAL)
996996
return PS_ERROR;
997997
}
998998
if (sp.lookup(SP_MARK,te) != PS_NORMAL
999-
|| te->which != MC_BY && te->which != MC_WHERE)
999+
|| (te->which != MC_BY && te->which != MC_WHERE))
10001000
{
10011001
MCperror->add
10021002
(PE_MARK_NOTBYORWHERE, sp);
@@ -2083,6 +2083,7 @@ Parse_stat MCSort::parse(MCScriptPoint &sp)
20832083
while (True)
20842084
{
20852085
if (sp.next(type) != PS_NORMAL)
2086+
{
20862087
if (of == NULL && chunktype == CT_FIELD)
20872088
{
20882089
MCperror->add
@@ -2091,6 +2092,7 @@ Parse_stat MCSort::parse(MCScriptPoint &sp)
20912092
}
20922093
else
20932094
break;
2095+
}
20942096
if (sp.lookup(SP_SORT, te) == PS_NORMAL)
20952097
{
20962098
switch (te->which)
@@ -2473,17 +2475,17 @@ Parse_stat MCWait::parse(MCScriptPoint &sp)
24732475
return PS_ERROR;
24742476
}
24752477
if (condition == RF_FOR)
2478+
{
24762479
if (sp.skip_token(SP_FACTOR, TT_FUNCTION, F_MILLISECS) == PS_NORMAL)
24772480
units = F_MILLISECS;
2481+
else if (sp.skip_token(SP_FACTOR, TT_FUNCTION, F_SECONDS) == PS_NORMAL
2482+
|| sp.skip_token(SP_FACTOR, TT_CHUNK, CT_SECOND) == PS_NORMAL)
2483+
units = F_SECONDS;
2484+
else if (sp.skip_token(SP_FACTOR, TT_FUNCTION, F_TICKS) == PS_NORMAL)
2485+
units = F_TICKS;
24782486
else
2479-
if (sp.skip_token(SP_FACTOR, TT_FUNCTION, F_SECONDS) == PS_NORMAL
2480-
|| sp.skip_token(SP_FACTOR, TT_CHUNK, CT_SECOND) == PS_NORMAL)
2481-
units = F_SECONDS;
2482-
else
2483-
if (sp.skip_token(SP_FACTOR, TT_FUNCTION, F_TICKS) == PS_NORMAL)
2484-
units = F_TICKS;
2485-
else
2486-
units = F_TICKS;
2487+
units = F_TICKS;
2488+
}
24872489
if (sp.skip_token(SP_REPEAT, TT_UNDEFINED, RF_WITH) == PS_NORMAL)
24882490
{
24892491
sp.skip_token(SP_MOVE, TT_UNDEFINED, MM_MESSAGES);

engine/src/cmdsc.cpp

Lines changed: 2 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ void MCDelete::exec_ctxt(MCExecContext& ctxt)
17111711
MCEngineExecDeleteVariableChunks(ctxt, t_chunks . Ptr(), t_chunks . Size());
17121712

17131713
// Release the text stored from evalvarchunk
1714-
for (int i = 0; i < t_chunks . Size(); ++i)
1714+
for (uindex_t i = 0; i < t_chunks . Size(); ++i)
17151715
{
17161716
MCValueRelease(t_chunks[i] . mark . text);
17171717
}
@@ -1748,7 +1748,7 @@ void MCDelete::exec_ctxt(MCExecContext& ctxt)
17481748
if (!t_return)
17491749
MCInterfaceExecDeleteObjectChunks(ctxt, t_chunks . Ptr(), t_chunks . Size());
17501750

1751-
for (int i = 0; i < t_chunks . Size(); ++i)
1751+
for (uindex_t i = 0; i < t_chunks . Size(); ++i)
17521752
MCValueRelease(t_chunks[i] . mark . text);
17531753
}
17541754
else if (targets != nil)
@@ -3282,103 +3282,6 @@ void MCRename::compile(MCSyntaxFactoryRef ctxt)
32823282

32833283
////////////////////////////////////////////////////////////////////////////////
32843284

3285-
// MW-2012-02-01: [[ Bug 9647 ]] New implementation of replace to fix the flaws
3286-
// in the old implementation.
3287-
// MW-2012-03-22: [[ Bug ]] Use uint8_t rather than char, otherwise we get
3288-
// comparison issues on some platforms (where char is signed!).
3289-
3290-
// Special case replacing a char with another char when case-sensitive is true.
3291-
static void replace_char_with_char(uint8_t *p_chars, uindex_t p_char_count, uint8_t p_from, uint8_t p_to)
3292-
{
3293-
// Simplest case, just substitute from for to.
3294-
for(uindex_t i = 0; i < p_char_count; i++)
3295-
if (p_chars[i] == p_from)
3296-
p_chars[i] = p_to;
3297-
}
3298-
3299-
// Special case replacing a char with another char when case-sensitive is false.
3300-
static void replace_char_with_char_caseless(uint8_t *p_chars, uindex_t p_char_count, uint8_t p_from, uint8_t p_to)
3301-
{
3302-
// Lowercase the from char.
3303-
p_from = MCS_tolower(p_from);
3304-
3305-
// Now substitute from for to, taking making sure its a caseless compare.
3306-
for(uindex_t i = 0; i < p_char_count; i++)
3307-
if (MCS_tolower(p_chars[i]) == p_from)
3308-
p_chars[i] = p_to;
3309-
}
3310-
3311-
// General replace case, rebuilds the input string in 'output' replacing each
3312-
// occurance of from with to.
3313-
static bool replace_general(const MCString& p_input, const MCString& p_from, const MCString& p_to, bool p_caseless, char*& r_output, uindex_t& r_output_length)
3314-
{
3315-
char *t_output;
3316-
uindex_t t_output_length;
3317-
uindex_t t_output_capacity;
3318-
t_output = nil;
3319-
t_output_length = 0;
3320-
t_output_capacity = 0;
3321-
3322-
MCString t_whole;
3323-
t_whole = p_input;
3324-
3325-
for(;;)
3326-
{
3327-
// Search for the next occurance of from in whole.
3328-
Boolean t_found;
3329-
uindex_t t_offset;
3330-
t_found = MCU_offset(p_from, t_whole, t_offset, p_caseless);
3331-
3332-
// If we found an instance of from, then we need space for to; otherwise,
3333-
// we update the offset, and need just room up to it.
3334-
uindex_t t_space_needed;
3335-
if (t_found)
3336-
t_space_needed = t_offset + p_to . getlength();
3337-
else
3338-
{
3339-
t_offset = t_whole . getlength();
3340-
t_space_needed = t_offset;
3341-
}
3342-
3343-
// Expand the buffer as necessary.
3344-
if (t_output_length + t_space_needed > t_output_capacity)
3345-
{
3346-
if (t_output_capacity == 0)
3347-
t_output_capacity = 4096;
3348-
3349-
while(t_output_length + t_space_needed > t_output_capacity)
3350-
t_output_capacity *= 2;
3351-
3352-
if (!MCMemoryReallocate(t_output, t_output_capacity, t_output))
3353-
{
3354-
MCMemoryDeallocate(t_output);
3355-
return false;
3356-
}
3357-
}
3358-
3359-
// Copy in whole, up to the offset.
3360-
memcpy(t_output + t_output_length, t_whole . getstring(), t_offset);
3361-
t_output_length += t_offset;
3362-
3363-
// No more occurances were found, so we are done.
3364-
if (!t_found)
3365-
break;
3366-
3367-
// Now copy in to.
3368-
memcpy(t_output + t_output_length, p_to . getstring(), p_to . getlength());
3369-
t_output_length += p_to . getlength();
3370-
3371-
// Update whole.
3372-
t_whole . set(t_whole . getstring() + t_offset + p_from . getlength(), t_whole . getlength() - (t_offset + p_from . getlength()));
3373-
}
3374-
3375-
// Make sure the buffer is no bigger than is needed.
3376-
MCMemoryReallocate(t_output, t_output_length, r_output);
3377-
r_output_length = t_output_length;
3378-
3379-
return true;
3380-
}
3381-
33823285
MCReplace::~MCReplace()
33833286
{
33843287
delete container;

engine/src/exec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct MCExecSetTypeInfo
148148
struct MCExecEnumTypeElementInfo
149149
{
150150
const char *tag;
151-
uindex_t value;
151+
intenum_t value;
152152
bool read_only;
153153
};
154154

engine/src/externalv0.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,11 +1331,11 @@ static char *get_variable_ex_utf8(const char *arg1, const char *arg2,
13311331
if (MCECptr == NULL)
13321332
{
13331333
*retval = xresFail;
1334-
return false;
1334+
return NULL;
13351335
}
13361336
*retval = trans_stat(getvarptr_utf8(*MCECptr, arg1, &var));
13371337
if (var == NULL)
1338-
return false;
1338+
return NULL;
13391339

13401340
MCAutoValueRef t_value;
13411341

0 commit comments

Comments
 (0)