diff options
Diffstat (limited to 'src/note.c')
-rw-r--r-- | src/note.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -94,9 +94,7 @@ void edit_note(char **note, const char *editor) const char *arg[] = { editor, tmppath, NULL }; wins_launch_external(arg); - if (io_file_is_empty(tmppath) > 0) { - erase_note(note); - } else if ((fp = fopen(tmppath, "r"))) { + if ((fp = fopen(tmppath, "r"))) { sha1_stream(fp, sha1); fclose(fp); *note = sha1; @@ -155,6 +153,17 @@ void note_read(char *buffer, FILE * fp) buffer[MAX_NOTESIZ] = '\0'; } +/* Read the contents of a note file */ +void note_read_contents(char *buffer, size_t buffer_len, FILE * fp) +{ + size_t read_count = fread(buffer, 1, buffer_len, fp); + if (read_count != buffer_len) + buffer[read_count] = '\0'; + else + memcpy(&buffer[buffer_len - 4], "...\0", 4); +} + + static void note_gc_extract_key(struct note_gc_hash *data, const char **key, int *len) { |