@@ -3349,14 +3349,21 @@ Exec_stat MCLocalLoc::eval(MCExecPoint &ep)
33493349
33503350Parse_stat MCLocals::parse (MCScriptPoint &sp, Boolean the)
33513351{
3352- h = sp.gethandler ();
33533352 return MCFunction::parse (sp, the);
33543353}
33553354
33563355Exec_stat MCLocals::eval (MCExecPoint &ep)
33573356{
33583357#ifdef /* MCLocals */ LEGACY_EXEC
3359- return h->getvarnames (ep, False);
3358+ // MW-2013-11-15: [[ Bug 11277 ]] Server mode may call this outwith a handler.
3359+
3360+ if (ep . gethandler () != nil)
3361+ return ep . gethandler () -> getvarnames (ep, False);
3362+
3363+ ep.clear ();
3364+ ep . gethlist () -> appendlocalnames (ep);
3365+
3366+ return ES_NORMAL;
33603367#endif /* MCLocals */
33613368}
33623369
@@ -3598,7 +3605,6 @@ MCMerge::~MCMerge()
35983605
35993606Parse_stat MCMerge::parse (MCScriptPoint &sp, Boolean the)
36003607{
3601- h = sp.gethandler ();
36023608 if (get1param (sp, &source, the) != PS_NORMAL)
36033609 {
36043610 MCperror->add
@@ -3682,17 +3688,29 @@ Exec_stat MCMerge::eval(MCExecPoint &ep)
36823688 uint4 ei = si + sptr + 1 - pstart;
36833689 MCString s (pstart + 2 , pend - pstart - 4 );
36843690 ep2.setsvalue (s);
3691+ // MW-2013-11-15: [[ Bug 11277 ]] If ep has no handler, then execute in
3692+ // server script object context.
36853693 if (isexpression)
36863694 {
3687- if (h->eval (ep2) != ES_ERROR)
3695+ Exec_stat t_stat;
3696+ if (ep.gethandler () != nil)
3697+ t_stat = ep . gethandler ()->eval (ep2);
3698+ else
3699+ t_stat = ep . gethlist ()-> eval (ep2);
3700+ if (t_stat != ES_ERROR)
36883701 {
36893702 ep.insert (ep2.getsvalue (), si, ei);
36903703 rlength += ep2.getsvalue ().getlength () - (pend - pstart);
36913704 }
36923705 }
36933706 else
36943707 {
3695- if (h->doscript (ep2, line, pos) != ES_ERROR)
3708+ Exec_stat t_stat;
3709+ if (ep.gethandler () != nil)
3710+ t_stat = ep . gethandler () -> doscript (ep2, line, pos);
3711+ else
3712+ t_stat = ep . gethlist () -> doscript (ep2, line, pos);
3713+ if (t_stat != ES_ERROR)
36963714 {
36973715 MCresult->fetch (ep2);
36983716 ep.insert (ep2.getsvalue (), si, ei);
@@ -4148,7 +4166,6 @@ MCParam::~MCParam()
41484166
41494167Parse_stat MCParam::parse (MCScriptPoint &sp, Boolean the)
41504168{
4151- h = sp.gethandler ();
41524169 if (get1param (sp, &source, the) != PS_NORMAL)
41534170 {
41544171 MCperror->add
@@ -4166,46 +4183,68 @@ Exec_stat MCParam::eval(MCExecPoint &ep)
41664183 MCeerror->add (EE_PARAM_BADSOURCE, line, pos);
41674184 return ES_ERROR;
41684185 }
4169- if (h->getparam (ep.getuint2 (), ep) != ES_NORMAL)
4186+ // MW-2013-11-15: [[ Bug 11277 ]] If we don't have a handler then 'the param'
4187+ // makes no sense so just return empty.
4188+ if (ep.gethandler () != nil)
41704189 {
4171- MCeerror->add (EE_PARAM_BADINDEX, line, pos, ep.getsvalue ());
4172- return ES_ERROR;
4190+ if (ep . gethandler ()->getparam (ep.getuint2 (), ep) != ES_NORMAL)
4191+ {
4192+ MCeerror->add (EE_PARAM_BADINDEX, line, pos, ep.getsvalue ());
4193+ return ES_ERROR;
4194+ }
4195+ }
4196+ else
4197+ {
4198+ ep.clear ();
41734199 }
41744200 return ES_NORMAL;
41754201#endif /* MCParam */
41764202}
41774203
41784204Parse_stat MCParamCount::parse (MCScriptPoint &sp, Boolean the)
41794205{
4180- h = sp.gethandler ();
41814206 return MCFunction::parse (sp, the);
41824207}
41834208
41844209Exec_stat MCParamCount::eval (MCExecPoint &ep)
41854210{
41864211#ifdef /* MCParamCount */ LEGACY_EXEC
4187- uint2 count;
4188- // PM-2014-04-14: [[Bug 12105]] Do this check to prevent crash in LC server
4189- if (h == NULL )
4190- {
4191- MCeerror->add (EE_PARAMCOUNT_NOHANDLER, line, pos);
4192- return ES_ERROR;
4193- }
4194- h->getnparams (count);
4195- ep.setnvalue (count);
4212+ // MW-2013-11-15: [[ Bug 11277 ]] If we don't have a handler then 'the param'
4213+ // makes no sense so just return 0.
4214+ if (ep.gethandler () != nil)
4215+ {
4216+ uint2 count;
4217+ ep.gethandler ()->getnparams (count);
4218+ ep.setnvalue (count);
4219+ }
4220+ else
4221+ {
4222+ ep.setnvalue (0 );
4223+ }
4224+
41964225 return ES_NORMAL;
41974226#endif /* MCParamCount */
41984227}
41994228
42004229Parse_stat MCParams::parse (MCScriptPoint &sp, Boolean the)
42014230{
4202- h = sp.gethandler ();
42034231 return MCFunction::parse (sp, the);
42044232}
42054233
42064234Exec_stat MCParams::eval (MCExecPoint &ep)
42074235{
42084236#ifdef /* MCParams */ LEGACY_EXEC
4237+ // MW-2013-11-15: [[ Bug 11277 ]] If we don't have a handler then 'the param'
4238+ // makes no sense so just return empty.
4239+ if (ep.gethandler () == nil)
4240+ {
4241+ ep . clear ();
4242+ return ES_NORMAL;
4243+ }
4244+
4245+ MCHandler *h;
4246+ h = ep.gethandler ();
4247+
42094248 ep . setnameref_unsafe (h -> getname ());
42104249 ep . appendchar (h -> gettype () == HT_FUNCTION ? ' (' : ' ' );
42114250
@@ -5431,7 +5470,6 @@ MCValue::~MCValue()
54315470
54325471Parse_stat MCValue::parse (MCScriptPoint &sp, Boolean the)
54335472{
5434- h = sp.gethandler ();
54355473 if (the)
54365474 {
54375475 if (get1param (sp, &source, the) != PS_NORMAL)
@@ -5543,26 +5581,44 @@ Exec_stat MCValue::eval(MCExecPoint &ep)
55435581 delete tptr;
55445582 }
55455583 else
5546- if (h->eval (ep) != ES_NORMAL)
5584+ {
5585+ Exec_stat t_stat;
5586+ if (ep . gethandler () != nil)
5587+ t_stat = ep . gethandler () -> eval (ep);
5588+ else
5589+ t_stat = ep . gethlist () -> eval (ep);
5590+
5591+ if (t_stat != ES_NORMAL)
55475592 {
55485593 MCeerror->add
55495594 (EE_VALUE_ERROR, line, pos, ep.getsvalue ());
55505595 return ES_ERROR;
55515596 }
5597+ }
55525598 return ES_NORMAL;
55535599#endif /* MCValue */
55545600}
55555601
55565602Parse_stat MCVariables::parse (MCScriptPoint &sp, Boolean the)
55575603{
5558- h = sp.gethandler ();
55595604 return MCFunction::parse (sp, the);
55605605}
55615606
55625607Exec_stat MCVariables::eval (MCExecPoint &ep)
55635608{
55645609#ifdef /* MCVariables */ LEGACY_EXEC
5565- return h->getvarnames (ep, True);
5610+ // MW-2013-11-15: [[ Bug 11277 ]] If no handler, then process the handler list
5611+ // (server script scope).
5612+ if (ep . gethandler () != nil)
5613+ return ep.gethandler ()->getvarnames (ep, True);
5614+ else
5615+ {
5616+ ep.clear ();
5617+ ep.gethlist () -> appendlocalnames (ep);
5618+ ep.appendnewline ();
5619+ ep.gethlist () -> appendglobalnames (ep, True);
5620+ }
5621+ return ES_NORMAL;
55665622#endif /* MCVariables */
55675623}
55685624
0 commit comments