diff options
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 24 |
1 files changed, 11 insertions, 13 deletions
@@ -14,7 +14,7 @@ DEBUG :: false; #import "UTF8"; TUI :: #import "TUI"(COLOR_MODE_BITS=4); -VERSION :: "3.0"; // Use only 3 chars (to fit layouts). +VERSION :: "3.1"; // Use only 3 chars (to fit layouts). YEAR :: "2024"; NUM_WEEK_DAYS :: 7; @@ -175,14 +175,6 @@ hide_processing :: () { TUI.tui_write_string(TUI.Commands.TextMode); } -// Advance to next item in array. -advance :: inline (array: *[] $T, amount: int = 1) { - assert(amount >= 0); - assert(array.count >= amount); - array.count -= amount; - array.data += amount; -} - // Advances to next line and returns it. // Taken from Text_File_Handler module. // Returns the next line and success. @@ -645,8 +637,6 @@ load_app_state :: (db: *Database, st_path: string, db_path: string) -> success: case "first_day_of_week"; first_day_of_week = abs(string_to_int(value)) % NUM_WEEK_DAYS; } - - advance(*csv_line); } // Adjust selected task. @@ -721,12 +711,20 @@ import_from_csv :: (db: *Database, path: string) -> bool #must { task: Task; csv_line := split(line, CSV_SEPARATOR,, temporary_allocator); - + + if csv_line.count != 8 { + log_error("Discarded invalid CSV entry '%' from file '%'.", line, path); + continue; + } + // Truncate and import task name. task_name := truncate(csv_line[0], task.name.count); memcpy(task.name.data, task_name.data, task_name.count); + + // Advance to next item in csv_line array. + csv_line.count -= 1; + csv_line.data += 1; - advance(*csv_line); for csv_line task.times[it_index] = string_to_int(it); |
