diff --git a/src/main.c b/src/main.c index 525bbdb..caace2c 100644 --- a/src/main.c +++ b/src/main.c @@ -245,8 +245,6 @@ arg_next: //--------------------------------------------------------------------------------------------- // flags and arguments overwrite the config - // (TODO LATER) maybe add a way to combine flags (such which rm -fr?) - // (TODO LATER) add a version flag debug("Parsing the attribute flags.\n This flags might overwrite the options in the config file."); // thoses bypasses are used if some specific flags are passed as args. This allows to bypass the TUI selectors int bypassSelectionVault = 0; @@ -310,7 +308,7 @@ for (int i = 1; i < argc; i++) { return 0; } else if (strcmp(arg, "--version") == 0) { - printf("No released version yet...\n"); + printf("NoteWrapper version 1.0\n"); return 0; } else { @@ -499,7 +497,6 @@ note_selection: } filesCount = filesCount + journalCount; - // we sort them // (TODO LATER) THis doesn't seem to sort them qsort(filesArray, filesCount, sizeof(const char *), compareString); debug("Available notes and journals:"); if (shouldDebug) { @@ -540,8 +537,8 @@ note_selection: if (strcmp(noteSelected, "Create new note") != 0 && strcmp(noteSelected,"Back to vault selection") != 0 && strcmp(noteSelected, "Delete vault") != 0 && strcmp(noteSelected,"Quit (Ctrl+C)") != 0) { open_note: bypassSelectionNote = 0; // we must reset bypassSelectionNote to avoid getting into an infinite loop of bypassing the note selection - char *fullPath = malloc(PATH_MAX); // (TODO LATER) Find a more appropriate and descriptive name for the variable - sprintf(fullPath, "%s/%s/%s", notesDirectoryString, vaultSelected, noteSelected); // (TODO LATER) change all sprintf to snprintf which checks for buffer size + char *fullPath = malloc(PATH_MAX); + snprintf(fullPath, PATH_MAX, "%s/%s/%s", notesDirectoryString, vaultSelected, noteSelected); // if it is a journal we must update it before regex_t regex; int regexReturn = regcomp(®ex, journalRegex, 0); @@ -551,7 +548,7 @@ open_note: debug("%s is a journal. Updating it...", noteSelected); fullPath = updateJournal(fullPath, noteSelected, timeFormat, shouldDebug); // we return the path. As if it is a divided journal we must point to the correct entry } - if (newLineOnOpening) { //(TODO LATER) For some reason this does not applies to journals? --- it does but only if we don't create a new file/entry + if (newLineOnOpening) {//(TODO LATER) For some reason this does not applies to journals? --- it does but only if we don't create a new file/entry appendToFile(fullPath, "\n", shouldDebug); } openEditor(fullPath, editorToOpen, shouldRender, shouldJumpToEnd, shouldDebug); @@ -570,7 +567,7 @@ note_creation: if (strcmp(answer, "Yes.") == 0) { // delete the vault after confirmation by the user char pathToRMRF[PATH_MAX]; - sprintf(pathToRMRF, "%s/%s", notesDirectoryString, vaultSelected); + snprintf(pathToRMRF, PATH_MAX, "%s/%s", notesDirectoryString, vaultSelected); debug("Removed the directory: %s", pathToRMRF); rmrf(pathToRMRF, shouldDebug); shouldChangeVault = 1; diff --git a/src/notes.c b/src/notes.c index 8acce84..8bd1b75 100644 --- a/src/notes.c +++ b/src/notes.c @@ -129,8 +129,6 @@ char **getVaultsFromDirectory(char *dirString, int *count, int shouldDebug) { } char *updateJournal(char *path, char *journal, char *timeFormat, int shouldDebug) { - //(TODO LATER) Per journal format configuration - // (TODO LATER) with all the usage of PATH_MAX we should really calculate max inputed path or something like this path[PATH_MAX] = '\0'; // it assures it is a string (Most cases this does nothing). But rewriting at least one bytes make the compile happy. He doesn't want to return an unchanged input. debug("Handling the journal %s", path); @@ -233,7 +231,6 @@ char *updateJournal(char *path, char *journal, char *timeFormat, int shouldDebug strncpy(path, temp, PATH_MAX); debug("Returning path to the selected entry: %s", path); } - // (TODO LATER) free all unused entryArray[i] } else { error(1, "program", "%s is not a file and not a directory.", path); }