--- parser3/src/classes/op.C 2002/05/07 07:39:17 1.95 +++ parser3/src/classes/op.C 2002/08/08 09:35:22 1.101 @@ -3,10 +3,10 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - - $Id: op.C,v 1.95 2002/05/07 07:39:17 paf Exp $ */ +static const char* IDENT_OP_C="$Date: 2002/08/08 09:35:22 $"; + #include "classes.h" #include "pa_common.h" #include "pa_request.h" @@ -100,22 +100,7 @@ static void _taint(Request& r, const Str } static void _process(Request& r, const String& method_name, MethodParams *params) { - // calculate pseudo file name of processed chars - // would be something like "/some/file(4) process" - char local_place[MAX_STRING]; -#ifndef NO_STRING_ORIGIN - const Origin& origin=method_name.origin(); - size_t place_size=snprintf(local_place, MAX_STRING, "%s(%d) %s", - origin.file?origin.file:"unknown_file", 1+origin.line, - method_name.cstr())+1; -#else - strncpy(local_place, method_name.cstr(), MAX_STRING-1); place[MAX_STRING-1]=0; - size_t place_size=strlen(local_place)+1; -#endif - char *heap_place=(char *)r.malloc(place_size); - memcpy(heap_place, local_place, place_size); - - + Pool& pool=r.pool(); VStateless_class& self_class=*r.self->get_class(); const Method *main_method; { @@ -128,11 +113,32 @@ static void _process(Request& r, const S // evaluate source to process const String& source=r.process_to_string(params->as_junction(0, "body must be code")); + // calculate pseudo file name of processed chars + // would be something like "/some/file(4) process" + char local_place[MAX_STRING]; +#ifndef NO_STRING_ORIGIN + const Origin& source_origin=source.origin(); + const Origin& method_origin=method_name.origin(); + size_t place_size; + if(source_origin.file==method_origin.file) + place_size=snprintf(local_place, MAX_STRING, "%s(%d) %s", // same file + source_origin.file?source_origin.file:"unknown_file", 1+source_origin.line, + method_name.cstr())+1; + else // different files ^process{external__file_text__or__sql} + place_size=snprintf(local_place, MAX_STRING, "%s", + source_origin.file?source_origin.file:"unknown_file")+1; +#else + strncpy(local_place, method_name.cstr(), MAX_STRING-1); place[MAX_STRING-1]=0; + size_t place_size=strlen(local_place)+1; +#endif + char *heap_place=(char *)r.malloc(place_size); + memcpy(heap_place, local_place, place_size); // process source code, append processed methods to 'self' class // 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); @@ -400,8 +406,10 @@ 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; - if(data.expires==0) + false/*block*/, + false/*fail on lock problem*/) ? info.evaluated_body: 0; + time_t now=time(0); + if(data.expires<=now) cache_delete(file_spec); return result; } @@ -629,7 +637,7 @@ static void _throw_operator(Request& r, 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->size()>2?params->as_string(2, "comment must be string").cstr():0; - throw Exception(type, &source, "%s", comment); + throw Exception(type, &source, "%s", comment?comment:""); } }