From f9a55bd5cd7b4bb0a4a1994ce339c38480fd5be5 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Wed, 6 Aug 2025 10:19:01 -0400 Subject: [PATCH] Allow `OPT` to accept optional dashes before flags --- man/rgbasm.5 | 3 ++- src/asm/opt.cpp | 3 +++ test/asm/opt.asm | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/man/rgbasm.5 b/man/rgbasm.5 index df22e187..0e43886e 100644 --- a/man/rgbasm.5 +++ b/man/rgbasm.5 @@ -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 diff --git a/src/asm/opt.cpp b/src/asm/opt.cpp index 69e6de52..2d3ad05c 100644 --- a/src/asm/opt.cpp +++ b/src/asm/opt.cpp @@ -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) { diff --git a/test/asm/opt.asm b/test/asm/opt.asm index ca32d8cb..fbe20b49 100644 --- a/test/asm/opt.asm +++ b/test/asm/opt.asm @@ -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