Skip to content

Commit

Permalink
Another substring instance
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRayCode committed Jan 27, 2024
1 parent ae748fc commit da648a9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/preprocessor/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,16 @@ const expandFunctionMacro = (

// Replace the use of the macro with the expansion
const processed = current.replace(
current.substr(startMatch.index, matchLength),
current.substring(startMatch.index, startMatch.index + matchLength),
expandedReplace
);
// Add text up to the end of the expanded macro to what we've procssed
expanded += processed.substr(0, endOfReplace);
expanded += processed.substring(0, endOfReplace);

// Only work on the rest of the text, not what we already expanded. This is
// to avoid a nested macro #define foo() foo() where we'll try to expand foo
// forever. With this strategy, we expand foo() to foo() and move on
current = processed.substr(endOfReplace);
current = processed.substring(endOfReplace);
}

return expanded + current;
Expand Down

0 comments on commit da648a9

Please sign in to comment.