--- parser3/src/classes/file.C 2008/07/03 09:36:16 1.173 +++ parser3/src/classes/file.C 2008/09/04 09:37:35 1.179 @@ -5,12 +5,10 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_FILE_C="$Date: 2008/07/03 09:36:16 $"; +static const char * const IDENT_FILE_C="$Date: 2008/09/04 09:37:35 $"; #include "pa_config_includes.h" -#include "pcre.h" - #include "classes.h" #include "pa_vmethod_frame.h" @@ -167,7 +165,7 @@ static void copy_process_source( nCount = file_block_read(from_file, buffer, sizeof(buffer)); int written=write(to_file, buffer, nCount); if( written < 0 ) - throw Exception(0, + throw Exception("file.access", 0, "write failed: %s (%d)", strerror(errno), errno); @@ -543,7 +541,7 @@ static void _exec_cgi(Request& r, Method break; default: // 00 unix_header_break=false; // calm down, compiler - throw Exception(0, + throw Exception("file.execute", 0, "output does not contain CGI header; " "exit status=%d; stdoutsize=%u; stdout: \"%s\"; stderrsize=%u; stderr: \"%s\"", @@ -616,15 +614,19 @@ static void _list(Request& r, MethodPara if(params.count()>1) { regexp=¶ms.as_no_junction(1, "regexp must not be code").as_string(); - const char* pattern=regexp->cstr(); + const char* pattern=regexp->cstr(String::L_UNSPECIFIED); const char* errptr; int erroffset; - regexp_code=pcre_compile(pattern, PCRE_EXTRA | PCRE_DOTALL, + int options=PCRE_EXTRA | PCRE_DOTALL; + if(r.charsets.source().isUTF8()) + options=options|PCRE_UTF8; + + regexp_code=pcre_compile(pattern, options, &errptr, &erroffset, r.charsets.source().pcre_tables); if(!regexp_code) - throw Exception(0, + throw Exception(PCRE_EXCEPTION_TYPE, ®exp->mid(erroffset, regexp->length()), "regular expression syntax error - %s", errptr); } else { @@ -652,9 +654,9 @@ static void _list(Request& r, MethodPara suits=false; else if(exec_result<0) { (*pcre_free)(regexp_code); - throw Exception(0, - regexp, - "regular expression execute (%d)", + throw Exception(PCRE_EXCEPTION_TYPE, + regexp, + print_pcre_exec_error_text(exec_result), exec_result); } }