Clean up RCS ids
[projects/cmucl/cmucl.git] / src / lisp / search.c
1 /*
2
3  This code was written as part of the CMU Common Lisp project at
4  Carnegie Mellon University, and has been placed in the public domain.
5
6 */
7
8 #include <string.h>
9 #include "lisp.h"
10 #include "internals.h"
11 #include "os.h"
12 #include "search.h"
13
14 boolean
15 search_for_type(int type, lispobj ** start, int *count)
16 {
17     lispobj obj, *addr;
18
19     while ((*count == -1 || (*count > 0)) &&
20            valid_addr((os_vm_address_t) * start)) {
21         obj = **start;
22         addr = *start;
23         if (*count != -1)
24             *count -= 2;
25
26         if (TypeOf(obj) == type)
27             return TRUE;
28
29         (*start) += 2;
30     }
31     return FALSE;
32 }
33
34
35 boolean
36 search_for_symbol(char *name, lispobj ** start, int *count)
37 {
38     struct symbol *symbol;
39     struct vector *symbol_name;
40
41     while (search_for_type(type_SymbolHeader, start, count)) {
42         symbol = (struct symbol *) PTR((lispobj) * start);
43         if (LowtagOf(symbol->name) == type_OtherPointer) {
44             symbol_name = (struct vector *) PTR(symbol->name);
45             if (valid_addr((os_vm_address_t) symbol_name) &&
46                 TypeOf(symbol_name->header) == type_SimpleString &&
47                 strcmp((char *) symbol_name->data, name) == 0)
48                 return TRUE;
49         }
50         (*start) += 2;
51     }
52     return FALSE;
53 }