~ubuntu-branches/ubuntu/precise/lilypond/precise

« back to all changes in this revision

Viewing changes to lily/keyword.cc

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2006-12-19 10:18:12 UTC
  • mfrom: (3.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061219101812-7awtjkp0i393wxty
Tags: 2.8.7-3
scripts/midi2ly.py: When setting DATADIR, find Lilypond python files
in the @TOPLEVEL_VERSION@ directory, not 'current'.  Patch thanks to
Chris Lamb (chris@chris-lamb.co.uk).  (Closes: #400550)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
  keyword.cc -- keywords and identifiers
3
 
 */
4
 
#include <string.h>
5
 
#include <stdlib.h>
 
3
*/
 
4
 
6
5
#include "keyword.hh"
7
6
 
 
7
#include <cstring>
 
8
#include <cstdlib>
 
9
using namespace std;
8
10
 
9
11
/* for qsort */
10
 
int tabcmp (Keyword_ent  const &p1, Keyword_ent const &p2)
 
12
int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2)
11
13
{
12
14
  return strcmp (p1.name_, p2.name_);
13
15
}
15
17
Keyword_table::Keyword_table (Keyword_ent *tab)
16
18
{
17
19
  while (tab->name_)
18
 
    {
19
 
      table_.push (*tab++);
20
 
    }
 
20
    table_.push_back (*tab++);
21
21
 
22
 
  table_.sort (tabcmp);
 
22
  vector_sort (table_, tabcmp);
23
23
}
24
24
 
25
 
int
 
25
vsize
26
26
Keyword_table::lookup (char const *s) const
27
27
{
28
 
  Keyword_ent e ;
29
 
  e.name_ =  s;
30
 
  int idx = binary_search (table_, e, tabcmp);
31
 
  if (idx >= 0)
 
28
  Keyword_ent e;
 
29
  e.name_ = s;
 
30
  vsize idx = binary_search (table_, e, tabcmp);
 
31
  if (idx != VPOS)
32
32
    return table_[idx].tokcode_;
33
 
  else
34
 
    return -1;
 
33
  return VPOS;
35
34
}