fixed a bug in recur_write_exc() which could result in an infinite loop when saving multiple days

recur_repeat_iem() updated to check if the frequence is valid
This commit is contained in:
Frederic Culot 2006-08-19 14:59:50 +00:00
parent 38deeac2aa
commit b80ecda39d

View File

@ -1,4 +1,4 @@
/* $calcurse: recur.c,v 1.4 2006/08/16 20:14:32 culot Exp $ */ /* $calcurse: recur.c,v 1.5 2006/08/19 14:59:50 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -147,20 +147,18 @@ int recur_char2def(char type){
/* Write days for which recurrent items should not be repeated. */ /* Write days for which recurrent items should not be repeated. */
void recur_write_exc(struct days_s *exc, FILE *f) { void recur_write_exc(struct days_s *exc, FILE *f) {
struct days_s *day;
struct tm *lt; struct tm *lt;
time_t t; time_t t;
int st_mon, st_day, st_year; int st_mon, st_day, st_year;
int end_mon, end_day, end_year;
for (day = exc; day != 0; day = exc->next) { while (exc) {
t = exc->st; t = exc->st;
lt = localtime(&t); lt = localtime(&t);
st_mon = lt->tm_mon + 1; st_mon = lt->tm_mon + 1;
st_day = lt->tm_mday; st_day = lt->tm_mday;
st_year = lt->tm_year + 1900; st_year = lt->tm_year + 1900;
fprintf(f, " !%02u/%02u/%04u", fprintf(f, " !%02u/%02u/%04u", st_mon, st_day, st_year);
st_mon, st_day, st_year); exc = exc->next;
} }
} }
@ -506,6 +504,8 @@ void recur_repeat_item(int sel_year, int sel_month, int sel_day,
char *mesg_type_2 = _("[D/W/M/Y] "); char *mesg_type_2 = _("[D/W/M/Y] ");
char *mesg_freq_1 = char *mesg_freq_1 =
_("Enter the repetition frequence:"); _("Enter the repetition frequence:");
char *mesg_wrong_freq =
_("The frequence you entered is not valid.");
char *mesg_until_1 = char *mesg_until_1 =
_("Enter the ending date: [mm/dd/yyyy] or '0' for an endless repetition"); _("Enter the ending date: [mm/dd/yyyy] or '0' for an endless repetition");
char *mesg_wrong_1 = _("The entered date is not valid."); char *mesg_wrong_1 = _("The entered date is not valid.");
@ -538,13 +538,19 @@ void recur_repeat_item(int sel_year, int sel_month, int sel_day,
ch = 0; ch = 0;
} }
status_mesg(mesg_freq_1, ""); while (freq == 0) {
getstring(swin, colr, user_input, 0, 1); status_mesg(mesg_freq_1, "");
if (strlen(user_input) != 0) { getstring(swin, colr, user_input, 0, 1);
freq = atoi(user_input); if (strlen(user_input) != 0) {
strcpy(user_input, ""); freq = atoi(user_input);
} else { if (freq == 0) {
return; status_mesg(mesg_wrong_freq, wrong_type_2);
wgetch(swin);
}
strcpy(user_input, "");
} else {
return;
}
} }
while (!date_entered) { while (!date_entered) {