diff --git a/README.md b/README.md index 45924ca..bd2ded5 100644 --- a/README.md +++ b/README.md @@ -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) - [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. +For installation, you can run `sudo make install` (from the /build directory) + # Usage To start Vis simply run the `vis` binary in your terminal alongside the name of the calendar file. diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 46f02d0..f5cc18b 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -286,7 +286,12 @@ calendar_information Engine::parse_date(std::string date) { std::vector tokens; 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, "."); } @@ -314,6 +319,7 @@ void Engine::parse_line(std::string line) { Base64decode(event_decoded, tokens[1].c_str()); this->events_map[event_date] = event_decoded; + free(event_decoded); } 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) if (this->calendar_file.fail()) return; - + std::string line; - while (std::getline(this->calendar_file, line)) { + while (std::getline(this->calendar_file, line)) this->parse_line(line); - } + } bool Engine::write_calendar() { @@ -357,6 +363,7 @@ bool Engine::write_calendar() { output_line << event_encoded; this->calendar_file << output_line.str() << std::endl; + free(event_encoded); } return true;