Diff for /parser3/src/main/pa_dictionary.C between versions 1.4 and 1.8

version 1.4, 2001/08/28 09:27:42 version 1.8, 2001/10/19 12:43:30
Line 2 Line 2
         Parser: dictionary class  impl.          Parser: dictionary class  impl.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
   
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
   
           $Id$
 */  */
 static const char *RCSId="$Id$";   
   
 #include "pa_dictionary.h"  #include "pa_dictionary.h"
 #include "pa_exception.h"  #include "pa_exception.h"
   
 static void add_first(Array::Item *value, void *info) {  void Dictionary::add_first(Array::Item *value, void *info) {
         Dictionary& self=*static_cast<Dictionary *>(info);          Dictionary& self=*static_cast<Dictionary *>(info);
         Array *row=static_cast<Array *>(value);          Array *row=static_cast<Array *>(value);
         // get a=>b values          // get a=>b values
Line 19  static void add_first(Array::Item *value Line 19  static void add_first(Array::Item *value
         // empty 'a' check          // empty 'a' check
         if(a.size()==0) {          if(a.size()==0) {
                 Pool& pool=self.pool();                  Pool& pool=self.pool();
                 PTHROW(0, 0,                   throw Exception(0, 0, 
                         &a,                           &a, 
                         "dictionary table 'from' column elements must not be empty");                          "dictionary table 'from' column elements must not be empty");
         }          }
Line 27  static void add_first(Array::Item *value Line 27  static void add_first(Array::Item *value
         if(!self.starting_line_of[c])          if(!self.starting_line_of[c])
                 self.starting_line_of[c]=self.constructor_line;                  self.starting_line_of[c]=self.constructor_line;
   
         double ratio=b.size()/a.size();          double ratio=((double)b.size())/a.size();
         if(ratio>self.fmax_ratio)          if(ratio>self.fmax_ratio)
                 self.fmax_ratio=ratio;                  self.fmax_ratio=ratio;
   
Line 47  Dictionary::Dictionary(Table& atable, do Line 47  Dictionary::Dictionary(Table& atable, do
 #ifndef DOXYGEN  #ifndef DOXYGEN
 struct First_that_starts_info {  struct First_that_starts_info {
         int line;          int line;
         const char *src;          const char *src;  size_t src_size;
 };  };
 #endif  #endif
 static void *starts(Array::Item *value, void *info) {  static void *starts(Array::Item *value, void *info) {
Line 60  static void *starts(Array::Item *value, Line 60  static void *starts(Array::Item *value,
         Array *row=static_cast<Array *>(value);          Array *row=static_cast<Array *>(value);
   
         int partial;          int partial;
         row->get_string(0)->cmp(partial, i.src);          row->get_string(0)->cmp(partial, i.src, i.src_size);
         return (          return (
                 partial==0 || // full match                  partial==0 || // full match
                 partial==1) // typo left column starts 'src'                  partial==1) // typo left column starts 'src'
                 ?value:0;                  ?value:0;
 }  }
   
 void* Dictionary::first_that_starts(const char *src) const {  void* Dictionary::first_that_starts(const char *src, size_t src_size) const {
         First_that_starts_info info;          First_that_starts_info info;
         if(info.line=starting_line_of[(unsigned char)*src]) {          if(info.line=starting_line_of[(unsigned char)*src]) {
                 info.src=src;                  info.src=src;
                   info.src_size=src_size;
                 return table.first_that(starts, &info);                  return table.first_that(starts, &info);
         } else          } else
                 return 0;                  return 0;

Removed from v.1.4  
changed lines
  Added in v.1.8


E-mail: