|
|
1.1 root 1: /* Copyright (c) 1982 Regents of the University of California */
2:
3: static char sccsid[] = "@(#)objaddr.c 1.2 2/17/82";
4:
5: /*
6: * Lookup the object address of a given line from the named file.
7: *
8: * Potentially all files in the file table need to be checked
9: * until the line is found since a particular file name may appear
10: * more than once in the file table (caused by includes).
11: */
12:
13: #include "defs.h"
14: #include "mappings.h"
15: #include "object.h"
16: #include "source.h"
17: #include "filetab.h"
18: #include "linetab.h"
19:
20: ADDRESS objaddr(line, name)
21: LINENO line;
22: char *name;
23: {
24: register FILETAB *ftp;
25: register LINENO i, j;
26: BOOLEAN foundfile;
27:
28: if (nlhdr.nlines == 0) {
29: return(-1);
30: }
31: if (name == NULL) {
32: name = cursource;
33: }
34: foundfile = FALSE;
35: for (ftp = &filetab[0]; ftp < &filetab[nlhdr.nfiles]; ftp++) {
36: if (streq(ftp->filename, name)) {
37: foundfile = TRUE;
38: i = ftp->lineindex;
39: if (ftp == &filetab[nlhdr.nfiles-1]) {
40: j = nlhdr.nlines;
41: } else {
42: j = (ftp + 1)->lineindex;
43: }
44: while (i < j) {
45: if (linetab[i].line == line) {
46: return linetab[i].addr;
47: }
48: i++;
49: }
50: }
51: }
52: if (!foundfile) {
53: error("unknown source file \"%s\"", name);
54: }
55: return(-1);
56: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.