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