General: Add many small fixes

This commit is contained in:
osamu-kj 2023-05-14 15:05:08 +02:00
parent 417f9fcbf2
commit 17a621b787
2 changed files with 15 additions and 6 deletions

View File

@ -15,12 +15,14 @@ The following is a list of dependencies that your system needs in order to be ab
- [The Ncurses library](https://invisible-island.net/ncurses/announce.html) - [The Ncurses library](https://invisible-island.net/ncurses/announce.html)
- [Moreutils](https://joeyh.name/code/moreutils/) - [Moreutils](https://joeyh.name/code/moreutils/)
# Building # Building & Installation
To build Vis, simply clone this repository and run `mkdir build; cd build; cmake ..; make` To build vis, simply clone this repository and run `mkdir build; cd build; cmake ..; make`
Resulting binary will be generated inside the `/build/src/` folder called. Resulting binary will be generated inside the `/build/src/` folder called.
For installation, you can run `sudo make install` (from the /build directory)
# Usage # Usage
To start Vis simply run the `vis` binary in your terminal alongside the name of the calendar file. To start Vis simply run the `vis` binary in your terminal alongside the name of the calendar file.

View File

@ -286,7 +286,12 @@ calendar_information Engine::parse_date(std::string date) {
std::vector<int> tokens; std::vector<int> tokens;
while (token != NULL) { while (token != NULL) {
tokens.push_back(std::stoi(token)); try {
tokens.push_back(std::stoi(token));
} catch (...) {
std::cout << "Error parsing calendar file. Suspected incorrect format." << std::endl;
exit(EXIT_FAILURE);
}
token = strtok(NULL, "."); token = strtok(NULL, ".");
} }
@ -314,6 +319,7 @@ void Engine::parse_line(std::string line) {
Base64decode(event_decoded, tokens[1].c_str()); Base64decode(event_decoded, tokens[1].c_str());
this->events_map[event_date] = event_decoded; this->events_map[event_date] = event_decoded;
free(event_decoded);
} }
void Engine::open_calendar(char *filename) { void Engine::open_calendar(char *filename) {
@ -324,11 +330,11 @@ void Engine::open_calendar(char *filename) {
// we'll create and reopen it later ('write' shortcut) // we'll create and reopen it later ('write' shortcut)
if (this->calendar_file.fail()) if (this->calendar_file.fail())
return; return;
std::string line; std::string line;
while (std::getline(this->calendar_file, line)) { while (std::getline(this->calendar_file, line))
this->parse_line(line); this->parse_line(line);
}
} }
bool Engine::write_calendar() { bool Engine::write_calendar() {
@ -357,6 +363,7 @@ bool Engine::write_calendar() {
output_line << event_encoded; output_line << event_encoded;
this->calendar_file << output_line.str() << std::endl; this->calendar_file << output_line.str() << std::endl;
free(event_encoded);
} }
return true; return true;