small bugfixes and code cleanup
This commit is contained in:
parent
8900d0f8f2
commit
65ec1bb0fa
13
ChangeLog
13
ChangeLog
@ -4,6 +4,19 @@
|
|||||||
|
|
||||||
* src/recur.c (foreach_date_dump): exception dates are now
|
* src/recur.c (foreach_date_dump): exception dates are now
|
||||||
properly taken into account
|
properly taken into account
|
||||||
|
|
||||||
|
* src/apoint.c:
|
||||||
|
* src/calendar.c:
|
||||||
|
* src/custom.c:
|
||||||
|
* src/event.c:
|
||||||
|
* src/io.c:
|
||||||
|
* src/recur.c: make use of error handling macros
|
||||||
|
|
||||||
|
* src/utils.c (status_bar): do not show 'credits' key binding
|
||||||
|
inside status bar
|
||||||
|
|
||||||
|
* src/custom.c (custom_general_config): make it possible to scroll
|
||||||
|
up and down again
|
||||||
|
|
||||||
2008-12-13 Frederic Culot <frederic@culot.org>
|
2008-12-13 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
|
621
po/calcurse.pot
621
po/calcurse.pot
File diff suppressed because it is too large
Load Diff
16
src/apoint.c
16
src/apoint.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: apoint.c,v 1.26 2008/12/12 20:44:50 culot Exp $ */
|
/* $calcurse: apoint.c,v 1.27 2008/12/14 15:54:51 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -381,12 +381,8 @@ apoint_scan (FILE *f, struct tm start, struct tm end, char state, char *note)
|
|||||||
|
|
||||||
tstart = mktime (&start);
|
tstart = mktime (&start);
|
||||||
tend = mktime (&end);
|
tend = mktime (&end);
|
||||||
if (tstart == -1 || tend == -1 || tstart > tend)
|
EXIT_IF (tstart == -1 || tend == -1 || tstart > tend,
|
||||||
{
|
_("date error in appointment"));
|
||||||
fputs (_("FATAL ERROR in apoint_scan: date error in the appointment\n"),
|
|
||||||
stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
return (apoint_new (buf, note, tstart, tend - tstart, state));
|
return (apoint_new (buf, note, tstart, tend - tstart, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,9 +403,9 @@ apoint_get (long day, int pos)
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
EXIT (_("item not found"));
|
||||||
fputs (_("FATAL ERROR in apoint_get: no such item\n"), stderr);
|
return 0;
|
||||||
exit (EXIT_FAILURE);
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calendar.c,v 1.19 2008/12/07 09:20:38 culot Exp $ */
|
/* $calcurse: calendar.c,v 1.20 2008/12/14 15:54:51 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -130,7 +130,7 @@ calendar_set_first_day_of_week (wday_e first_day)
|
|||||||
week_begins_on_monday = true;
|
week_begins_on_monday = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (_("ERROR in calendar_set_first_day_of_week\n"), stderr);
|
ERROR_MSG (_("ERROR setting first day of week"));
|
||||||
week_begins_on_monday = false;
|
week_begins_on_monday = false;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
55
src/custom.c
55
src/custom.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: custom.c,v 1.29 2008/12/08 19:17:07 culot Exp $ */
|
/* $calcurse: custom.c,v 1.30 2008/12/14 15:54:51 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -46,9 +46,8 @@ fill_config_var (char *string)
|
|||||||
return (false);
|
return (false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fputs (_("FATAL ERROR in fill_config_var: "
|
EXIT (_("wrong configuration variable format."));
|
||||||
"wrong configuration variable format.\n"), stderr);
|
return false;
|
||||||
return (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,26 +64,16 @@ custom_load_color (char *color, int background)
|
|||||||
int i, len, color_num;
|
int i, len, color_num;
|
||||||
char c[AWAITED_COLORS][BUFSIZ];
|
char c[AWAITED_COLORS][BUFSIZ];
|
||||||
int colr[AWAITED_COLORS];
|
int colr[AWAITED_COLORS];
|
||||||
const char *wrong_color_number =
|
|
||||||
_("FATAL ERROR in custom_load_color: wrong color number.\n");
|
|
||||||
const char *wrong_color_name =
|
|
||||||
_("FATAL ERROR in custom_load_color: wrong color name.\n");
|
|
||||||
const char *wrong_variable_format =
|
|
||||||
_("FATAL ERROR in custom_load_color: "
|
|
||||||
"wrong configuration variable format.\n");
|
|
||||||
|
|
||||||
len = strlen (color);
|
len = strlen (color);
|
||||||
|
|
||||||
if (len > 1)
|
if (len > 1)
|
||||||
{
|
{
|
||||||
/* New version configuration */
|
/* New version configuration */
|
||||||
if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS)
|
if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS)
|
||||||
{
|
{
|
||||||
fputs (_("FATAL ERROR in custom_load_color: "
|
EXIT (_("missing colors in config file"));
|
||||||
"missing colors in config file.\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
};
|
}
|
||||||
|
|
||||||
for (i = 0; i < AWAITED_COLORS; i++)
|
for (i = 0; i < AWAITED_COLORS; i++)
|
||||||
{
|
{
|
||||||
@ -108,8 +97,7 @@ custom_load_color (char *color, int background)
|
|||||||
colr[i] = background;
|
colr[i] = background;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fputs (wrong_color_name, stderr);
|
EXIT (_("wrong color name"));
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,15 +138,13 @@ custom_load_color (char *color, int background)
|
|||||||
init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
|
init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (wrong_color_number, stderr);
|
EXIT (_("wrong color number"));
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fputs (wrong_variable_format, stderr);
|
EXIT (_("wrong configuration variable format"));
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,9 +296,7 @@ custom_load_conf (conf_t *conf, int background)
|
|||||||
var = 0;
|
var = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (_("FATAL ERROR in custom_load_conf: "
|
EXIT (_("configuration variable unknown"));
|
||||||
"configuration variable unknown.\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,8 +670,6 @@ custom_color_theme_name (char *theme_name)
|
|||||||
"cyan",
|
"cyan",
|
||||||
"white"
|
"white"
|
||||||
};
|
};
|
||||||
const char *error_txt =
|
|
||||||
_("FATAL ERROR in custom_color_theme_name: unknown color\n");
|
|
||||||
|
|
||||||
if (!colorize)
|
if (!colorize)
|
||||||
snprintf (theme_name, BUFSIZ, "0");
|
snprintf (theme_name, BUFSIZ, "0");
|
||||||
@ -702,8 +684,7 @@ custom_color_theme_name (char *theme_name)
|
|||||||
color_name[i] = name[color[i]];
|
color_name[i] = name[color[i]];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fputs (error_txt, stderr);
|
EXIT (_("unknown color"));
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -805,7 +786,9 @@ custom_general_config (conf_t *conf)
|
|||||||
{
|
{
|
||||||
scrollwin_t cwin;
|
scrollwin_t cwin;
|
||||||
char *number_str =
|
char *number_str =
|
||||||
_("Enter an option number to change its value [Q to quit] ");
|
_("Enter an option number to change its value");
|
||||||
|
char *keys =
|
||||||
|
_("(Press '^P' or '^N' to move up or down, 'Q' to quit)");
|
||||||
char *output_datefmt_str =
|
char *output_datefmt_str =
|
||||||
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
|
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
|
||||||
char *input_datefmt_str =
|
char *input_datefmt_str =
|
||||||
@ -818,7 +801,7 @@ custom_general_config (conf_t *conf)
|
|||||||
snprintf (cwin.label, BUFSIZ, _("CalCurse %s | general options"), VERSION);
|
snprintf (cwin.label, BUFSIZ, _("CalCurse %s | general options"), VERSION);
|
||||||
wins_scrollwin_init (&cwin);
|
wins_scrollwin_init (&cwin);
|
||||||
wins_show (cwin.win.p, cwin.label);
|
wins_show (cwin.win.p, cwin.label);
|
||||||
status_mesg (number_str, "");
|
status_mesg (number_str, keys);
|
||||||
cwin.total_lines = print_general_options (cwin.pad.p, conf);
|
cwin.total_lines = print_general_options (cwin.pad.p, conf);
|
||||||
wins_scrollwin_display (&cwin);
|
wins_scrollwin_display (&cwin);
|
||||||
|
|
||||||
@ -844,10 +827,10 @@ custom_general_config (conf_t *conf)
|
|||||||
notify_update_bar ();
|
notify_update_bar ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_MOVE_DOWN:
|
case CTRL ('N'):
|
||||||
wins_scrollwin_down (&cwin, 1);
|
wins_scrollwin_down (&cwin, 1);
|
||||||
break;
|
break;
|
||||||
case KEY_MOVE_UP:
|
case CTRL ('P'):
|
||||||
wins_scrollwin_up (&cwin, 1);
|
wins_scrollwin_up (&cwin, 1);
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
@ -876,7 +859,7 @@ custom_general_config (conf_t *conf)
|
|||||||
{
|
{
|
||||||
strncpy (conf->output_datefmt, buf, strlen (buf) + 1);
|
strncpy (conf->output_datefmt, buf, strlen (buf) + 1);
|
||||||
}
|
}
|
||||||
status_mesg (number_str, "");
|
status_mesg (number_str, keys);
|
||||||
break;
|
break;
|
||||||
case '8':
|
case '8':
|
||||||
status_mesg (input_datefmt_str, "");
|
status_mesg (input_datefmt_str, "");
|
||||||
@ -886,10 +869,10 @@ custom_general_config (conf_t *conf)
|
|||||||
if (val >= 1 && val <= 3)
|
if (val >= 1 && val <= 3)
|
||||||
conf->input_datefmt = val;
|
conf->input_datefmt = val;
|
||||||
}
|
}
|
||||||
status_mesg (number_str, "");
|
status_mesg (number_str, keys);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
status_mesg (number_str, "");
|
status_mesg (number_str, keys);
|
||||||
cwin.total_lines = print_general_options (cwin.pad.p, conf);
|
cwin.total_lines = print_general_options (cwin.pad.p, conf);
|
||||||
wins_scrollwin_display (&cwin);
|
wins_scrollwin_display (&cwin);
|
||||||
}
|
}
|
||||||
|
23
src/event.c
23
src/event.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: event.c,v 1.7 2008/04/12 21:14:03 culot Exp $ */
|
/* $calcurse: event.c,v 1.8 2008/12/14 15:54:51 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -113,13 +113,9 @@ event_scan (FILE *f, struct tm start, int id, char *note)
|
|||||||
start.tm_mon--;
|
start.tm_mon--;
|
||||||
|
|
||||||
tstart = mktime (&start);
|
tstart = mktime (&start);
|
||||||
if (tstart == -1)
|
EXIT_IF (tstart == -1, _("date error in the event\n"));
|
||||||
{
|
|
||||||
fputs (_("FATAL ERROR in event_scan: date error in the event\n"),
|
return event_new (buf, note, tstart, id);
|
||||||
stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
return (event_new (buf, note, tstart, id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Retrieve an event from the list, given the day and item position. */
|
/* Retrieve an event from the list, given the day and item position. */
|
||||||
@ -139,9 +135,9 @@ event_get (long day, int pos)
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
EXIT (_("event not found"));
|
||||||
fputs (_("FATAL ERROR in event_get: no such item\n"), stderr);
|
return 0;
|
||||||
exit (EXIT_FAILURE);
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete an event from the list. */
|
/* Delete an event from the list. */
|
||||||
@ -174,7 +170,6 @@ event_delete_bynum (long start, unsigned num, erase_flag_e flag)
|
|||||||
}
|
}
|
||||||
iptr = &i->next;
|
iptr = &i->next;
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
EXIT (_("event not found"));
|
||||||
fputs (_("FATAL ERROR in event_delete_bynum: no such event\n"), stderr);
|
/* NOTREACHED */
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
54
src/io.c
54
src/io.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: io.c,v 1.48 2008/12/14 11:24:19 culot Exp $ */
|
/* $calcurse: io.c,v 1.49 2008/12/14 15:54:51 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -437,10 +437,7 @@ pcal_export_recur_events (FILE *stream)
|
|||||||
fprintf (stream, "%s %s\n", pcal_date, i->mesg);
|
fprintf (stream, "%s %s\n", pcal_date, i->mesg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (_("FATAL ERROR in pcal_export_recur_events: "
|
EXIT (_("incoherent repetition type"));
|
||||||
"incoherent repetition type\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -573,10 +570,7 @@ pcal_export_recur_apoints (FILE *stream)
|
|||||||
pcal_beg, pcal_end, i->mesg);
|
pcal_beg, pcal_end, i->mesg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (_("FATAL ERROR in pcal_export_recur_apoints: "
|
EXIT (_("incoherent repetition type"));
|
||||||
"incoherent repetition type\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -967,8 +961,6 @@ io_load_app (void)
|
|||||||
int freq;
|
int freq;
|
||||||
char type, state = 0L;
|
char type, state = 0L;
|
||||||
char note[NOTESIZ + 1], *notep;
|
char note[NOTESIZ + 1], *notep;
|
||||||
char *error =
|
|
||||||
_("FATAL ERROR in io_load_app: wrong format in the appointment or event\n");
|
|
||||||
|
|
||||||
t = time (NULL);
|
t = time (NULL);
|
||||||
lt = localtime (&t);
|
lt = localtime (&t);
|
||||||
@ -989,9 +981,7 @@ io_load_app (void)
|
|||||||
if (fscanf (data_file, "%u / %u / %u ",
|
if (fscanf (data_file, "%u / %u / %u ",
|
||||||
&start.tm_mon, &start.tm_mday, &start.tm_year) != 3)
|
&start.tm_mon, &start.tm_mday, &start.tm_year) != 3)
|
||||||
{
|
{
|
||||||
fputs (_("FATAL ERROR in io_load_app: "
|
EXIT (_("syntax error in the item date"));
|
||||||
"syntax error in the item date\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the next character : if it is an '@' then we have
|
/* Read the next character : if it is an '@' then we have
|
||||||
@ -1005,9 +995,7 @@ io_load_app (void)
|
|||||||
is_event = 1;
|
is_event = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fputs (_("FATAL ERROR in io_load_app: "
|
EXIT (_("no event nor appointment found"));
|
||||||
"no event nor appointment found\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
ungetc (c, data_file);
|
ungetc (c, data_file);
|
||||||
|
|
||||||
@ -1024,9 +1012,9 @@ io_load_app (void)
|
|||||||
fscanf (data_file, "[%d] ", &id);
|
fscanf (data_file, "[%d] ", &id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* NOT REACHED */
|
{
|
||||||
fputs (error, stderr);
|
EXIT (_("wrong format in the appointment or event"));
|
||||||
exit (EXIT_FAILURE);
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we have a recursive item. */
|
/* Check if we have a recursive item. */
|
||||||
@ -1071,9 +1059,9 @@ io_load_app (void)
|
|||||||
until.tm_year = 0;
|
until.tm_year = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* NOT REACHED */
|
{
|
||||||
fputs (error, stderr);
|
EXIT (_("wrong format in the appointment or event"));
|
||||||
exit (EXIT_FAILURE);
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1136,9 +1124,9 @@ io_load_app (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* NOT REACHED */
|
{
|
||||||
fputs (error, stderr);
|
EXIT (_("wrong format in the appointment or event"));
|
||||||
exit (EXIT_FAILURE);
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (data_file);
|
fclose (data_file);
|
||||||
@ -1469,16 +1457,13 @@ void
|
|||||||
io_export_data (export_type_t type, conf_t *conf)
|
io_export_data (export_type_t type, conf_t *conf)
|
||||||
{
|
{
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
char *wrong_mode = _("FATAL ERROR in io_export_data: wrong export mode\n");
|
|
||||||
char *wrong_type = _("FATAL ERROR in io_export_data: unknown export type\n");
|
|
||||||
char *success = _("The data were successfully exported");
|
char *success = _("The data were successfully exported");
|
||||||
char *enter = _("Press [ENTER] to continue");
|
char *enter = _("Press [ENTER] to continue");
|
||||||
|
|
||||||
if (type < IO_EXPORT_ICAL || type >= IO_EXPORT_NBTYPES)
|
if (type < IO_EXPORT_ICAL || type >= IO_EXPORT_NBTYPES)
|
||||||
{
|
EXIT (_("unknown export type"));
|
||||||
fputs (wrong_type, stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
stream = 0;
|
||||||
}
|
|
||||||
switch (ui_mode)
|
switch (ui_mode)
|
||||||
{
|
{
|
||||||
case UI_CMDLINE:
|
case UI_CMDLINE:
|
||||||
@ -1488,12 +1473,11 @@ io_export_data (export_type_t type, conf_t *conf)
|
|||||||
stream = get_export_stream (type);
|
stream = get_export_stream (type);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (wrong_mode, stderr);
|
EXIT (_("wrong export mode"));
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream == NULL)
|
if (stream == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cb_export_header[type] (stream);
|
cb_export_header[type] (stream);
|
||||||
|
65
src/recur.c
65
src/recur.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: recur.c,v 1.44 2008/12/14 11:24:19 culot Exp $ */
|
/* $calcurse: recur.c,v 1.45 2008/12/14 15:54:51 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -127,7 +127,6 @@ char
|
|||||||
recur_def2char (recur_types_t define)
|
recur_def2char (recur_types_t define)
|
||||||
{
|
{
|
||||||
char recur_char;
|
char recur_char;
|
||||||
char *error = _("FATAL ERROR in recur_def2char: unknown recur type\n");
|
|
||||||
|
|
||||||
switch (define)
|
switch (define)
|
||||||
{
|
{
|
||||||
@ -144,8 +143,8 @@ recur_def2char (recur_types_t define)
|
|||||||
recur_char = 'Y';
|
recur_char = 'Y';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (error, stderr);
|
EXIT (_("unknown repetition type"));
|
||||||
exit (EXIT_FAILURE);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (recur_char);
|
return (recur_char);
|
||||||
@ -159,7 +158,6 @@ int
|
|||||||
recur_char2def (char type)
|
recur_char2def (char type)
|
||||||
{
|
{
|
||||||
int recur_def;
|
int recur_def;
|
||||||
char *error = _("FATAL ERROR in recur_char2def: unknown char\n");
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -176,8 +174,8 @@ recur_char2def (char type)
|
|||||||
recur_def = RECUR_YEARLY;
|
recur_def = RECUR_YEARLY;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (error, stderr);
|
EXIT (_("unknown character"));
|
||||||
exit (EXIT_FAILURE);
|
return 0;
|
||||||
}
|
}
|
||||||
return (recur_def);
|
return (recur_def);
|
||||||
}
|
}
|
||||||
@ -245,13 +243,8 @@ recur_apoint_scan (FILE *f, struct tm start, struct tm end, char type,
|
|||||||
{
|
{
|
||||||
tuntil = 0;
|
tuntil = 0;
|
||||||
}
|
}
|
||||||
|
EXIT_IF (tstart == -1 || tend == -1 || tstart > tend || tuntil == -1,
|
||||||
if (tstart == -1 || tend == -1 || tstart > tend || tuntil == -1)
|
_("date error in appointment"));
|
||||||
{
|
|
||||||
fputs (_("FATAL ERROR in apoint_scan: date error in the appointment\n"),
|
|
||||||
stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (recur_apoint_new (buf, note, tstart, tend - tstart, state,
|
return (recur_apoint_new (buf, note, tstart, tend - tstart, state,
|
||||||
recur_char2def (type), freq, tuntil, exc));
|
recur_char2def (type), freq, tuntil, exc));
|
||||||
@ -293,12 +286,8 @@ recur_event_scan (FILE *f, struct tm start, int id, char type, int freq,
|
|||||||
tuntil = 0;
|
tuntil = 0;
|
||||||
}
|
}
|
||||||
tstart = mktime (&start);
|
tstart = mktime (&start);
|
||||||
if ((tstart == -1) || (tuntil == -1))
|
EXIT_IF (tstart == -1 || tuntil == -1,
|
||||||
{
|
_("date error in event"));
|
||||||
fputs (_("FATAL ERROR in recur_event_scan: "
|
|
||||||
"date error in the event\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (recur_event_new (buf, note, tstart, id, recur_char2def (type),
|
return (recur_event_new (buf, note, tstart, id, recur_char2def (type),
|
||||||
freq, tuntil, exc));
|
freq, tuntil, exc));
|
||||||
@ -418,7 +407,6 @@ recur_item_inday (long item_start, struct days_s *item_exc, int rpt_type,
|
|||||||
struct tm lt_item, lt_day;
|
struct tm lt_item, lt_day;
|
||||||
struct days_s *exc;
|
struct days_s *exc;
|
||||||
time_t t;
|
time_t t;
|
||||||
char *error = _("FATAL ERROR in recur_item_inday: unknown item type\n");
|
|
||||||
|
|
||||||
day_end = day_start + DAYINSEC;
|
day_end = day_start + DAYINSEC;
|
||||||
t = day_start;
|
t = day_start;
|
||||||
@ -475,8 +463,7 @@ recur_item_inday (long item_start, struct days_s *item_exc, int rpt_type,
|
|||||||
lt_item.tm_year = lt_day.tm_year;
|
lt_item.tm_year = lt_day.tm_year;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fputs (error, stderr);
|
EXIT (_("unknown item type"));
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
start_date.dd = lt_item.tm_mday;
|
start_date.dd = lt_item.tm_mday;
|
||||||
start_date.mm = lt_item.tm_mon + 1;
|
start_date.mm = lt_item.tm_mon + 1;
|
||||||
@ -546,9 +533,8 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
|
|||||||
}
|
}
|
||||||
iptr = &i->next;
|
iptr = &i->next;
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
EXIT (_("event not found"));
|
||||||
fputs (_("FATAL ERROR in recur_event_erase: no such event\n"), stderr);
|
/* NOTREACHED */
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -618,10 +604,8 @@ recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
|
|||||||
}
|
}
|
||||||
iptr = &i->next;
|
iptr = &i->next;
|
||||||
}
|
}
|
||||||
|
EXIT (_("appointment not found"));
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
fputs (_("FATAL ERROR in recur_apoint_erase: no such appointment\n"),
|
|
||||||
stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -768,10 +752,9 @@ recur_repeat_item (conf_t *conf)
|
|||||||
notify_check_repeated (ra);
|
notify_check_repeated (ra);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* NOTREACHED */
|
{
|
||||||
fputs (_("FATAL ERROR in recur_repeat_item: wrong item type\n"),
|
EXIT (_("wrong item type"));
|
||||||
stderr);
|
/* NOTREACHED */
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
day_erase_item (date, item_nb, ERASE_FORCE_KEEP_NOTE);
|
day_erase_item (date, item_nb, ERASE_FORCE_KEEP_NOTE);
|
||||||
}
|
}
|
||||||
@ -798,9 +781,7 @@ recur_exc_scan (FILE *data_file)
|
|||||||
if (fscanf (data_file, "!%u / %u / %u ",
|
if (fscanf (data_file, "!%u / %u / %u ",
|
||||||
&day.tm_mon, &day.tm_mday, &day.tm_year) != 3)
|
&day.tm_mon, &day.tm_mday, &day.tm_year) != 3)
|
||||||
{
|
{
|
||||||
fputs (_("FATAL ERROR in recur_exc_scan: "
|
EXIT (_("syntax error in item date"));
|
||||||
"syntax error in the item date\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
day.tm_sec = 0;
|
day.tm_sec = 0;
|
||||||
day.tm_isdst = -1;
|
day.tm_isdst = -1;
|
||||||
@ -872,9 +853,9 @@ recur_get_apoint (long date, int num)
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EXIT (_("item not found"));
|
||||||
|
return 0;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
fputs (_("FATAL ERROR in recur_get_apoint: no such item\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a structure containing the selected recurrent event. */
|
/* Returns a structure containing the selected recurrent event. */
|
||||||
@ -896,9 +877,9 @@ recur_get_event (long date, int num)
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EXIT (_("item not found"));
|
||||||
|
return 0;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
fputs (_("FATAL ERROR in recur_get_event: no such item\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Switch recurrent item notification state. */
|
/* Switch recurrent item notification state. */
|
||||||
@ -932,9 +913,7 @@ recur_apoint_switch_notify (long date, int recur_nb)
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EXIT (_("item not found"));
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
fputs (_("FATAL ERROR in recur_apoint_switch_notify: no such item\n"),
|
|
||||||
stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
src/utils.c
29
src/utils.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: utils.c,v 1.58 2008/12/13 21:41:25 culot Exp $ */
|
/* $calcurse: utils.c,v 1.59 2008/12/14 15:54:51 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -40,9 +40,9 @@
|
|||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#define NB_CAL_CMDS 26 /* number of commands while in cal view */
|
#define NB_CAL_CMDS 24 /* number of commands while in cal view */
|
||||||
#define NB_APP_CMDS 30 /* same thing while in appointment view */
|
#define NB_APP_CMDS 29 /* same thing while in appointment view */
|
||||||
#define NB_TOD_CMDS 30 /* same thing while in todo view */
|
#define NB_TOD_CMDS 29 /* same thing while in todo view */
|
||||||
#define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS
|
#define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS
|
||||||
#define CMDS_PER_LINE 6 /* max number of commands per line */
|
#define CMDS_PER_LINE 6 /* max number of commands per line */
|
||||||
|
|
||||||
@ -410,7 +410,6 @@ status_bar (void)
|
|||||||
const int pos[NB_PANELS + 1] =
|
const int pos[NB_PANELS + 1] =
|
||||||
{ 0, NB_CAL_CMDS, NB_CAL_CMDS + NB_APP_CMDS, TOTAL_CMDS };
|
{ 0, NB_CAL_CMDS, NB_CAL_CMDS + NB_APP_CMDS, TOTAL_CMDS };
|
||||||
|
|
||||||
binding_t crdts = {_("Credits"), KEY_GENERIC_CREDITS};
|
|
||||||
binding_t help = {_("Help"), KEY_GENERIC_HELP};
|
binding_t help = {_("Help"), KEY_GENERIC_HELP};
|
||||||
binding_t quit = {_("Quit"), KEY_GENERIC_QUIT};
|
binding_t quit = {_("Quit"), KEY_GENERIC_QUIT};
|
||||||
binding_t save = {_("Save"), KEY_GENERIC_SAVE};
|
binding_t save = {_("Save"), KEY_GENERIC_SAVE};
|
||||||
@ -449,15 +448,15 @@ status_bar (void)
|
|||||||
/* calendar keys */
|
/* calendar keys */
|
||||||
&help, &quit, &save, &chgvu, &import, &export, &up, &down, &left, &right,
|
&help, &quit, &save, &chgvu, &import, &export, &up, &down, &left, &right,
|
||||||
&togo, &othr, &weekb, &weeke, &conf, &draw, &appt, &todo, &gnday, &gpday,
|
&togo, &othr, &weekb, &weeke, &conf, &draw, &appt, &todo, &gnday, &gpday,
|
||||||
&gnweek, &gpweek, &today, &othr, &crdts, &othr,
|
&gnweek, &gpweek, &today, &othr,
|
||||||
/* appointment keys */
|
/* appointment keys */
|
||||||
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
|
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
|
||||||
&draw, &othr, &rept, &flag, &enote, &vnote, &up, &down, &gnday, &gpday,
|
&draw, &othr, &rept, &flag, &enote, &vnote, &up, &down, &gnday, &gpday,
|
||||||
&gnweek, &gpweek, &togo, &othr, &today, &conf, &appt, &todo, &crdts, &othr,
|
&gnweek, &gpweek, &togo, &othr, &today, &conf, &appt, &todo, &othr,
|
||||||
/* todo keys */
|
/* todo keys */
|
||||||
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
|
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
|
||||||
&draw, &othr, &rprio, &lprio, &enote, &vnote, &up, &down, &gnday, &gpday,
|
&draw, &othr, &rprio, &lprio, &enote, &vnote, &up, &down, &gnday, &gpday,
|
||||||
&gnweek, &gpweek, &togo, &othr, &today, &conf, &appt, &todo, &crdts, &othr
|
&gnweek, &gpweek, &togo, &othr, &today, &conf, &appt, &todo, &othr
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Drawing the keybinding with attribute and label without. */
|
/* Drawing the keybinding with attribute and label without. */
|
||||||
@ -487,13 +486,7 @@ date2sec (date_t day, unsigned hour, unsigned min)
|
|||||||
start.tm_year -= 1900;
|
start.tm_year -= 1900;
|
||||||
start.tm_mon--;
|
start.tm_mon--;
|
||||||
tstart = mktime (&start);
|
tstart = mktime (&start);
|
||||||
if (tstart == -1)
|
EXIT_IF (tstart == -1, _("failure in mktime"));
|
||||||
{
|
|
||||||
fputs (_("FATAL ERROR in date2sec: failure in mktime\n"), stderr);
|
|
||||||
fprintf (stderr, "%u %u %u %u %u\n", day.yyyy, day.mm, day.dd,
|
|
||||||
hour, min);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (tstart);
|
return (tstart);
|
||||||
}
|
}
|
||||||
@ -563,11 +556,7 @@ date_sec_change (long date, int delta_month, int delta_day)
|
|||||||
lt->tm_mday += delta_day;
|
lt->tm_mday += delta_day;
|
||||||
lt->tm_isdst = -1;
|
lt->tm_isdst = -1;
|
||||||
t = mktime (lt);
|
t = mktime (lt);
|
||||||
if (t == -1)
|
EXIT_IF (t == -1, _("failure in mktime"));
|
||||||
{
|
|
||||||
fputs (_("FATAL ERROR in date_sec_change: failure in mktime\n"), stderr);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user