From abb3931fa2b2fbffd0b77b1db233e9e5fa39e647 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Thu, 2 Jan 2025 21:34:13 +0400 Subject: use `copy` to copy slices instead of `=` --- src/main.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.go b/src/main.go index a427a6b..3791b02 100644 --- a/src/main.go +++ b/src/main.go @@ -93,12 +93,15 @@ func preprocess(tokens[] Token) []Token { /* FIXME: Better error message */ panic("include must be wrapped with `\"`") } - rawName := tokens[i + 1].str - fileName := rawName[1:len(rawName) - 1] + tmp := tokens[i + 1].str + includeFile := tmp[1:len(tmp) - 1] /* Clear out `"` at the beginning and at the end */ + + incTokens := tokenize(includeFile) + firstHalf := make([]Token, len(tokens[:i])) + secondHalf := make([]Token, len(tokens[i + 2:])) + copy(firstHalf, tokens[:i]) + copy(secondHalf, tokens[i + 2:]) - incTokens := tokenize(fileName) - firstHalf := tokens[:i] - secondHalf := tokens[i + 2:] tokens = append(firstHalf, incTokens...) tokens = append(tokens, secondHalf...) } -- cgit v1.2.3