X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=blobdiff_plain;f=lily%2Fkeyword.cc;h=f027ee86d91591151fcd7622221cf948ffbab497;hb=13e79c0250d34b6bdfbafbc551ef64e8b59b2991;hp=4eec8b4f72fe843d5002f645ac4de10f4d4ee944;hpb=cf393d97985570aaf254a48785ad6eaa737ee4f0;p=lilypond.git diff --git a/lily/keyword.cc b/lily/keyword.cc index 4eec8b4f72..f027ee86d9 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -9,36 +9,36 @@ /* for the keyword table */ struct Keyword_ent { - char const *name; - int tokcode; + char const *name; + int tokcode; }; struct Keyword_table { - Keyword_ent *table; - int maxkey; - Keyword_table (Keyword_ent *); - int lookup (char const *s) const; + Keyword_ent *table; + int maxkey; + Keyword_table (Keyword_ent *); + int lookup (char const *s) const; }; /* for qsort */ int - tabcmp (void const * p1, void const * p2) + tabcmp (void const * p1, void const * p2) { - return strcmp (((Keyword_ent const *) p1)->name, - ((Keyword_ent const *) p2)->name); + return strcmp (((Keyword_ent const *) p1)->name, + ((Keyword_ent const *) p2)->name); } Keyword_table::Keyword_table (Keyword_ent *tab) { - table = tab; + table = tab; - /* count keywords */ - for (maxkey = 0; table[maxkey].name; maxkey++); + /* count keywords */ + for (maxkey = 0; table[maxkey].name; maxkey++); - /* sort them */ - qsort (table, maxkey, sizeof (Keyword_ent), tabcmp); + /* sort them */ + qsort (table, maxkey, sizeof (Keyword_ent), tabcmp); } /* @@ -47,30 +47,31 @@ Keyword_table::Keyword_table (Keyword_ent *tab) int Keyword_table::lookup (char const *s)const { - int lo, - hi, - cmp, - result; - lo = 0; - hi = maxkey; + int lo, + hi, + cmp, + result; + lo = 0; + hi = maxkey; - /* binary search */ - do - { - cmp = (lo + hi) / 2; + /* binary search */ + do + { + cmp = (lo + hi) / 2; - result = strcmp (s, table[cmp].name); + result = strcmp (s, table[cmp].name); - if (result < 0) - hi = cmp; - else - lo = cmp; + if (result < 0) + hi = cmp; + else + lo = cmp; } - while (hi - lo > 1); - if (!strcmp (s, table[lo].name)) - { - return table[lo].tokcode; - } else - return -1; /* not found */ + while (hi - lo > 1); + if (!strcmp (s, table[lo].name)) + { + return table[lo].tokcode; + } + else + return -1; /* not found */ }