Files
TempleOS-Rijn/LT/Utils/ListFile.APZ
T
2018-09-08 21:45:20 +02:00

81 lines
1.7 KiB
Plaintext

#help_index "Compiler"
I8 LFLineAdd(I1 *fn,I8 line,ClassStruct **hint)
{
I1 buf[256];
I8 i;
DbgInfo *dbg;
ClassStruct *tempc;
SysHashTable *tempht=Fs->hash_table;
if (tempc=*hint) {
if (line>=dbg->min_line && line<=dbg->max_line)
return dbg->body[line-dbg->min_line];
}
while (tempht) {
for (i=0;i<=tempht->mask;i++) {
tempc=tempht->body[i];
while (tempc) {
if (tempc->type&(HTT_FUNCTION|HTT_SYS_SYMBOL) && tempc->source_link) {
StrCpy(buf,tempc->source_link);
RemoveFirstSeg(buf,":");
RemoveLastSeg(buf,",");
if (*buf==':') *buf=default_drive;
if (!StrCmp(fn,buf)) {
if (dbg=tempc->debug) {
if (line>=dbg->min_line && line<=dbg->max_line) {
*hint=tempc;
return dbg->body[line-dbg->min_line];
}
}
}
}
tempc=tempc->next;
}
}
tempht=tempht->next;
}
return 0;
}
public void ListFile(I1 *filename,I1 *flags=NULL)
//This works on files Loaded into memory.
//flag $FG,2$+s$FG$ means size instead of address.
{
I8 i,f=0,last_i=0;
I1 *fn=DefaultExtension(filename,"CPZ"),*fn2;
Ltf *l;
LtfEntry *cl;
ClassStruct *hint=NULL;
GetFFlags(&f,"s\0",flags);
fn2=AbsoluteFileName(fn);
l=LtfRead(fn2);
cl=l->dummy.next;
while (cl!=l) {
i=LFLineAdd(fn2,cl->y+1,&hint);
if (!last_i) last_i=i;
if (i) {
if (f&1)
PrintF("$$FG,RED$$%04X$$FG$$ ",i-last_i);
else
PrintF("$$FG,RED$$%08X$$FG$$ ",i);
} else {
if (f&1)
PutS(" ");
else
PutS(" ");
}
cl=LtfPutLine(cl);
if (i) last_i=i;
}
LtfDel(l);
Free(fn);
Free(fn2);
}
#help_index ""