Skip to content

Commit 85c1823

Browse files
committed
v_include fix for non-symbol-compliant unquoted filenames
1 parent 77c3169 commit 85c1823

File tree

6 files changed

+44
-3
lines changed

6 files changed

+44
-3
lines changed

src/ops.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,13 @@ v_include(char *str, MNEMONIC *dummy)
416416

417417
programlabel();
418418

419-
sym = eval(str, 0);
420-
if (sym->flags & SYM_STRING )
419+
// only eval the string if it's compliant with symbol naming
420+
if ((*str<'0')||(*str>'9')) //check could be more comprehensive
421+
sym = eval(str, 0);
422+
else
423+
sym = NULL;
424+
425+
if ( (sym) && (sym->flags & SYM_STRING ) )
421426
{
422427
pushinclude(sym->string);
423428
}
@@ -432,7 +437,8 @@ v_include(char *str, MNEMONIC *dummy)
432437
free(buf);
433438
}
434439

435-
FreeSymbolList(sym);
440+
if (sym)
441+
FreeSymbolList(sym);
436442
}
437443

438444

test/11include.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; 11include.inc - part of the symbolic include testing.
2+
; To test non-symbol compliant include filenames, the name needs to begin with digits.
3+
; Please don't rename it.
4+
;
5+
; --Mike Saarna
6+
7+
.byte $11

test/include-a.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.byte $0A

test/include.asm

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; Test symbolic includes
2+
;
3+
; Ensure that quoted, unquoted, and symbol based includes work.
4+
;
5+
; --Mike Saarna
6+
7+
.processor 6502
8+
.org 0
9+
10+
TESTINCA = "include-a.inc"
11+
PASSFORCEA = PASSFORCEB
12+
13+
lda #PASSFORCEA
14+
include "include-a.inc"
15+
include include-a.inc
16+
include TESTINCA
17+
include "11include.inc"
18+
19+
; Non-symbol compliant filenames without quotes...
20+
include 11include.inc
21+
22+
PASSFORCEB = 1
23+
24+
25+
.end

test/include.bin.ref

9 Bytes
Binary file not shown.

test/include.hex.ref

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:07000000A9010A0A0A11110F
2+
:00000001FF

0 commit comments

Comments
 (0)