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>
This commit is contained in:
parent
bc97d60ef2
commit
2fe7a36aab
@ -109,7 +109,8 @@
|
|||||||
#define ATTR_HIGHEST 6
|
#define ATTR_HIGHEST 6
|
||||||
|
|
||||||
#define STATUSHEIGHT 2
|
#define STATUSHEIGHT 2
|
||||||
#define NOTESIZ 6
|
#define MAX_NOTESIZ 40
|
||||||
|
#define TMPEXTSIZ 6
|
||||||
|
|
||||||
/* Format for appointment hours is: HH:MM */
|
/* Format for appointment hours is: HH:MM */
|
||||||
#define HRMIN_SIZE 6
|
#define HRMIN_SIZE 6
|
||||||
|
8
src/io.c
8
src/io.c
@ -1114,7 +1114,7 @@ io_load_app (void)
|
|||||||
int id = 0;
|
int id = 0;
|
||||||
int freq;
|
int freq;
|
||||||
char type, state = 0L;
|
char type, state = 0L;
|
||||||
char note[NOTESIZ + 1], *notep;
|
char note[MAX_NOTESIZ + 1], *notep;
|
||||||
|
|
||||||
t = time (NULL);
|
t = time (NULL);
|
||||||
lt = localtime (&t);
|
lt = localtime (&t);
|
||||||
@ -1295,7 +1295,7 @@ io_load_todo (void)
|
|||||||
char *newline;
|
char *newline;
|
||||||
int nb_tod = 0;
|
int nb_tod = 0;
|
||||||
int c, id;
|
int c, id;
|
||||||
char buf[BUFSIZ], e_todo[BUFSIZ], note[NOTESIZ + 1];
|
char buf[BUFSIZ], e_todo[BUFSIZ], note[MAX_NOTESIZ + 1];
|
||||||
|
|
||||||
data_file = fopen (path_todo, "r");
|
data_file = fopen (path_todo, "r");
|
||||||
if (data_file == NULL)
|
if (data_file == NULL)
|
||||||
@ -2313,7 +2313,7 @@ ical_read_note (char *line, unsigned *noskipped, ical_vevent_e item_type,
|
|||||||
|
|
||||||
if ((p = strchr (line, ':')) != NULL)
|
if ((p = strchr (line, ':')) != NULL)
|
||||||
{
|
{
|
||||||
notename = new_tempfile (path_notes, NOTESIZ);
|
notename = new_tempfile (path_notes, TMPEXTSIZ);
|
||||||
EXIT_IF (notename == NULL,
|
EXIT_IF (notename == NULL,
|
||||||
_("Warning: could not create new note file to store "
|
_("Warning: could not create new note file to store "
|
||||||
"description. Aborting...\n"));
|
"description. Aborting...\n"));
|
||||||
@ -2818,7 +2818,7 @@ io_log_init (void)
|
|||||||
struct io_file *log;
|
struct io_file *log;
|
||||||
|
|
||||||
snprintf (logprefix, BUFSIZ, "%s/calcurse_log.", get_tempdir ());
|
snprintf (logprefix, BUFSIZ, "%s/calcurse_log.", get_tempdir ());
|
||||||
logname = new_tempfile (logprefix, NOTESIZ);
|
logname = new_tempfile (logprefix, TMPEXTSIZ);
|
||||||
RETVAL_IF (logname == NULL, 0,
|
RETVAL_IF (logname == NULL, 0,
|
||||||
_("Warning: could not create temporary log file, Aborting..."));
|
_("Warning: could not create temporary log file, Aborting..."));
|
||||||
log = mem_malloc (sizeof (struct io_file));
|
log = mem_malloc (sizeof (struct io_file));
|
||||||
|
17
src/note.c
17
src/note.c
@ -93,7 +93,18 @@ erase_note (char **note, enum eraseflg flag)
|
|||||||
void
|
void
|
||||||
note_read (char *buffer, FILE *fp)
|
note_read (char *buffer, FILE *fp)
|
||||||
{
|
{
|
||||||
(void)fgets (buffer, NOTESIZ + 1, fp);
|
int i;
|
||||||
buffer[NOTESIZ] = '\0';
|
|
||||||
getc (fp);
|
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';
|
||||||
}
|
}
|
||||||
|
@ -334,14 +334,14 @@ todo_chg_priority (int action)
|
|||||||
struct todo *backup;
|
struct todo *backup;
|
||||||
char backup_mesg[BUFSIZ];
|
char backup_mesg[BUFSIZ];
|
||||||
int backup_id;
|
int backup_id;
|
||||||
char backup_note[NOTESIZ + 1];
|
char backup_note[MAX_NOTESIZ + 1];
|
||||||
int do_chg = 1;
|
int do_chg = 1;
|
||||||
|
|
||||||
backup = todo_get_item (hilt);
|
backup = todo_get_item (hilt);
|
||||||
(void)strncpy (backup_mesg, backup->mesg, strlen (backup->mesg) + 1);
|
(void)strncpy (backup_mesg, backup->mesg, strlen (backup->mesg) + 1);
|
||||||
backup_id = backup->id;
|
backup_id = backup->id;
|
||||||
if (backup->note)
|
if (backup->note)
|
||||||
(void)strncpy (backup_note, backup->note, NOTESIZ + 1);
|
(void)strncpy (backup_note, backup->note, MAX_NOTESIZ + 1);
|
||||||
else
|
else
|
||||||
backup_note[0] = '\0';
|
backup_note[0] = '\0';
|
||||||
switch (action)
|
switch (action)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user