diff --git a/include/asm/fstack.hpp b/include/asm/fstack.hpp index f6613e25..4c116c72 100644 --- a/include/asm/fstack.hpp +++ b/include/asm/fstack.hpp @@ -75,6 +75,6 @@ void fstk_RunFor( bool fstk_Break(); void fstk_NewRecursionDepth(size_t newDepth); -void fstk_Init(std::string const &mainPath, size_t maxDepth); +void fstk_Init(std::string const &mainPath); #endif // RGBDS_ASM_FSTACK_HPP diff --git a/include/asm/main.hpp b/include/asm/main.hpp index 8efb1892..c70fd83e 100644 --- a/include/asm/main.hpp +++ b/include/asm/main.hpp @@ -15,7 +15,7 @@ enum MissingInclude { struct Options { uint8_t fixPrecision = 16; // -Q - size_t maxRecursionDepth; // -r + size_t maxRecursionDepth = 64; // -r char binDigits[2] = {'0', '1'}; // -b char gfxDigits[4] = {'0', '1', '2', '3'}; // -g bool verbose = false; // -v diff --git a/src/asm/fstack.cpp b/src/asm/fstack.cpp index 60997bc0..14f7ac86 100644 --- a/src/asm/fstack.cpp +++ b/src/asm/fstack.cpp @@ -410,11 +410,9 @@ void fstk_NewRecursionDepth(size_t newDepth) { options.maxRecursionDepth = newDepth; } -void fstk_Init(std::string const &mainPath, size_t maxDepth) { +void fstk_Init(std::string const &mainPath) { newFileContext(mainPath, true); - options.maxRecursionDepth = maxDepth; - for (std::string const &name : preIncludeNames) { if (std::optional fullPath = fstk_FindFile(name); fullPath) { newFileContext(*fullPath, false); diff --git a/src/asm/main.cpp b/src/asm/main.cpp index 35188150..68771434 100644 --- a/src/asm/main.cpp +++ b/src/asm/main.cpp @@ -165,26 +165,23 @@ static std::vector parseStateFeatures(char *str) { } int main(int argc, char *argv[]) { - time_t now = time(nullptr); // Support SOURCE_DATE_EPOCH for reproducible builds // https://reproducible-builds.org/docs/source-date-epoch/ + time_t now = time(nullptr); if (char const *sourceDateEpoch = getenv("SOURCE_DATE_EPOCH"); sourceDateEpoch) { now = static_cast(strtoul(sourceDateEpoch, nullptr, 0)); } - - // Perform some init for below sym_Init(now); - // Set defaults - sym_SetExportAll(false); - uint32_t maxDepth = 64; - char const *dependFileName = nullptr; - std::unordered_map> stateFileSpecs; - // Maximum of 100 errors only applies if rgbasm is printing errors to a terminal. + // Maximum of 100 errors only applies if rgbasm is printing errors to a terminal if (isatty(STDERR_FILENO)) { options.maxErrors = 100; } + // Local options + char const *dependFileName = nullptr; // -M + std::unordered_map> stateFileSpecs; // -s + for (int ch; (ch = musl_getopt_long_only(argc, argv, optstring, longopts, nullptr)) != -1;) { switch (ch) { char *endptr; @@ -295,7 +292,7 @@ int main(int argc, char *argv[]) { } case 'r': - maxDepth = strtoul(musl_optarg, &endptr, 0); + options.maxRecursionDepth = strtoul(musl_optarg, &endptr, 0); if (musl_optarg[0] == '\0' || *endptr != '\0') { fatal("Invalid argument for option 'r'"); @@ -415,7 +412,7 @@ int main(int argc, char *argv[]) { charmap_New(DEFAULT_CHARMAP_NAME, nullptr); // Init lexer and file stack, providing file info - fstk_Init(mainFileName, maxDepth); + fstk_Init(mainFileName); // Perform parse (`yy::parser` is auto-generated from `parser.y`) if (yy::parser parser; parser.parse() != 0) { diff --git a/src/asm/symbol.cpp b/src/asm/symbol.cpp index 6bd7b8b3..710ab5a4 100644 --- a/src/asm/symbol.cpp +++ b/src/asm/symbol.cpp @@ -36,7 +36,7 @@ static char savedTIME[256]; static char savedDATE[256]; static char savedTIMESTAMP_ISO8601_LOCAL[256]; static char savedTIMESTAMP_ISO8601_UTC[256]; -static bool exportAll; // -E +static bool exportAll = false; // -E bool sym_IsPC(Symbol const *sym) { return sym == PCSymbol;