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

Last change on this file since 482 was 482, checked in by Sam Hocevar, 7 years ago

lisp: make all lisp object inherit a common type.

File size: 1.1 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12LispSymbol *find_symbol(char *name)
13{
14  LispSymbol *p=lsym_root;
15  while (p)
16  {
17    int cmp=strcmp(name,((char *)((LispSymbol *)cs->car)->name)+sizeof(LispString));
18    if (cmp==0) return p;
19    else if (cmp<0) p=p->left;
20    else p=p->right;
21  }
22  return NULL;
23}
24
25
26
27LispSymbol *make_find_symbol(char *name)
28{
29  LispSymbol *p=lsym_root;
30  LispSymbol **parent=&lsym_root;
31  while (p)
32  {
33    int cmp=strcmp(name,((char *)((LispSymbol *)cs->car)->name)+sizeof(LispString));
34    if (cmp==0) return p;
35    else if (cmp<0)
36    {
37      parent=&p->left;
38      p=p->left;
39    }
40    else
41    {
42      parent=&p->right;
43      p=p->right;
44    }
45  }
46
47  p=malloc(sizeof(LispSymbol));
48  p->type=L_SYMBOL;
49  p->name=new_lisp_string(name);
50  p->value=l_undefined;
51  p->function=l_undefined;
52  p->call_counter=0;
53  p->left=p->right=NULL;
54  *parent=p;
55  return p;
56}
57
58
Note: See TracBrowser for help on using the repository browser.