From da648a97e4c3df0ced6bd5a155229e704b4b9a9e Mon Sep 17 00:00:00 2001 From: Andrew Ray Date: Sat, 27 Jan 2024 11:19:10 -0800 Subject: [PATCH] Another substring instance --- src/preprocessor/preprocessor.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/preprocessor/preprocessor.ts b/src/preprocessor/preprocessor.ts index c6b5535..e666653 100644 --- a/src/preprocessor/preprocessor.ts +++ b/src/preprocessor/preprocessor.ts @@ -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;