int lnsave; // 1; strcpy() text of current line
int curlineno; // Current line number
int totlines; // Total # of lines
int lnsave; // 1; strcpy() text of current line
int curlineno; // Current line number
int totlines; // Total # of lines
- 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--;
+ }
// ExpandMacro((char *)(strp + 1), imacro->im_lnbuf, LNSIZ);
ExpandMacro(strp->line, imacro->im_lnbuf, LNSIZ);
// ExpandMacro((char *)(strp + 1), imacro->im_lnbuf, LNSIZ);
ExpandMacro(strp->line, imacro->im_lnbuf, LNSIZ);
if (!strcmp(imacro->im_macro->sname, "mjump") && !mjump_align)
{
// if we need to adjust the alignment of the jump source address to
if (!strcmp(imacro->im_macro->sname, "mjump") && !mjump_align)
{
// if we need to adjust the alignment of the jump source address to
ifile->ifoldlineno = curlineno; // Save old line number
ifile->ifoldfname = curfname; // Save old filename
ifile->ifno = cfileno; // Save old file number
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
curfname = strdup(fname); // Set current filename (alloc storage)
curlineno = 0; // Start on line zero
// Add another file to the file-record
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
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