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

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

lisp: make all lisp object inherit a common type.

File size: 1.1 KB
RevLine 
[56]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 */
[2]9
[56]10#include "config.h"
11
[482]12LispSymbol *find_symbol(char *name)
[2]13{
[482]14  LispSymbol *p=lsym_root;
[2]15  while (p)
16  {
[482]17    int cmp=strcmp(name,((char *)((LispSymbol *)cs->car)->name)+sizeof(LispString));
[2]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
[482]27LispSymbol *make_find_symbol(char *name)
[2]28{
[482]29  LispSymbol *p=lsym_root;
30  LispSymbol **parent=&lsym_root;
[2]31  while (p)
32  {
[482]33    int cmp=strcmp(name,((char *)((LispSymbol *)cs->car)->name)+sizeof(LispString));
[2]34    if (cmp==0) return p;
[124]35    else if (cmp<0)
36    {
[2]37      parent=&p->left;
38      p=p->left;
39    }
[124]40    else
[2]41    {
42      parent=&p->right;
43      p=p->right;
44    }
45  }
46
[482]47  p=malloc(sizeof(LispSymbol));
[2]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.