diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2025-01-02 21:34:13 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2025-01-02 21:34:13 +0400 |
commit | abb3931fa2b2fbffd0b77b1db233e9e5fa39e647 (patch) | |
tree | 863bb882f46be720d4ee567dd7fbe1a285b475b2 /src | |
parent | 74287e5870a2548dd1a0d0f47bbeff1fa1bb36fb (diff) |
use `copy` to copy slices instead of `=`
Diffstat (limited to 'src')
-rw-r--r-- | src/main.go | 13 |
1 files 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...) } |