From e6961d6d6df7ea7c842a713b8aa073d00a2f347b Mon Sep 17 00:00:00 2001 From: PoliEcho Date: Tue, 3 Jun 2025 13:52:32 +0200 Subject: [PATCH] remembered that versioning exist --- src/const.h | 4 ++-- src/main.cpp | 2 +- src/menu.cpp | 66 +++++++++++++++++++++++++++++++--------------------- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/const.h b/src/const.h index d231f49..be27356 100644 --- a/src/const.h +++ b/src/const.h @@ -3,7 +3,7 @@ #ifndef NAME #define NAME "ParaDocs" -#define VERSION "0.0.1" +#define VERSION "1.0.0" inline constexpr auto hash_djb2a(const std::string_view sv) { unsigned long hash{5381}; @@ -13,7 +13,7 @@ inline constexpr auto hash_djb2a(const std::string_view sv) { return hash; } -inline constexpr auto operator""_sh(const char* str, size_t len) { +inline constexpr auto operator""_sh(const char *str, size_t len) { return hash_djb2a(std::string_view{str, len}); } diff --git a/src/main.cpp b/src/main.cpp index 0cb7f31..7f3b996 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ void PrintHelp() { } void PrintVersion() { - std::cout << NAME << loc_strings->version << ": " << VERSION << "\n"; + std::cout << NAME << " " << loc_strings->version << ": " << VERSION << "\n"; exit(0); } diff --git a/src/menu.cpp b/src/menu.cpp index d6c92c0..79b7f4c 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -84,20 +83,25 @@ void reload_menu_from_directory(complete_menu &main_menu) { for (uint8_t i = 0; i < ARRAY_SIZE(name_date); i++) { std::getline(ssfn, name_date[i], '_'); } + try { + json complaint_json = json::parse(file); - json complaint_json = json::parse(file); - if (complaint_json["status"].is_null() || - complaint_json["status"].get() >= STATUS_COUNT) { - std::cerr << "Invalid status in file: " - << directroy_entry.path().filename().string() << std::endl; - safe_exit(EINVAL); + if (complaint_json["status"].is_null() || + complaint_json["status"].get() >= STATUS_COUNT) { + std::cerr << "Invalid status in file: " + << directroy_entry.path().filename().string() + << std::endl; + safe_exit(EINVAL); + } + + name_date[1].append(" "); + name_date[1].append( + loc_strings + ->status_strings[complaint_json["status"].get()]); + } catch (...) { + continue; } - name_date[1].append(" "); - name_date[1].append( - loc_strings - ->status_strings[complaint_json["status"].get()]); - char *name = new char[name_date[0].length() + 1]; main_menu_allocated.push_back({GENERIC_TYPE, name, 1}); char *date = new char[name_date[1].length() + 1]; @@ -162,18 +166,22 @@ void menu() { for (uint8_t i = 0; i < ARRAY_SIZE(name_date); i++) { std::getline(ssfn, name_date[i], '_'); } - json complaint_json = json::parse(file); - if (complaint_json["status"].is_null() || - complaint_json["status"].get() >= STATUS_COUNT) { - std::cerr << "Invalid status in file: " - << directroy_entry.path().filename().string() - << std::endl; - safe_exit(EINVAL); + try { + json complaint_json = json::parse(file); + if (complaint_json["status"].is_null() || + complaint_json["status"].get() >= STATUS_COUNT) { + std::cerr << "Invalid status in file: " + << directroy_entry.path().filename().string() + << std::endl; + safe_exit(EINVAL); + } + name_date[1].append(" "); + name_date[1].append( + loc_strings + ->status_strings[complaint_json["status"].get()]); + } catch (...) { + continue; } - name_date[1].append(" "); - name_date[1].append( - loc_strings - ->status_strings[complaint_json["status"].get()]); char *name = new char[name_date[0].length() + 1]; main_menu_allocated.push_back({GENERIC_TYPE, name, 1}); @@ -252,11 +260,15 @@ void menu() { << "\n"; exit(EINVAL); } + try { + json selected_file_json = json::parse(selected_file); - json selected_file_json = json::parse(selected_file); - - printDocument(selected_file_json["complaint_text"].get()); - current_allocated = &main_menu_allocated; + printDocument( + selected_file_json["complaint_text"].get()); + current_allocated = &main_menu_allocated; + } catch (...) { + safe_exit(EINVAL); + } break; } case "easy_edit"_sh: