summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Nystrom <sam@samnystrom.dev>2023-06-23 01:21:22 -0400
committerSam Nystrom <sam@samnystrom.dev>2023-06-23 01:22:30 -0400
commitbd7e80e0653f8851e9ca710561e1bdd1c90064fc (patch)
treed55ddef9fd386072b61c8ed6508465ef00286b24
parentc89770e17a73040b14723e510d62a1527b75b130 (diff)
close subtitle file after parsing
-rw-r--r--main.ha6
1 files changed, 3 insertions, 3 deletions
diff --git a/main.ha b/main.ha
index f2c571f..42e7039 100644
--- a/main.ha
+++ b/main.ha
@@ -24,7 +24,6 @@ use fs;
use os;
use strconv;
use strings;
-use strio;
use time;
use unix::poll;
use unix::tty;
@@ -66,12 +65,13 @@ export fn main() void = {
};
let subtitles = parse_srt(file);
+ io::close(file)!;
defer free(subtitles);
defer for (let i = 0z; i < len(subtitles); i += 1) {
free_text(subtitles[i].text);
};
- fmt::fprint(os::stdout_file, "\x1b[?25l")!;
+ fmt::fprint(os::stdout_file, "\x1b[?25l")!; // Hide the cursor
defer fmt::fprint(os::stdout_file, "\x1b[?25h")!;
let termios = tty::termios_query(os::stdin_file)!;
defer tty::termios_restore(&termios);
@@ -240,7 +240,7 @@ fn parse_srt(file: io::handle) []subtitle = {
case state::TEXT =>
if (len(line) > 0) {
io::writeall(&content, strings::toutf8(line))!;
- strio::appendrune(&content, '\n')!;
+ io::writeall(&content, strings::toutf8("\n"))!;
continue;
};