--- parser3/src/classes/op.C 2002/04/18 10:51:00 1.91 +++ parser3/src/classes/op.C 2002/06/20 14:50:22 1.97 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: op.C,v 1.91 2002/04/18 10:51:00 paf Exp $ + $Id: op.C,v 1.97 2002/06/20 14:50:22 paf Exp $ */ #include "classes.h" @@ -100,6 +100,7 @@ static void _taint(Request& r, const Str } static void _process(Request& r, const String& method_name, MethodParams *params) { + Pool& pool=r.pool(); // calculate pseudo file name of processed chars // would be something like "/some/file(4) process" char local_place[MAX_STRING]; @@ -122,7 +123,7 @@ static void _process(Request& r, const S // temporary remove language change Temp_lang temp_lang(r, String::UL_PASS_APPENDED); // temporary zero @main so to maybe-replace it in processed code - Temp_method temp_method_main(self_class, *main_method_name, 0); + Temp_method temp_method_main(self_class, r.main_method_name, 0); // temporary zero @auto so it wouldn't be auto-called in Request::use_buf Temp_method temp_method_auto(self_class, *auto_method_name, 0); @@ -133,11 +134,12 @@ static void _process(Request& r, const S // maybe-define new @main r.use_buf( source.cstr(String::UL_UNSPECIFIED, r.connection(0)), + *new(pool) String(pool, heap_place, place_size, true /*tainted*/), heap_place, &self_class); // main_method - main_method=self_class.get_method(*main_method_name); + main_method=self_class.get_method(r.main_method_name); } // after restoring current-request-lang // maybe-execute @main[] @@ -196,9 +198,9 @@ static void _for(Request& r, const Strin bool need_delim=false; VInt *vint=new(pool) VInt(pool, 0); + r.root->put_element(var_name, vint); for(int i=from; i<=to; i++) { vint->set_int(i); - r.root->put_element(var_name, vint); StringOrValue processed_body=r.process(body_code); if(delim_maybe_code) { // delimiter set? @@ -400,7 +402,8 @@ const String *locked_process_and_cache_p "cache_put", locked_process_and_cache_put_action, &info, false/*as_text*/, false/*do_append*/, - false/*block*/) ? info.evaluated_body: 0; + false/*block*/, + false/*fail on lock problem*/) ? info.evaluated_body: 0; if(data.expires==0) cache_delete(file_spec); return result; @@ -533,7 +536,7 @@ static void _cache(Request& r, const Str VHash& exception2vhash(Pool& pool, const Exception& e) { VHash& result=*new(pool) VHash(pool); Hash& hash=result.hash(0); - if(const char *type=e.type()) + if(const char *type=e.type(true)) hash.put(*exception_type_part_name, new(pool) VString(*new(pool) String(pool, type))); if(const String *asource=e.problem_source()) { String& source=*new(pool) String(pool); @@ -548,7 +551,7 @@ VHash& exception2vhash(Pool& pool, const new(pool) VInt(pool, 1+origin.line)); #endif } - if(const char *ecomment=e.comment()) { + if(const char *ecomment=e.comment(true)) { int comment_size=strlen(ecomment); char *pcomment=(char *)pool.malloc(comment_size); memcpy(pcomment, ecomment, comment_size); @@ -628,8 +631,8 @@ static void _throw_operator(Request& r, } else { const char *type=params->as_string(0, "type must be string").cstr(); const String& source=params->as_string(1, "source must be string"); - const char *comment=params->as_string(2, "comment must be string").cstr(); - throw Exception(type, &source, comment); + const char *comment=params->size()>2?params->as_string(2, "comment must be string").cstr():0; + throw Exception(type, &source, "%s", comment?comment:""); } }