mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
Add recursion limit for INCLUDE and macros
(And REPT.) Not exactly a *recursion* limit, more like a *stack depth* limit, but calling it "recursion" conveys its purpose better. The default of 64 is super overkill: even in a a project with what I believe to be above-average levels of nesting, the level only peaked at 6. Keeping in mind the purpose of this is to catch infinite recursion, which is still caught quickly (in usual cases, anyways), this default seems sensible. And it passes tests. What more do you need?
This commit is contained in:
@@ -315,6 +315,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* yydebug=1; */
|
||||
|
||||
nMaxFileStackDepth = 64;
|
||||
|
||||
DefaultOptions.gbgfx[0] = '0';
|
||||
DefaultOptions.gbgfx[1] = '1';
|
||||
DefaultOptions.gbgfx[2] = '2';
|
||||
@@ -332,7 +334,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
newopt = CurrentOptions;
|
||||
|
||||
while ((ch = getopt(argc, argv, "b:D:Eg:hi:LM:o:p:Vvw")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "b:D:Eg:hi:LM:o:p:r:Vvw")) != -1) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
if (strlen(optarg) == 2) {
|
||||
@@ -386,6 +388,12 @@ int main(int argc, char *argv[])
|
||||
errx(1, "Argument for option 'p' must be between 0 and 0xFF");
|
||||
|
||||
break;
|
||||
case 'r':
|
||||
nMaxFileStackDepth = strtoul(optarg, &ep, 0);
|
||||
|
||||
if (optarg[0] == '\0' || *ep != '\0')
|
||||
errx(1, "Invalid argument for option 'r'");
|
||||
break;
|
||||
case 'V':
|
||||
printf("rgbasm %s\n", get_package_version_string());
|
||||
exit(0);
|
||||
|
||||
Reference in New Issue
Block a user