Diff for /parser3/src/classes/string.C between versions 1.63 and 1.65

version 1.63, 2001/07/18 10:06:04 version 1.65, 2001/07/23 11:19:25
Line 214  static void _match(Request& r, const Str Line 214  static void _match(Request& r, const Str
         Temp_lang temp_lang(r, String::UL_PASS_APPENDED);          Temp_lang temp_lang(r, String::UL_PASS_APPENDED);
         Table *table;          Table *table;
         if(params->size()<3) { // search          if(params->size()<3) { // search
                   bool was_global;
                 bool matched=src.match(r.pcre_tables,                  bool matched=src.match(r.pcre_tables,
                         &method_name,                           &method_name, 
                         regexp.as_string(), options,                          regexp.as_string(), options,
                         &table,                          &table,
                         search_action, 0);                          search_action, 0,
                           &was_global);
                 // matched                  // matched
                 if(table->columns()->size()==3 && // just matched[3=pre/match/post], no substrings                  // not (just matched[3=pre/match/post], no substrings) or Global search
                         table->size()<=1)  // just one row, not /g_lobal search                  if(table->columns()->size()>3 || was_global) 
                         result=new(pool) VBool(pool, matched);                          result=new(pool) VTable(pool, table); // table of pre/match/post+substrings
                 else // table of pre/match/post+substrings                  else 
                         result=new(pool) VTable(pool, table);                          result=new(pool) VBool(pool, matched);                  
         } else { // replace          } else { // replace
                 Value& replacement_code=params->as_junction(2, "replacement code must be code");                  Value& replacement_code=params->as_junction(2, "replacement code must be code");
   
Line 261  static void _lower(Request& r, const Str Line 263  static void _lower(Request& r, const Str
         change_case(r, method_name, params, String::CC_LOWER);          change_case(r, method_name, params, String::CC_LOWER);
 }  }
   
   #ifndef DOXYGEN
   class String_sql_event_handlers : public SQL_Driver_query_event_handlers {
   public:
           String_sql_event_handlers(Pool& apool, 
                   const String& astatement_string, const char *astatement_cstr) :
                   pool(apool), 
                   statement_string(astatement_string),
                   statement_cstr(astatement_cstr),
                   got_column(false), got_cell(false) {
                   result=new(pool) String(pool);
           }
   
           void add_column(void *ptr, size_t size) {
                   if(got_column)
                           PTHROW(0, 0,
                                   &statement_string,
                                   "result must contain exactly one column");
                   got_column=true;
           }
           void before_rows() { /* ignore */ }
           void add_row() { /* ignore */ }
           void add_row_cell(void *ptr, size_t size) {
                   if(got_cell)
                           PTHROW(0, 0,
                                   &statement_string,
                                   "result must not contain more then one row");
                   got_cell=true;
   
                   result->APPEND_TAINTED((const char *)ptr, size, statement_cstr, 0);
           }
   
   private:
           Pool& pool;
           const String& statement_string; const char *statement_cstr;
           bool got_column;
   public:
           bool got_cell;
           String *result;
   };
   #endif
 const String* sql_result_string(Request& r, const String& method_name, MethodParams *params) {  const String* sql_result_string(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
   
Line 277  const String* sql_result_string(Request& Line 319  const String* sql_result_string(Request&
         const String& statement_string=r.process(statement).as_string();          const String& statement_string=r.process(statement).as_string();
         const char *statement_cstr=          const char *statement_cstr=
                 statement_string.cstr(String::UL_UNSPECIFIED, r.connection);                  statement_string.cstr(String::UL_UNSPECIFIED, r.connection);
         unsigned int sql_column_count; SQL_Driver::Cell *sql_columns;          String_sql_event_handlers handlers(pool, statement_string, statement_cstr);
         unsigned long sql_row_count; SQL_Driver::Cell **sql_rows;  
         bool need_rethrow=false; Exception rethrow_me;          bool need_rethrow=false; Exception rethrow_me;
         PTRY {          PTRY {
                 r.connection->query(                  r.connection->query(
                         statement_cstr, offset, 0,                          statement_cstr, offset, 0,
                         &sql_column_count, &sql_columns,                          handlers);
                         &sql_row_count, &sql_rows);  
         }          }
         PCATCH(e) { // query problem          PCATCH(e) { // query problem
                 rethrow_me=e;  need_rethrow=true;                  rethrow_me=e;  need_rethrow=true;
Line 295  const String* sql_result_string(Request& Line 335  const String* sql_result_string(Request&
                         &statement_string, // setting more specific source [were url]                          &statement_string, // setting more specific source [were url]
                         rethrow_me.comment());                          rethrow_me.comment());
                   
         if(sql_column_count!=1)          if(!handlers.got_cell)
                 PTHROW(0, 0,                  return 0; // no lines, caller should return second param[default value]
                         &statement_string,  
                         "result must contain exactly one column");  
   
         if(!sql_row_count)  
                 return 0; // no lines, should return second param[default value]  
   
         if(sql_row_count>1)          return handlers.result;
                 PTHROW(0, 0,  
                         &statement_string,  
                         "result must not contain more then one row");     
   
         String *result=new(pool) String(pool);  
         SQL_Driver::Cell& cell=sql_rows[0][0];  
         result->APPEND_TAINTED(  
                 (const char *)cell.ptr, cell.size,  
                 statement_cstr, 0);  
           
         return result;  
 }  }
   
 static void _sql(Request& r, const String& method_name, MethodParams *params) {  static void _sql(Request& r, const String& method_name, MethodParams *params) {

Removed from v.1.63  
changed lines
  Added in v.1.65


E-mail: