fix some warnings
All checks were successful
build_test / build (push) Successful in 3m57s

This commit is contained in:
PoliEcho 2025-06-03 13:27:04 +02:00
parent d330878f8a
commit 00f261696f
2 changed files with 344 additions and 340 deletions

View File

@ -1,12 +1,12 @@
#include <ncurses.h>
#include "strings.h"
#include <cstddef>
#include <cstdint>
#include <ncurses.h>
#include <nlohmann/json.hpp>
#include <nlohmann/json_fwd.hpp>
#include <sstream>
#include <string>
#include <vector>
#include "strings.h"
using nlohmann::json;
void save_document(std::string &text, std::vector<std::string> &lines) {
@ -48,7 +48,8 @@ void editor_hard(std::string& text) {
while (true) {
clear();
// Draw text lines
for (size_t i = 0; i < window_height - 1 && i < lines.size(); i++) {
for (size_t i = 0;
i < static_cast<size_t>(window_height) - 1 && i < lines.size(); i++) {
mvprintw(i, 0, "%s", lines[i].c_str());
}

View File

@ -1,19 +1,3 @@
#include <curses.h>
#include <menu.h>
#include <ncurses.h>
#include <array>
#include <cerrno>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
#include <sstream>
#include <string>
#include <vector>
#include "color.h"
#include "const.h"
#include "cups.h"
@ -24,6 +8,24 @@
#include "signal.h"
#include "strings.h"
#include "types.h"
#include <array>
#include <cerrno>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <curses.h>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <limits>
#include <menu.h>
#include <ncurses.h>
#include <nlohmann/json.hpp>
#include <sstream>
#include <string>
#include <vector>
using nlohmann::json;
@ -239,23 +241,21 @@ void menu() {
// DONT FORGET TO PRINT ACTUAL DOCUMENT
std::array<std::string, 2> name_date =
get_name_date_from_item(current_item(main_menu.menu));
std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] +
'_' + name_date[1]);
std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' +
name_date[1]);
if (!selected_file.is_open()) {
std::clog << selected_file.rdstate() << "\n";
std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input
<< "\n"
<< "File: "
<< COMPLAINTS_DIR "/" + name_date[0] + '_' +
name_date[1]
<< COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1]
<< "\n";
exit(EINVAL);
}
json selected_file_json = json::parse(selected_file);
printDocument(
selected_file_json["complaint_text"].get<std::string>());
printDocument(selected_file_json["complaint_text"].get<std::string>());
current_allocated = &main_menu_allocated;
break;
}
@ -263,8 +263,8 @@ void menu() {
case "ee"_sh: {
const std::string name = spawncmd(loc_strings->reference_name);
if (name == "") {
print_in_middle(main_menu.win, 10, 0, 40,
loc_strings->invalid_input, COLOR_PAIR(1));
print_in_middle(main_menu.win, 10, 0, 40, loc_strings->invalid_input,
COLOR_PAIR(1));
}
const time_t current_time = time(nullptr);
@ -292,15 +292,14 @@ void menu() {
case "eh"_sh: {
std::array<std::string, 2> name_date =
get_name_date_from_item(current_item(main_menu.menu));
std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] +
'_' + name_date[1]);
std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' +
name_date[1]);
if (!selected_file.is_open()) {
std::clog << selected_file.rdstate() << "\n";
std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input
<< "\n"
<< "File: "
<< COMPLAINTS_DIR "/" + name_date[0] + '_' +
name_date[1]
<< COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1]
<< "\n";
exit(EINVAL);
}
@ -321,8 +320,8 @@ void menu() {
break;
}
default:
print_in_middle(main_menu.win, 10, 0, 40,
loc_strings->unknown_command, COLOR_PAIR(1));
print_in_middle(main_menu.win, 10, 0, 40, loc_strings->unknown_command,
COLOR_PAIR(1));
break;
}
break;
@ -333,7 +332,7 @@ void menu() {
{
uint8_t n = 0;
size_t indexes[2];
size_t indexes[2] = {ULONG_MAX, ULONG_MAX}; // fix compiler warning
for (size_t i = 0; (i < main_menu_allocated.size()); i++) {
if (main_menu_allocated[i].ptr ==
item_name(current_item(main_menu.menu))) {
@ -350,6 +349,10 @@ void menu() {
break;
}
}
if (indexes[0] == ULONG_MAX || indexes[1] == ULONG_MAX) {
std::cerr << RED "[ERROR]" << RESET " HOW DID THIS EVEN HAPPEN\n";
safe_exit(84);
}
if (indexes[0] > indexes[1]) {
std::swap(indexes[0], indexes[1]);
}
@ -378,8 +381,8 @@ void menu() {
: selected_file_json["status"] =
selected_file_json["status"].get<uint8_t>() + 1;
std::ofstream selected_file(COMPLAINTS_DIR "/" + name_date[0] +
'_' + name_date[1]);
std::ofstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' +
name_date[1]);
selected_file << selected_file_json;
selected_file.close();
} else {
@ -390,8 +393,8 @@ void menu() {
name_date[1].append(" ");
name_date[1].append(
loc_strings->status_strings[selected_file_json["status"]
.get<uint8_t>()]);
loc_strings
->status_strings[selected_file_json["status"].get<uint8_t>()]);
char *date_status = new char[name_date[1].length() + 1];
main_menu_allocated.push_back({GENERIC_TYPE, date_status, 1});
strlcpy(date_status, name_date[1].c_str(), name_date[1].length() + 1);