--- parser3/src/main/pa_dictionary.C 2001/08/28 09:27:42 1.4 +++ parser3/src/main/pa_dictionary.C 2001/10/05 16:12:40 1.7 @@ -2,15 +2,15 @@ Parser: dictionary class impl. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + + $Id: pa_dictionary.C,v 1.7 2001/10/05 16:12:40 parser Exp $ */ -static const char *RCSId="$Id: pa_dictionary.C,v 1.4 2001/08/28 09:27:42 parser Exp $"; #include "pa_dictionary.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(info); Array *row=static_cast(value); // get a=>b values @@ -27,7 +27,7 @@ static void add_first(Array::Item *value if(!self.starting_line_of[c]) 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) self.fmax_ratio=ratio; @@ -47,7 +47,7 @@ Dictionary::Dictionary(Table& atable, do #ifndef DOXYGEN struct First_that_starts_info { int line; - const char *src; + const char *src; size_t src_size; }; #endif static void *starts(Array::Item *value, void *info) { @@ -60,17 +60,18 @@ static void *starts(Array::Item *value, Array *row=static_cast(value); int partial; - row->get_string(0)->cmp(partial, i.src); + row->get_string(0)->cmp(partial, i.src, i.src_size); return ( partial==0 || // full match partial==1) // typo left column starts 'src' ?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; if(info.line=starting_line_of[(unsigned char)*src]) { info.src=src; + info.src_size=src_size; return table.first_that(starts, &info); } else return 0;