|
|
| version 1.24, 2001/04/03 08:23:06 | version 1.26, 2001/04/03 14:38:58 |
|---|---|
| Line 13 | Line 13 |
| #include "pa_vdouble.h" | #include "pa_vdouble.h" |
| #include "pa_vint.h" | #include "pa_vint.h" |
| #include "pa_vtable.h" | #include "pa_vtable.h" |
| #include "pa_vbool.h" | |
| // global var | // global var |
| Line 144 static void _match(Request& r, const Str | Line 145 static void _match(Request& r, const Str |
| // forcing {this param type} | // forcing {this param type} |
| r.fail_if_junction_(false, regexp, method_name, "regexp must be junction"); | r.fail_if_junction_(false, regexp, method_name, "regexp must be junction"); |
| Value& options=*static_cast<Value *>(params->get(1)); | const String *options=0; |
| // forcing {this param type} | if(params->size()>1) { |
| r.fail_if_junction_(true, options, method_name, "options must not be junction"); | Value& value=*static_cast<Value *>(params->get(1)); |
| // forcing {this param type} | |
| r.fail_if_junction_(true, value, method_name, "options must not be junction"); | |
| options=&value.as_string(); | |
| } | |
| Temp_lang temp_lang(r, String::UL_PASS_APPENDED); | Temp_lang temp_lang(r, String::UL_PASS_APPENDED); |
| Table& table=string.match(&method_name, | Table *table; |
| r.process(regexp).as_string(), options.as_string()); | Value *result; |
| if(string.match(&method_name, | |
| r.process(regexp).as_string(), options, | |
| &table)) { | |
| // matched | |
| if(table->columns()->size()==3 && // just matched[3=pre/match/post], no substrings | |
| table->size()==1) // just one row, not Global search | |
| result=new(pool) VBool(pool, true); | |
| else // table of match column+substring columns | |
| result=new(pool) VTable(pool, table); | |
| } else // not global & not matched | |
| result=new(pool) VBool(pool, false); | |
| r.write_no_lang(*new(pool) VTable(pool, &table)); | result->set_name(method_name); |
| r.write_no_lang(*result); | |
| } | } |
| // initialize | // initialize |
| Line 186 void initialize_string_class(Pool& pool, | Line 203 void initialize_string_class(Pool& pool, |
| vclass.add_native_method("rsplit", Method::CT_DYNAMIC, _rsplit, 1, 1); | vclass.add_native_method("rsplit", Method::CT_DYNAMIC, _rsplit, 1, 1); |
| // ^string.match{regexp}[options] | // ^string.match{regexp}[options] |
| vclass.add_native_method("match", Method::CT_DYNAMIC, _match, 2, 2); | vclass.add_native_method("match", Method::CT_DYNAMIC, _match, 1, 2); |
| } | } |