aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/calcurse.h1
-rw-r--r--src/io.c10
-rw-r--r--src/note.c9
3 files changed, 12 insertions, 8 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 8b82422..8aa5c4a 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -753,6 +753,7 @@ void mem_stats (void);
void edit_note (char **, char *);
void view_note (char *, char *);
void erase_note (char **, enum eraseflg);
+void note_read (char *, FILE *);
/* notify.c */
int notify_time_left (void);
diff --git a/src/io.c b/src/io.c
index b461b2b..31b4097 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1226,10 +1226,8 @@ io_load_app (void)
c = getc (data_file);
if (c == '>')
{
- (void)fgets (note, NOTESIZ + 1, data_file);
- note[NOTESIZ] = '\0';
+ note_read (note, data_file);
notep = note;
- getc (data_file);
}
else
{
@@ -1324,11 +1322,7 @@ io_load_todo (void)
/* Now read the attached note, if any. */
c = getc (data_file);
if (c == '>')
- {
- (void)fgets (note, NOTESIZ + 1, data_file);
- note[NOTESIZ] = '\0';
- getc (data_file);
- }
+ note_read (note, data_file);
else
note[0] = '\0';
/* Then read todo description. */
diff --git a/src/note.c b/src/note.c
index 57bfc2d..91aae66 100644
--- a/src/note.c
+++ b/src/note.c
@@ -88,3 +88,12 @@ erase_note (char **note, enum eraseflg flag)
mem_free (*note);
*note = NULL;
}
+
+/* Read a serialized note file name from a stream and deserialize it. */
+void
+note_read (char *buffer, FILE *fp)
+{
+ (void)fgets (buffer, NOTESIZ + 1, fp);
+ buffer[NOTESIZ] = '\0';
+ getc (fp);
+}