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

Commit c40dafc

Browse files
committed
[[ Bug 14485 ]] Errors in parsing expressions involving widget.
The MCChunk object is highly dependent on the order of CT_* enum for controls. In particular, CT_FIELD must be the last object type as there is a comparison which depends on it being a text chunk. Therefore CT_FIELD has been moved to after CT_WIDGET and aliased with CT_FIRST_TEXT_CHUNK. Places in the code which were comparing with CT_FIELD to get a control have been updated to CT_LAST_CONTROL, and places which were comparing to CT_FIELD as a text chunk have been updated to use CT_FIRST_TEXT_CHUNK. In particular, this fixes the issue with parsing chunk lists such as 'widget 1 and button 2' - which was parsing 'widget (1 and button 2)' rather than 'widget (1) and button (2)'.
1 parent 15d1e5a commit c40dafc

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

engine/src/chunk.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
369369
{
370370
if (sp.lookup(SP_FACTOR, ite) == PS_NORMAL
371371
&& ite->type == TT_CHUNK
372-
&& ite->which >= CT_LAYER && ite->which <= CT_FIELD)
372+
&& ite->which >= CT_LAYER && ite->which <= CT_LAST_CONTROL)
373373
{
374374
curref->ptype = curref->otype;
375375
nterm = curref->otype = (Chunk_term)ite->which;
@@ -384,7 +384,7 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
384384
curref->etype = CT_ID;
385385
else
386386
curref->etype = CT_EXPRESSION;
387-
if (sp.parseexp(curref->otype <= CT_FIELD, False,
387+
if (sp.parseexp(curref->otype <= CT_LAST_CONTROL, False,
388388
&curref->startpos) != PS_NORMAL)
389389
{
390390
MCperror->add(PE_CHUNK_NOSTARTEXP, sp);

engine/src/cmdsc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2607,7 +2607,7 @@ void MCMakeGroup::exec_ctxt(MCExecContext& ctxt)
26072607

26082608
// MW-2013-06-20: [[ Bug 10863 ]] Only objects which are controls, and have a
26092609
// parent are groupable.
2610-
if (optr->gettype() > CT_FIELD ||
2610+
if (optr->gettype() > CT_LAST_CONTROL ||
26112611
optr->gettype() < CT_GROUP ||
26122612
optr->getparent() == NULL ||
26132613
optr->getparent()->gettype() != CT_CARD)

engine/src/cmdss.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ Parse_stat MCGo::parse(MCScriptPoint &sp)
335335
curref = new MCCRef;
336336
if (oterm == CT_UNDEFINED)
337337
{
338-
if (nterm >= CT_FIELD || nterm == CT_URL)
338+
if (nterm >= CT_FIRST_TEXT_CHUNK || nterm == CT_URL)
339339
{
340340
sp.backup();
341341
nterm = CT_CARD;

engine/src/sellst.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ MCControl *MCSellist::clone(MCObject *target)
281281
Exec_stat MCSellist::group(uint2 line, uint2 pos)
282282
{
283283
MCresult->clear(False);
284-
if (objects != NULL && objects->ref->gettype() <= CT_FIELD
284+
if (objects != NULL && objects->ref->gettype() <= CT_LAST_CONTROL
285285
&& objects->ref->gettype() >= CT_GROUP)
286286
{
287287
MCObject *parent = objects->ref->getparent();

engine/src/sysdefs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,10 @@ enum Chunk_term {
13321332
CT_EPS,
13331333
CT_MAGNIFY,
13341334
CT_COLOR_PALETTE,
1335-
CT_FIELD,
13361335
CT_WIDGET,
1337-
CT_LAST_CONTROL = CT_WIDGET,
1336+
CT_FIELD,
1337+
CT_LAST_CONTROL = CT_FIELD,
1338+
CT_FIRST_TEXT_CHUNK = CT_FIELD,
13381339
CT_LINE,
13391340
CT_PARAGRAPH,
13401341
CT_SENTENCE,

0 commit comments

Comments
 (0)