--- parser3/src/classes/string.C 2004/02/27 15:24:03 1.134 +++ parser3/src/classes/string.C 2004/03/01 08:54:16 1.136 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_STRING_C="$Date: 2004/02/27 15:24:03 $"; +static const char * const IDENT_STRING_C="$Date: 2004/03/01 08:54:16 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -503,23 +503,27 @@ static void _trim(Request& r, MethodPara String::Trim_kind kind=String::TRIM_BOTH; const char* chars=0; if(params.count()>0) { - if(params.count()>1) { // [>>kind<<;chars] - const String& skind=params.as_string(0, - "'where' must be string"); - if(skind==TRIM_START_OPTION) - kind=String::TRIM_START; - else if(skind==TRIM_END_OPTION) - kind=String::TRIM_END; - else if(skind==TRIM_BOTH_OPTION) - kind=String::TRIM_BOTH; - else + const String& skind=params.as_string(0, + "'where' must be string"); + if(skind==TRIM_START_OPTION) + kind=String::TRIM_START; + else if(skind==TRIM_END_OPTION) + kind=String::TRIM_END; + else if(skind==TRIM_BOTH_OPTION) + kind=String::TRIM_BOTH; + else + throw Exception("parser.runtime", + &skind, + "'kind' should be one of "TRIM_START_OPTION", "TRIM_BOTH_OPTION", "TRIM_END_OPTION); + + if(params.count()>1) { + const String& schars=params.as_string(1, "'chars' must be string"); + if(!schars.length()) throw Exception("parser.runtime", - &skind, - "'kind' should be one of "TRIM_START_OPTION", "TRIM_BOTH_OPTION", "TRIM_END_OPTION); + 0, + "'chars' must not be empty"); + chars=schars.cstr(); } - - chars=params.as_string(params.count()-1, - "'chars' must be string").cstr(); } r.write_assign_lang(src.trim(kind, chars));