Allow OPT to accept optional dashes before flags

This commit is contained in:
Rangi42
2025-08-06 10:19:01 -04:00
parent a4a830776b
commit f9a55bd5cd
3 changed files with 7 additions and 3 deletions

View File

@@ -2482,7 +2482,8 @@ can be used to change some of the options during assembling from within the sour
takes a comma-separated list of options as its argument:
.Bd -literal -offset indent
PUSHO
OPT g.oOX, Wdiv ; acts like command-line -g.oOX -Wdiv
OPT g.oOX, Wdiv ; acts like command-line `-g.oOX -Wdiv`
OPT -Wdiv ; dashes before the options are optional
DW `..ooOOXX ; uses the graphics constant characters from OPT g
PRINTLN $80000000/-1 ; prints a warning about division
POPO

View File

@@ -53,6 +53,9 @@ void opt_W(char const *flag) {
}
void opt_Parse(char const *s) {
if (s[0] == '-') {
++s;
}
switch (s[0]) {
case 'b':
if (strlen(&s[1]) == 2) {

View File

@@ -1,7 +1,7 @@
SECTION "test", ROM0
pusho
opt p42, Q.4, Wno-div
opt p42, -Q.4, Wno-div
ds 1
println $8000_0000 / -1
def n = 3.14
@@ -13,6 +13,6 @@ popo
def n = 3.14
println "{x:n} = {f:n}"
pusho p99
pusho -p99
ds 1
popo