aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/calcurse.c6
-rw-r--r--src/calcurse.h5
-rw-r--r--src/custom.c7
-rw-r--r--src/day.c10
-rw-r--r--src/ical.c52
-rw-r--r--src/utils.c23
6 files changed, 34 insertions, 69 deletions
diff --git a/src/calcurse.c b/src/calcurse.c
index caabafa..a8dace1 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -49,8 +49,8 @@ int count, reg;
*/
static struct day_items_nb do_storage(int day_changed)
{
- struct day_items_nb inday = *day_process_storage(calendar_get_slctd_day(),
- day_changed, &inday);
+ struct day_items_nb inday = day_process_storage(calendar_get_slctd_day(),
+ day_changed);
if (day_changed) {
if ((inday.nb_events + inday.nb_apoints) > 0)
@@ -579,7 +579,7 @@ int main(int argc, char **argv)
wins_update(FLAG_ALL);
io_startup_screen(no_data_file);
}
- inday = *day_process_storage(0, 0, &inday);
+ inday = day_process_storage(0, 0);
wins_slctd_set(conf.default_panel);
wins_update(FLAG_ALL);
diff --git a/src/calcurse.h b/src/calcurse.h
index cb03a51..dd974a8 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -684,8 +684,7 @@ int day_item_get_state(struct day_item *);
void day_item_add_exc(struct day_item *, long);
void day_item_fork(struct day_item *, struct day_item *);
int day_store_items(long, unsigned *, unsigned *, regex_t *);
-struct day_items_nb *day_process_storage(struct date *, unsigned,
- struct day_items_nb *);
+struct day_items_nb day_process_storage(struct date *, unsigned);
void day_write_pad(long, int, int, int);
void day_write_stdout(long, const char *, const char *, const char *,
const char *);
@@ -971,14 +970,12 @@ void item_in_popup(const char *, const char *, const char *, const char *);
long get_today(void);
long now(void);
char *nowstr(void);
-long mystrtol(const char *);
void print_bool_option_incolor(WINDOW *, unsigned, int, int);
const char *get_tempdir(void);
char *new_tempfile(const char *, int);
int parse_date(const char *, enum datefmt, int *, int *, int *, struct date *);
int parse_time(const char *, unsigned *, unsigned *);
int parse_duration(const char *, unsigned *);
-void str_toupper(char *);
void file_close(FILE *, const char *);
void psleep(unsigned);
int fork_exec(int *, int *, const char *, const char *const *);
diff --git a/src/custom.c b/src/custom.c
index a4365ac..df344c2 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -231,7 +231,7 @@ void custom_layout_config(void)
switch (ch) {
case KEY_GENERIC_HELP:
help_wins_init(&hwin, 0, 0, (notify_bar())? row - 3 : row - 2, col);
- mvwaddstr(hwin.pad.p, 1, 0, help_text);
+ mvwprintw(hwin.pad.p, 1, 0, help_text, SBARMINWIDTH);
hwin.total_lines = 7;
wins_scrollwin_display(&hwin);
wgetch(hwin.win.p);
@@ -295,13 +295,12 @@ void custom_sidebar_config(void)
};
const char *help_text =
_
- /* xgettext:no-c-format */
("This configuration screen is used to change the width of the side bar.\n"
"The side bar is the part of the screen which contains two panels:\n"
"the calendar and, depending on the chosen layout, either the todo list\n"
"or the appointment list.\n\n"
- "The side bar width can be up to 50% of the total screen width, but\n"
- "can't be smaller than " TOSTRING(SBARMINWIDTH) " characters wide.\n\n");
+ "The side bar width can be up to 50%% of the total screen width, but\n"
+ "can't be smaller than %d characters wide.\n\n");
int ch, bindings_size;
bindings_size = sizeof(bindings) / sizeof(bindings[0]);
diff --git a/src/day.c b/src/day.c
index 189875f..4c2f5bf 100644
--- a/src/day.c
+++ b/src/day.c
@@ -360,12 +360,12 @@ day_store_items(long date, unsigned *pnb_events, unsigned *pnb_apoints,
* those items in a pad. If selected day is null, then store items for current
* day. This is useful to speed up the appointment panel update.
*/
-struct day_items_nb *day_process_storage(struct date *slctd_date,
- unsigned day_changed,
- struct day_items_nb *inday)
+struct day_items_nb day_process_storage(struct date *slctd_date,
+ unsigned day_changed)
{
long date;
struct date day;
+ struct day_items_nb inday;
if (slctd_date)
day = *slctd_date;
@@ -379,8 +379,8 @@ struct day_items_nb *day_process_storage(struct date *slctd_date,
delwin(apad.ptrwin);
/* Store the events and appointments (recursive and normal items). */
- day_store_items(date, &inday->nb_events, &inday->nb_apoints, NULL);
- apad.length = (inday->nb_events + 1 + 3 * inday->nb_apoints);
+ day_store_items(date, &inday.nb_events, &inday.nb_apoints, NULL);
+ apad.length = (inday.nb_events + 1 + 3 * inday.nb_apoints);
/* Create the new pad with its new length. */
if (day_changed)
diff --git a/src/ical.c b/src/ical.c
index ea8afaa..b716c8d 100644
--- a/src/ical.c
+++ b/src/ical.c
@@ -34,6 +34,7 @@
*
*/
+#include <strings.h>
#include <sys/types.h>
#include "calcurse.h"
@@ -428,8 +429,7 @@ ical_chk_header(FILE * fd, char *buf, char *lstore, unsigned *lineno,
if (!ical_readline(fd, buf, lstore, lineno))
return 0;
- str_toupper(buf);
- if (strncmp(buf, icalheader, sizeof(icalheader) - 1) != 0)
+ if (strncasecmp(buf, icalheader, sizeof(icalheader) - 1) != 0)
return 0;
while (!sscanf(buf, "VERSION:%d.%d", major, minor)) {
@@ -830,7 +830,7 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, unsigned *noapoints,
const char endalarm[] = "END:VALARM";
const char desc[] = "DESCRIPTION";
ical_vevent_e vevent_type;
- char *p, buf_upper[BUFSIZ];
+ char *p;
struct {
llist_t exc;
ical_rpt_t *rpt;
@@ -844,18 +844,14 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, unsigned *noapoints,
memset(&vevent, 0, sizeof vevent);
skip_alarm = 0;
while (ical_readline(fdi, buf, lstore, lineno)) {
- strncpy(buf_upper, buf, BUFSIZ);
- buf_upper[BUFSIZ - 1] = '\0';
- str_toupper(buf_upper);
-
if (skip_alarm) {
/* Need to skip VALARM properties because some keywords could
interfere, such as DURATION, SUMMARY,.. */
- if (strncmp(buf_upper, endalarm, sizeof(endalarm) - 1) == 0)
+ if (strncasecmp(buf, endalarm, sizeof(endalarm) - 1) == 0)
skip_alarm = 0;
continue;
}
- if (strncmp(buf_upper, endevent, sizeof(endevent) - 1) == 0) {
+ if (strncasecmp(buf, endevent, sizeof(endevent) - 1) == 0) {
if (vevent.mesg) {
if (vevent.rpt && vevent.rpt->count)
vevent.rpt->until = ical_compute_rpt_until(vevent.start, vevent.rpt);
@@ -917,7 +913,7 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, unsigned *noapoints,
}
return;
} else {
- if (strncmp(buf_upper, dtstart, sizeof(dtstart) - 1) == 0) {
+ if (strncasecmp(buf, dtstart, sizeof(dtstart) - 1) == 0) {
if ((p = strchr(buf, ':')) != NULL)
vevent.start = ical_datetime2long(++p, &vevent_type);
if (!vevent.start) {
@@ -925,7 +921,7 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, unsigned *noapoints,
_("could not retrieve event start time."));
goto cleanup;
}
- } else if (strncmp(buf_upper, dtend, sizeof(dtend) - 1) == 0) {
+ } else if (strncasecmp(buf, dtend, sizeof(dtend) - 1) == 0) {
if ((p = strchr(buf, ':')) != NULL)
vevent.end = ical_datetime2long(++p, &vevent_type);
if (!vevent.end) {
@@ -933,21 +929,21 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, unsigned *noapoints,
_("could not retrieve event end time."));
goto cleanup;
}
- } else if (strncmp(buf_upper, duration, sizeof(duration) - 1) == 0) {
+ } else if (strncasecmp(buf, duration, sizeof(duration) - 1) == 0) {
if ((vevent.dur = ical_dur2long(buf)) <= 0) {
ical_log(log, ICAL_VEVENT, ITEMLINE, _("item duration malformed."));
goto cleanup;
}
- } else if (strncmp(buf_upper, rrule, sizeof(rrule) - 1) == 0) {
+ } else if (strncasecmp(buf, rrule, sizeof(rrule) - 1) == 0) {
vevent.rpt = ical_read_rrule(log, buf, noskipped, ITEMLINE);
- } else if (strncmp(buf_upper, exdate, sizeof(exdate) - 1) == 0) {
+ } else if (strncasecmp(buf, exdate, sizeof(exdate) - 1) == 0) {
ical_read_exdate(&vevent.exc, log, buf, noskipped, ITEMLINE);
- } else if (strncmp(buf_upper, summary, sizeof(summary) - 1) == 0) {
+ } else if (strncasecmp(buf, summary, sizeof(summary) - 1) == 0) {
vevent.mesg = ical_read_summary(buf);
- } else if (strncmp(buf_upper, alarm, sizeof(alarm) - 1) == 0) {
+ } else if (strncasecmp(buf, alarm, sizeof(alarm) - 1) == 0) {
skip_alarm = 1;
vevent.has_alarm = 1;
- } else if (strncmp(buf_upper, desc, sizeof(desc) - 1) == 0) {
+ } else if (strncasecmp(buf, desc, sizeof(desc) - 1) == 0) {
vevent.note = ical_read_note(buf, noskipped, ICAL_VEVENT,
ITEMLINE, log);
}
@@ -980,7 +976,6 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
const char desc[] = "DESCRIPTION";
const int LOWEST = 9;
const int ITEMLINE = *lineno;
- char buf_upper[BUFSIZ];
struct {
char *mesg, *note;
int has_priority, priority;
@@ -990,17 +985,14 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
memset(&vtodo, 0, sizeof vtodo);
skip_alarm = 0;
while (ical_readline(fdi, buf, lstore, lineno)) {
- strncpy(buf_upper, buf, BUFSIZ);
- buf_upper[BUFSIZ - 1] = '\0';
- str_toupper(buf_upper);
if (skip_alarm) {
/* Need to skip VALARM properties because some keywords could
interfere, such as DURATION, SUMMARY,.. */
- if (strncmp(buf_upper, endalarm, sizeof(endalarm) - 1) == 0)
+ if (strncasecmp(buf, endalarm, sizeof(endalarm) - 1) == 0)
skip_alarm = 0;
continue;
}
- if (strncmp(buf_upper, endtodo, sizeof(endtodo) - 1) == 0) {
+ if (strncasecmp(buf, endtodo, sizeof(endtodo) - 1) == 0) {
if (!vtodo.has_priority)
vtodo.priority = LOWEST;
if (vtodo.mesg) {
@@ -1015,7 +1007,8 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
} else {
int tmpint;
- if (sscanf(buf_upper, "PRIORITY:%d", &tmpint) == 1) {
+ if (strncasecmp(buf, "PRIORITY:", sizeof("PRIORITY:") - 1) == 0) {
+ sscanf(buf, "%d", &tmpint);
if (tmpint <= 9 && tmpint >= 1) {
vtodo.priority = tmpint;
vtodo.has_priority = 1;
@@ -1025,11 +1018,11 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
"(must be between 1 and 9)."));
vtodo.priority = LOWEST;
}
- } else if (strncmp(buf_upper, summary, sizeof(summary) - 1) == 0) {
+ } else if (strncasecmp(buf, summary, sizeof(summary) - 1) == 0) {
vtodo.mesg = ical_read_summary(buf);
- } else if (strncmp(buf_upper, alarm, sizeof(alarm) - 1) == 0) {
+ } else if (strncasecmp(buf, alarm, sizeof(alarm) - 1) == 0) {
skip_alarm = 1;
- } else if (strncmp(buf_upper, desc, sizeof(desc) - 1) == 0) {
+ } else if (strncasecmp(buf, desc, sizeof(desc) - 1) == 0) {
vtodo.note = ical_read_note(buf, noskipped, ICAL_VTODO, ITEMLINE, log);
}
}
@@ -1066,11 +1059,10 @@ ical_import_data(FILE * stream, FILE * log, unsigned *events, unsigned *apoints,
while (ical_readline(stream, buf, lstore, lines)) {
(*lines)++;
- str_toupper(buf);
- if (strncmp(buf, vevent, sizeof(vevent) - 1) == 0) {
+ if (strncasecmp(buf, vevent, sizeof(vevent) - 1) == 0) {
ical_read_event(stream, log, events, apoints, skipped, buf, lstore,
lines);
- } else if (strncmp(buf, vtodo, sizeof(vtodo) - 1) == 0) {
+ } else if (strncasecmp(buf, vtodo, sizeof(vtodo) - 1) == 0) {
ical_read_todo(stream, log, todos, skipped, buf, lstore, lines);
}
}
diff --git a/src/utils.c b/src/utils.c
index 47d8d57..76cdba6 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -561,21 +561,6 @@ char *nowstr(void)
return buf;
}
-long mystrtol(const char *str)
-{
- char *ep;
- long lval;
-
- errno = 0;
- lval = strtol(str, &ep, 10);
- if (str[0] == '\0' || *ep != '\0')
- EXIT(_("could not convert string"));
- if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
- EXIT(_("out of range"));
-
- return lval;
-}
-
/* Print the given option value with appropriate color. */
void
print_bool_option_incolor(WINDOW * win, unsigned option, int pos_y, int pos_x)
@@ -860,14 +845,6 @@ int parse_duration(const char *string, unsigned *duration)
return 1;
}
-void str_toupper(char *s)
-{
- if (!s)
- return;
- for (; *s; s++)
- *s = toupper(*s);
-}
-
void file_close(FILE * f, const char *pos)
{
EXIT_IF((fclose(f)) != 0, _("Error when closing file at %s"), pos);