#define DEF_KW // Declare keyword values
#include "kwtab.h" // Incl generated keyword tables & defs
+
int lnsave; // 1; strcpy() text of current line
int curlineno; // Current line number
int totlines; // Total # of lines
};
-//
-// Make `fnum' the Current `curfname'
-//
-void setfnum(WORD fnum)
+void SetFilenameForErrorReporting(void)
{
- FILEREC * fr;
+ WORD fnum = cfileno;
- for(fr=filerec; fr!=NULL && fnum--; fr=fr->frec_next);
+ // Check for absolute top filename (this should never happen)
+ if (fnum == -1)
+ {
+ curfname = "(*top*)";
+ return;
+ }
+
+ FILEREC * fr = filerec;
+
+ // Advance to the correct record...
+ while (fr != NULL && fnum != 0)
+ {
+ fr = fr->frec_next;
+ fnum--;
+ }
+ // Check for file # record not found (this should never happen either)
if (fr == NULL)
- curfname = "(*top*)";
- else
- curfname = fr->frec_name;
+ {
+ curfname = "(*NOT FOUND*)";
+ return;
+ }
+
+ curfname = fr->frec_name;
}
// ExpandMacro((char *)(strp + 1), imacro->im_lnbuf, LNSIZ);
ExpandMacro(strp->line, imacro->im_lnbuf, LNSIZ);
+// bollocks
+#if 0
if (!strcmp(imacro->im_macro->sname, "mjump") && !mjump_align)
{
// if we need to adjust the alignment of the jump source address to
mjump_align = 1;
}
+#endif
return imacro->im_lnbuf;
}
return NULL;
}
- strp = irept->ir_nextln; //strp
+ strp = irept->ir_nextln;
}
strcpy(irbuf, (char *)(irept->ir_nextln + 1));
// Verbose mode
if (verb_flag)
- printf("[Including: %s]\n", fname);
+ printf("[include: %s, cfileno=%u]\n", fname, cfileno);
// Alloc and initialize include-descriptors
inobj = a_inobj(SRC_IFILE);
ifile->ifoldlineno = curlineno; // Save old line number
ifile->ifoldfname = curfname; // Save old filename
ifile->ifno = cfileno; // Save old file number
- cfileno = filecount++; // Compute new file number
+
+// cfileno = filecount++; // Compute new file number
+ // NB: This *must* be preincrement, we're adding one to the filecount here!
+ cfileno = ++filecount; // Compute NEW file number
curfname = strdup(fname); // Set current filename (alloc storage)
curlineno = 0; // Start on line zero
// Add another file to the file-record
-// fr = (FILEREC *)amem((LONG)sizeof(FILEREC));
fr = (FILEREC *)malloc(sizeof(FILEREC));
fr->frec_next = NULL;
fr->frec_name = curfname;
last_fr->frec_next = fr; // Append to list of filerecs
last_fr = fr;
+ DEBUG printf("[include: curfname: %s, cfileno=%u]\n", curfname, cfileno);
return OK;
}
ifile->if_link = f_ifile;
f_ifile = ifile;
close(ifile->ifhandle); // Close source file
+if (verb_flag) printf("[fpop (pre): curfname=%s]\n", curfname);
curfname = ifile->ifoldfname; // Set current filename
+if (verb_flag) printf("[fpop (post): curfname=%s]\n", curfname);
+if (verb_flag) printf("[fpop: (pre) cfileno=%d ifile->ifno=%d]\n", (int)cfileno, (int)ifile->ifno);
curlineno = ifile->ifoldlineno; // Set current line#
DEBUG printf("cfileno=%d ifile->ifno=%d\n", (int)cfileno, (int)ifile->ifno);
cfileno = ifile->ifno; // Restore current file number
+if (verb_flag) printf("[fpop: (post) cfileno=%d ifile->ifno=%d]\n", (int)cfileno, (int)ifile->ifno);
break;
case SRC_IMACRO: // Pop and release an IMACRO
imacro = inobj->inobj.imacro;
case SRC_IFILE:
if ((ln = getln()) == NULL)
{
+if (verb_flag) printf("tokln: Calling fpop() from SRC_IFILE...\n");
fpop(); // Pop input level
goto retry; // Try for more lines
}
case SRC_IREPT:
if ((ln = getrln()) == NULL)
{
+if (verb_flag) printf("tokln: Calling fpop() from SRC_IREPT...\n");
fpop();
goto retry;
}
return error("goto label not found");
}
+
void DumpTokenBuffer(void)
{
TOKEN * t;
printf("[EOL]\n");
}
+