|
|
| version 1.25, 2001/04/03 09:58:07 | version 1.26, 2001/04/03 14:38:58 |
|---|---|
| Line 145 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; | Table *table; |
| Value *result; | Value *result; |
| if(string.match(&method_name, | if(string.match(&method_name, |
| r.process(regexp).as_string(), options.as_string(), | r.process(regexp).as_string(), options, |
| &table)) { | &table)) { |
| // matched | // matched |
| if(table->columns()->size()==1) // just matched, no substrings | 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); | result=new(pool) VBool(pool, true); |
| else // table of match column+substring columns | else // table of match column+substring columns |
| result=new(pool) VTable(pool, table); | result=new(pool) VTable(pool, table); |
| } else // not matched | } else // not global & not matched |
| result=new(pool) VBool(pool, false); | result=new(pool) VBool(pool, false); |
| result->set_name(method_name); | |
| r.write_no_lang(*result); | r.write_no_lang(*result); |
| } | } |
| Line 197 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); |
| } | } |