summaryrefslogtreecommitdiff
path: root/src/note.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-08-02 21:42:10 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-10-05 12:25:47 +0200
commit2fe7a36aab8c6c934550b2b8dc2074c1af23859a (patch)
tree31fe32a80e1f15d2bfa457b40ba337c849f3e8df /src/note.c
parentbc97d60ef2cacfe79875e6c604bf3f0e6d07fbd9 (diff)
downloadcalcurse-2fe7a36aab8c6c934550b2b8dc2074c1af23859a.zip
Accept variable length note names
Read up to the first blank in note_read() instead of assuming a fixed-width note file name. Accept everything up to 40 characters (which is the length of a SHA1 hash in hexadecimal representation). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/note.c')
-rw-r--r--src/note.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/note.c b/src/note.c
index 91aae66..c8aa1ec 100644
--- a/src/note.c
+++ b/src/note.c
@@ -93,7 +93,18 @@ erase_note (char **note, enum eraseflg flag)
void
note_read (char *buffer, FILE *fp)
{
- (void)fgets (buffer, NOTESIZ + 1, fp);
- buffer[NOTESIZ] = '\0';
- getc (fp);
+ int i;
+
+ for (i = 0; i < MAX_NOTESIZ; i++)
+ {
+ buffer[i] = getc (fp);
+ if (buffer[i] == ' ')
+ {
+ buffer[i] = '\0';
+ return;
+ }
+ }
+
+ while (getc (fp) != ' ');
+ buffer[MAX_NOTESIZ] = '\0';
}