new copyright; att/bsd/shared
[unix-history] / usr / src / usr.bin / pascal / pdx / mappings / srcfile.c
CommitLineData
505bf312
KB
1/*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
f644bb55 6 */
56160dc1 7
f644bb55 8#ifndef lint
505bf312
KB
9static char sccsid[] = "@(#)srcfile.c 5.2 (Berkeley) %G%";
10#endif /* not lint */
56160dc1
ML
11
12/*
13 * get the source file name associated with a given address
14 */
15
16#include "defs.h"
17#include "mappings.h"
18#include "object.h"
19#include "filetab.h"
20
21char *srcfilename(addr)
22ADDRESS addr;
23{
24 register ADDRESS i, j, k;
25 ADDRESS a;
26 FILETAB *ftp;
27
28 if (addr < filetab[0].addr) {
29 return(NIL);
30 }
31 i = 0;
32 j = nlhdr.nfiles - 1;
33 while (i < j) {
34 k = (i + j) / 2;
35 ftp = &filetab[k];
36 if ((a = ftp->addr) == addr) {
37 return(ftp->filename);
38 } else if (addr > a) {
39 i = k + 1;
40 } else {
41 j = k - 1;
42 }
43 }
44 if (addr >= filetab[i].addr) {
45 return(filetab[i].filename);
46 } else {
47 return(filetab[i-1].filename);
48 }
49 /*NOTREACHED*/
50}