X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fkeyword.cc;h=b5f7947ada203e31550ee041a557f37f439b115c;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=de6aca9e495cd7a6c6496384a0c3d7e2d6b377ca;hpb=528e7b6840aa4bd8e23f69c3f6842b124cee26ae;p=lilypond.git diff --git a/lily/keyword.cc b/lily/keyword.cc index de6aca9e49..b5f7947ada 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -1,35 +1,34 @@ /* keyword.cc -- keywords and identifiers - */ -#include -#include +*/ + #include "keyword.hh" +#include +#include +using namespace std; /* for qsort */ -int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2) +bool tab_less (Keyword_ent const &p1, Keyword_ent const &p2) { - return strcmp (p1.name_, p2.name_); + return strcmp (p1.name_, p2.name_) < 0; } Keyword_table::Keyword_table (Keyword_ent *tab) { while (tab->name_) - { - table_.push (*tab++); - } + table_.push_back (*tab++); - table_.sort (tabcmp); + vector_sort (table_, tab_less); } -int +vsize Keyword_table::lookup (char const *s) const { - Keyword_ent e ; - e.name_ = s; - int idx = binary_search (table_, e, tabcmp); - if (idx >= 0) + Keyword_ent e; + e.name_ = s; + vsize idx = binary_search (table_, e, tab_less); + if (idx != VPOS) return table_[idx].tokcode_; - else - return -1; + return VPOS; }