bugfix: shift in date_arg(), thanks Herbert for reporting this bug

This commit is contained in:
Frederic Culot 2007-09-01 21:26:12 +00:00
parent c908d40292
commit c04fee7e14
2 changed files with 12 additions and 15 deletions

View File

@ -1,3 +1,6 @@
01 Sep 2007:
bugfix: shift in date_arg(), thanks Herbert for reporting this bug
31 Aug 2007: 1.9_beta 31 Aug 2007: 1.9_beta
NEWS file updated NEWS file updated

View File

@ -1,4 +1,4 @@
/* $calcurse: args.c,v 1.24 2007/08/15 15:36:49 culot Exp $ */ /* $calcurse: args.c,v 1.25 2007/09/01 21:26:12 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -203,7 +203,7 @@ arg_print_date(long date)
* If there is also no date given, current date is considered. * If there is also no date given, current date is considered.
*/ */
static int static int
app_arg(int add_line, date_t day, long date) app_arg(int add_line, date_t *day, long date)
{ {
struct recur_event_s *re; struct recur_event_s *re;
struct event_s *j; struct event_s *j;
@ -216,7 +216,7 @@ app_arg(int add_line, date_t day, long date)
char apoint_end_time[100]; char apoint_end_time[100];
if (date == 0) if (date == 0)
today = get_sec_date(day); today = get_sec_date(*day);
else else
today = date; today = date;
@ -322,12 +322,7 @@ date_arg(char *ddate, int add_line)
int numdays = 0, num_digit = 0; int numdays = 0, num_digit = 0;
int arg_len = 0, app_found = 0; int arg_len = 0, app_found = 0;
int date_valid = 0; int date_valid = 0;
long today, ind; long ind;
int sec_in_day = 86400;
day.dd = 0;
day.mm = 0;
day.yyyy = 0;
/* /*
* Check (with the argument length) if a date or a number of days * Check (with the argument length) if a date or a number of days
@ -347,18 +342,17 @@ date_arg(char *ddate, int add_line)
* in the chosen interval. app_found and add_line are used * in the chosen interval. app_found and add_line are used
* to format the output correctly. * to format the output correctly.
*/ */
today = get_sec_date(day); ind = get_today();
ind = today;
for (i = 0; i < numdays; i++) { for (i = 0; i < numdays; i++) {
app_found = app_arg(add_line, day, ind); app_found = app_arg(add_line, 0L, ind);
add_line = app_found; add_line = app_found;
ind = ind + sec_in_day; ind += DAYINSEC + MININSEC;
} }
} else { /* a date was entered */ } else { /* a date was entered */
date_valid = check_date(ddate); date_valid = check_date(ddate);
if (date_valid) { if (date_valid) {
sscanf(ddate, "%d / %d / %d", &day.mm, &day.dd, &day.yyyy); sscanf(ddate, "%d / %d / %d", &day.mm, &day.dd, &day.yyyy);
app_found = app_arg(add_line, day, 0); app_found = app_arg(add_line, &day, 0);
} else { } else {
fputs(_("Argument to the '-d' flag is not valid\n"), fputs(_("Argument to the '-d' flag is not valid\n"),
stdout); stdout);
@ -513,7 +507,7 @@ parse_args(int argc, char **argv, conf_t *conf)
} else if (aflag) { } else if (aflag) {
date_t day; date_t day;
day.dd = day.mm = day.yyyy = 0; day.dd = day.mm = day.yyyy = 0;
app_found = app_arg(add_line,day,0); app_found = app_arg(add_line, &day, 0);
non_interactive = 1; non_interactive = 1;
} }
} else { } else {