mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix failing assertion with backslash at EOF in macro arguments (#1634)
`Expansion::advance()` can increase its offset beyond the size, so I don't think this assumption was valid in the first place; `BufferedContent::advance()` should be able to as well.
This commit is contained in:
@@ -509,8 +509,9 @@ void BufferedContent::advance() {
|
|||||||
if (offset == std::size(buf)) {
|
if (offset == std::size(buf)) {
|
||||||
offset = 0; // Wrap around if necessary
|
offset = 0; // Wrap around if necessary
|
||||||
}
|
}
|
||||||
assume(size > 0);
|
if (size > 0) {
|
||||||
size--;
|
size--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferedContent::refill() {
|
void BufferedContent::refill() {
|
||||||
|
|||||||
3
test/asm/command-line-symbols.asm
Normal file
3
test/asm/command-line-symbols.asm
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
assert !strcmp("{FOO}", "hello")
|
||||||
|
assert !strcmp("{DEFINED}", "1")
|
||||||
|
def FOO equ 42
|
||||||
3
test/asm/command-line-symbols.err
Normal file
3
test/asm/command-line-symbols.err
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
error: command-line-symbols.asm(3):
|
||||||
|
'FOO' already defined at <command-line>
|
||||||
|
error: Assembly aborted (1 error)!
|
||||||
1
test/asm/command-line-symbols.flags
Normal file
1
test/asm/command-line-symbols.flags
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-Weverything -DFOO=hello -DDEFINED
|
||||||
@@ -41,6 +41,9 @@ for {s}, 3, 30, 3
|
|||||||
print "{d:x} "
|
print "{d:x} "
|
||||||
endr
|
endr
|
||||||
println "-> {d:x}"
|
println "-> {d:x}"
|
||||||
|
for s, 10
|
||||||
|
println "{d:s}"
|
||||||
|
endr
|
||||||
|
|
||||||
for v, 10
|
for v, 10
|
||||||
println "{d:v}"
|
println "{d:v}"
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ error: for.asm(16):
|
|||||||
FOR cannot have a step value of 0
|
FOR cannot have a step value of 0
|
||||||
warning: for.asm(20): [-Wbackwards-for]
|
warning: for.asm(20): [-Wbackwards-for]
|
||||||
FOR goes backwards from 1 to 2 by -1
|
FOR goes backwards from 1 to 2 by -1
|
||||||
error: for.asm(45) -> for.asm::REPT~4(51):
|
error: for.asm(46):
|
||||||
'v' already defined as constant at for.asm(45) -> for.asm::REPT~4(49)
|
's' already defined as constant at for.asm(39)
|
||||||
FATAL: for.asm(45) -> for.asm::REPT~4(51):
|
error: for.asm(48) -> for.asm::REPT~4(54):
|
||||||
|
'v' already defined as constant at for.asm(48) -> for.asm::REPT~4(52)
|
||||||
|
FATAL: for.asm(48) -> for.asm::REPT~4(54):
|
||||||
Failed to update FOR symbol value
|
Failed to update FOR symbol value
|
||||||
|
|||||||
5
test/asm/macro-arg-escape-chars.asm
Normal file
5
test/asm/macro-arg-escape-chars.asm
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
MACRO mac
|
||||||
|
DEF s EQUS "\#"
|
||||||
|
println "{#s:s}"
|
||||||
|
ENDM
|
||||||
|
mac \\\"\t\r\0\n\{\}\,\(\)\w\
|
||||||
5
test/asm/macro-arg-escape-chars.err
Normal file
5
test/asm/macro-arg-escape-chars.err
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
error: macro-arg-escape-chars.asm(5):
|
||||||
|
Illegal character escape 'w'
|
||||||
|
error: macro-arg-escape-chars.asm(5):
|
||||||
|
Illegal character escape at end of input
|
||||||
|
error: Assembly aborted (2 errors)!
|
||||||
1
test/asm/macro-arg-escape-chars.out
Normal file
1
test/asm/macro-arg-escape-chars.out
Normal file
@@ -0,0 +1 @@
|
|||||||
|
\\\"\t\r\0\n\{},()w\\
|
||||||
11
test/asm/string-literal-macro-arg.asm
Normal file
11
test/asm/string-literal-macro-arg.asm
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
MACRO mac
|
||||||
|
println "\1"
|
||||||
|
println \1
|
||||||
|
ENDM
|
||||||
|
mac "hello \\\"\t\r\0\n\ ; comment
|
||||||
|
\wor\
|
||||||
|
ld"
|
||||||
|
mac """goodbye
|
||||||
|
cruel\ ; comment
|
||||||
|
\nworld"""
|
||||||
|
mac "\
|
||||||
9
test/asm/string-literal-macro-arg.err
Normal file
9
test/asm/string-literal-macro-arg.err
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
error: string-literal-macro-arg.asm(6):
|
||||||
|
Illegal character escape 'w'
|
||||||
|
error: string-literal-macro-arg.asm(11):
|
||||||
|
Illegal character escape at end of input
|
||||||
|
error: string-literal-macro-arg.asm(11):
|
||||||
|
Unterminated string
|
||||||
|
error: string-literal-macro-arg.asm(11) -> string-literal-macro-arg.asm::mac(4):
|
||||||
|
Unterminated string
|
||||||
|
error: Assembly aborted (4 errors)!
|
||||||
BIN
test/asm/string-literal-macro-arg.out
Normal file
BIN
test/asm/string-literal-macro-arg.out
Normal file
Binary file not shown.
Reference in New Issue
Block a user