source: abuse/trunk/src/ltree.cpp @ 32

Last change on this file since 32 was 2, checked in by Sam Hocevar, 17 years ago
  • imported original 0.7.0 tarball
File size: 875 bytes
Line 
1
2lisp_symbol *find_symbol(char *name)
3{
4  lisp_symbol *p=lsym_root;
5  while (p)
6  {
7    int cmp=strcmp(name,((char *)((lisp_symbol *)cs->car)->name)+sizeof(lisp_string));
8    if (cmp==0) return p;
9    else if (cmp<0) p=p->left;
10    else p=p->right;
11  }
12  return NULL;
13}
14
15
16
17lisp_symbol *make_find_symbol(char *name)
18{
19  lisp_symbol *p=lsym_root;
20  lisp_symbol **parent=&lsym_root;
21  while (p)
22  {
23    int cmp=strcmp(name,((char *)((lisp_symbol *)cs->car)->name)+sizeof(lisp_string));
24    if (cmp==0) return p;
25    else if (cmp<0)
26    {
27      parent=&p->left;
28      p=p->left;
29    }
30    else
31    {
32      parent=&p->right;
33      p=p->right;
34    }
35  }
36
37  p=jmalloc(sizeof(lisp_symbol),"lsymbol");
38  p->type=L_SYMBOL;
39  p->name=new_lisp_string(name);
40  p->value=l_undefined;
41  p->function=l_undefined;
42  p->call_counter=0;
43  p->left=p->right=NULL;
44  *parent=p;
45  return p;
46}
47
48
Note: See TracBrowser for help on using the repository browser.