Initialize maxRecursionDepth with other options

This commit is contained in:
Rangi42
2025-07-21 19:58:37 -04:00
parent ee0f311c10
commit 8d268e8a8a
5 changed files with 12 additions and 17 deletions

View File

@@ -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<std::string> fullPath = fstk_FindFile(name); fullPath) {
newFileContext(*fullPath, false);

View File

@@ -165,26 +165,23 @@ static std::vector<StateFeature> 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<time_t>(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<std::string, std::vector<StateFeature>> 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<std::string, std::vector<StateFeature>> 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) {

View File

@@ -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;