--- parser3/src/classes/op.C 2001/10/19 12:43:29 1.53 +++ parser3/src/classes/op.C 2001/11/01 16:30:14 1.57 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: op.C,v 1.53 2001/10/19 12:43:29 parser Exp $ + $Id: op.C,v 1.57 2001/11/01 16:30:14 paf Exp $ */ #include "classes.h" @@ -176,16 +176,16 @@ static void _for(Request& r, const Strin Value& body_code=params->as_junction(3, "body must be code"); Value *delim_maybe_code=params->size()>4?¶ms->get(4):0; + if(to-from>=MAX_LOOPS) // too long loop? + throw Exception(0, 0, + &method_name, + "endless loop detected"); + bool need_delim=false; VInt *vint=new(pool) VInt(pool, 0); - int endless_loop_count=0; for(int i=from; i<=to; i++) { - if(++endless_loop_count>=MAX_LOOPS) // endless loop? - throw Exception(0, 0, - &method_name, - "endless loop detected"); vint->set_int(i); - r.self/*root*/->put_element(var_name, vint); + r.root->put_element(var_name, vint); Value& processed_body=r.process(body_code); if(delim_maybe_code) { // delimiter set? @@ -353,7 +353,7 @@ MOP::MOP(Pool& apool) : Methoded(apool), // ^use[file] add_native_method("use", Method::CT_ANY, _use, 1, 1); - // ^for[i;from-number;to-number-inclusive]{code}[delim] + // ^for[i](from-number;to-number-inclusive){code}[delim] add_native_method("for", Method::CT_ANY, _for, 3+1, 3+1+1); // ^eval(expr)