feat: odin setup
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
**/part[12]
|
||||
6
ols.json
Normal file
6
ols.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json",
|
||||
"enable_document_symbols": true,
|
||||
"enable_hover": true,
|
||||
"enable_snippets": true
|
||||
}
|
||||
29
utils/utils.odin
Normal file
29
utils/utils.odin
Normal file
@@ -0,0 +1,29 @@
|
||||
package utils
|
||||
|
||||
import "core:bufio"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
import "core:strings"
|
||||
|
||||
read_input_lines :: proc(allocator := context.allocator) -> []string {
|
||||
lines := make([dynamic]string, allocator)
|
||||
|
||||
scanner: bufio.Scanner
|
||||
bufio.scanner_init(&scanner, os.to_stream(os.stdin))
|
||||
defer bufio.scanner_destroy(&scanner)
|
||||
|
||||
for bufio.scanner_scan(&scanner) {
|
||||
line := strings.clone(bufio.scanner_text(&scanner), allocator)
|
||||
append(&lines, line)
|
||||
}
|
||||
|
||||
if err := bufio.scanner_error(&scanner); err != nil {
|
||||
fmt.eprintfln("ERROR: Scanning input: %v", err)
|
||||
}
|
||||
|
||||
for len(lines) > 0 && len(lines[len(lines) - 1]) == 0 {
|
||||
pop(&lines)
|
||||
}
|
||||
|
||||
return lines[:]
|
||||
}
|
||||
Reference in New Issue
Block a user