aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-10-02 00:22:53 +0000
committerdam <dam@gudinoff>2022-10-02 00:22:53 +0000
commit62294eb66c1ef061002165c692266d5d5f7f1cd1 (patch)
tree33a99875b84701f661c838cbd2646f1b68ad59fd /main.c
parent5c68228fbe958c6405573876de8f2956d6b9a23a (diff)
downloadtask-time-tracker-62294eb66c1ef061002165c692266d5d5f7f1cd1.tar.zst
task-time-tracker-62294eb66c1ef061002165c692266d5d5f7f1cd1.zip
Fixed argument checking on some argument driven actions.
Diffstat (limited to 'main.c')
-rw-r--r--main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/main.c b/main.c
index 8817d6d..8e6cfbc 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,8 @@
// Compilation command:
// - release: gcc main.c -Wall -Werror -pedantic -O2 -m64 -lncursesw -o ttt
// - debug : gcc main.c -Wall -Werror -pedantic -g3 -m64 -lncursesw -o ttt -D DEBUG
+// Usage hints:
+// - To changes app data path change the environment variable HOME (USERPROFILE for windows users).
#include <assert.h>
@@ -996,8 +998,9 @@ int main(int argc, char *argv[]) {
action = "--icsv";
do_action = strncmp(argv[idx], action, strlen(action)+1) == 0;
if (do_action) {
- if (argc < idx+1) {
+ if (idx+1 >= argc) {
fprintf(stdout, "Missing CSV file path to import.\n");
+ return EXIT_FAILURE;
}
load_database(&database, db_file_path);
import_from_csv(&database, argv[idx+1]);
@@ -1009,8 +1012,9 @@ int main(int argc, char *argv[]) {
action = "--ecsv";
do_action = strncmp(argv[idx], action, strlen(action)+1) == 0;
if (do_action) {
- if (argc < idx+1) {
+ if (idx+1 >= argc) {
fprintf(stdout, "Missing CSV file path to export.\n");
+ return EXIT_FAILURE;
}
load_database(&database, db_file_path);
export_to_csv(&database, argv[idx+1]);