--- parser3/src/classes/op.C 2013/10/04 21:21:54 1.217 +++ parser3/src/classes/op.C 2015/10/09 11:42:38 1.223 @@ -18,7 +18,7 @@ #include "pa_vclass.h" #include "pa_charset.h" -volatile const char * IDENT_OP_C="$Id: op.C,v 1.217 2013/10/04 21:21:54 moko Exp $"; +volatile const char * IDENT_OP_C="$Id: op.C,v 1.223 2015/10/09 11:42:38 moko Exp $"; // limits @@ -61,8 +61,7 @@ static const String exception_var_name(E class Untaint_lang_name2enum: public HashString { public: Untaint_lang_name2enum() { - #define ULN(name, LANG) \ - put(String::Body(name), (value_type)(String::L_##LANG)); + #define ULN(name, LANG) put(name, (value_type)(String::L_##LANG)); ULN("clean", CLEAN); ULN("as-is", AS_IS); ULN("optimized-as-is", AS_IS|String::L_OPTIMIZE_BIT); @@ -357,7 +356,7 @@ static void _for(Request& r, MethodParam VInt* vint=new VInt(0); VMethodFrame& caller=*r.get_method_frame()->caller(); - caller.put_element(var_name, vint); + r.put_element(caller, var_name, vint); if(delim_maybe_code){ // delimiter set bool need_delim=false; @@ -585,6 +584,10 @@ static Try_catch_result try_catch(Reques return result; } +static StringOrValue process_try_body_code(Request& r, Value* body_code) { + return r.process(*body_code); +} + // cache-- // consts @@ -646,8 +649,8 @@ static void locked_process_and_cache_put } else throw Exception(PARSER_RUNTIME, result.exception_should_be_handled, - "$"EXCEPTION_VAR_NAME"."EXCEPTION_HANDLED_PART_NAME" value must be " - "either boolean or string '"CACHE_EXCEPTION_HANDLED_CACHE_NAME"'"); + "$" EXCEPTION_VAR_NAME "." EXCEPTION_HANDLED_PART_NAME " value must be " + "either boolean or string '" CACHE_EXCEPTION_HANDLED_CACHE_NAME "'"); } else info.processed_code=&result.processed_code.as_string(); @@ -725,7 +728,7 @@ static time_t as_expires(Request& r, Met int index, time_t now) { time_t result; if(Value* vdate=params[index].as(VDATE_TYPE)) - result=static_cast(vdate)->get_time(); + result=(time_t)(static_cast(vdate)->get_time()); else result=now+(time_t)params.as_double(index, "lifespan must be date or number", r); @@ -739,10 +742,8 @@ static void _cache(Request& r, MethodPar // ^cache[] -- return current expiration time Cache_scope* scope=static_cast(r.classes_conf.get(cache_data_name)); if(!scope) - throw Exception(PARSER_RUNTIME, - 0, - "expire-time get without cache"); - r.write_no_lang(*new VDate(scope->expires)); + throw Exception(PARSER_RUNTIME, 0, "expire-time get without cache"); + r.write_no_lang(*new VDate((pa_time_t)scope->expires)); return; } @@ -814,15 +815,16 @@ static void _cache(Request& r, MethodPar cache_delete(file_spec); } - // process without cacheing - const String& processed_body=r.process_to_string(body_code); - // write it out - r.write_assign_lang(processed_body); + // process without caching + if(catch_code){ + Try_catch_result result=try_catch(r, process_try_body_code, &body_code, catch_code); + r.write_assign_lang(result.processed_code); + } else { + const String& processed_body=r.process_to_string(body_code); + r.write_assign_lang(processed_body); + } } -static StringOrValue process_try_body_code(Request& r, Value* body_code) { - return r.process(*body_code); -} static void _try_operator(Request& r, MethodParams& params) { Value& body_code=params.as_junction(0, "body_code must be code"); Value& catch_code=params.as_junction(1, "catch_code must be code"); @@ -831,13 +833,7 @@ static void _try_operator(Request& r, Me Try_catch_result result; StringOrValue finally_result; try{ - result=try_catch(r, - process_try_body_code, &body_code, - &catch_code); - if(result.exception_should_be_handled) - throw Exception(PARSER_RUNTIME, - result.exception_should_be_handled, - "catch block must set $exception.handled to some boolean value, not string"); + result=try_catch(r, process_try_body_code, &body_code, &catch_code); } catch(...){ if(finally_code) finally_result=r.process(*finally_code);