aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apoint.c29
-rw-r--r--src/calcurse.h15
-rw-r--r--src/day.c8
-rw-r--r--src/event.c13
-rw-r--r--src/recur.c44
5 files changed, 27 insertions, 82 deletions
diff --git a/src/apoint.c b/src/apoint.c
index a308b26..b00bc8a 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -213,34 +213,21 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, char state,
return apoint_new(buf, note, tstart, tend - tstart, state);
}
-void apoint_delete(struct apoint *apt, enum eraseflg flag)
+void apoint_delete(struct apoint *apt)
{
- int need_check_notify = 0;
-
LLIST_TS_LOCK(&alist_p);
+
llist_item_t *i = LLIST_TS_FIND_FIRST(&alist_p, apt, NULL);
+ int need_check_notify = 0;
if (!i)
EXIT(_("no such appointment"));
- switch (flag) {
- case ERASE_CUT:
- if (notify_bar())
- need_check_notify = notify_same_item(apt->start);
- LLIST_TS_REMOVE(&alist_p, i);
- if (need_check_notify)
- notify_check_next_app(0);
- break;
- default:
- if (notify_bar())
- need_check_notify = notify_same_item(apt->start);
- LLIST_TS_REMOVE(&alist_p, i);
- mem_free(apt->mesg);
- mem_free(apt);
- if (need_check_notify)
- notify_check_next_app(0);
- break;
- }
+ if (notify_bar())
+ need_check_notify = notify_same_item(apt->start);
+ LLIST_TS_REMOVE(&alist_p, i);
+ if (need_check_notify)
+ notify_check_next_app(0);
LLIST_TS_UNLOCK(&alist_p);
}
diff --git a/src/calcurse.h b/src/calcurse.h
index 4c3d1d1..8b99c04 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -519,13 +519,6 @@ enum item_type {
MAX_TYPES = APPT
};
-/* Flags used to adapt processing when erasing an item. */
-enum eraseflg {
- ERASE_DONT_FORCE,
- ERASE_FORCE,
- ERASE_CUT
-};
-
/* Return codes for the getstring() function. */
enum getstr {
GETSTRING_VALID,
@@ -608,7 +601,7 @@ unsigned apoint_inday(struct apoint *, long *);
void apoint_sec2str(struct apoint *, long, char *, char *);
void apoint_write(struct apoint *, FILE *);
struct apoint *apoint_scan(FILE *, struct tm, struct tm, char, char *);
-void apoint_delete(struct apoint *, enum eraseflg);
+void apoint_delete(struct apoint *);
void apoint_scroll_pad_down(int, int);
void apoint_scroll_pad_up(int);
struct notify_app *apoint_check_next(struct notify_app *, long);
@@ -703,7 +696,7 @@ struct event *event_new(char *, char *, long, int);
unsigned event_inday(struct event *, long *);
void event_write(struct event *, FILE *);
struct event *event_scan(FILE *, struct tm, int, char *);
-void event_delete(struct event *, enum eraseflg);
+void event_delete(struct event *);
void event_paste_item(struct event *, long);
/* help.c */
@@ -888,8 +881,8 @@ unsigned recur_apoint_inday(struct recur_apoint *, long *);
unsigned recur_event_inday(struct recur_event *, long *);
void recur_event_add_exc(struct recur_event *, long);
void recur_apoint_add_exc(struct recur_apoint *, long);
-void recur_event_erase(struct recur_event *, enum eraseflg);
-void recur_apoint_erase(struct recur_apoint *, enum eraseflg);
+void recur_event_erase(struct recur_event *);
+void recur_apoint_erase(struct recur_apoint *);
void recur_exc_scan(llist_t *, FILE *);
struct notify_app *recur_apoint_check_next(struct notify_app *, long, long);
void recur_apoint_switch_notify(struct recur_apoint *);
diff --git a/src/day.c b/src/day.c
index bb949dc..978e9d2 100644
--- a/src/day.c
+++ b/src/day.c
@@ -656,16 +656,16 @@ struct day_item *day_cut_item(long date, int item_number)
switch (p->type) {
case EVNT:
- event_delete(p->item.ev, ERASE_CUT);
+ event_delete(p->item.ev);
break;
case RECUR_EVNT:
- recur_event_erase(p->item.rev, ERASE_CUT);
+ recur_event_erase(p->item.rev);
break;
case APPT:
- apoint_delete(p->item.apt, ERASE_CUT);
+ apoint_delete(p->item.apt);
break;
case RECUR_APPT:
- recur_apoint_erase(p->item.rapt, ERASE_CUT);
+ recur_apoint_erase(p->item.rapt);
break;
default:
EXIT(_("unknwon type"));
diff --git a/src/event.c b/src/event.c
index b53ec2f..561c299 100644
--- a/src/event.c
+++ b/src/event.c
@@ -150,23 +150,14 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note)
}
/* Delete an event from the list. */
-void event_delete(struct event *ev, enum eraseflg flag)
+void event_delete(struct event *ev)
{
llist_item_t *i = LLIST_FIND_FIRST(&eventlist, ev, NULL);
if (!i)
EXIT(_("no such appointment"));
- switch (flag) {
- case ERASE_CUT:
- LLIST_REMOVE(&eventlist, i);
- break;
- default:
- LLIST_REMOVE(&eventlist, i);
- mem_free(ev->mesg);
- mem_free(ev);
- break;
- }
+ LLIST_REMOVE(&eventlist, i);
}
void event_paste_item(struct event *ev, long date)
diff --git a/src/recur.c b/src/recur.c
index 335cbf6..3338017 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -697,28 +697,14 @@ recur_apoint_add_exc(struct recur_apoint *rapt, long date)
* or delete only one occurence of the recurrent event.
*/
void
-recur_event_erase(struct recur_event *rev, enum eraseflg flag)
+recur_event_erase(struct recur_event *rev)
{
llist_item_t *i = LLIST_FIND_FIRST(&recur_elist, rev, NULL);
if (!i)
EXIT(_("event not found"));
- switch (flag) {
- case ERASE_CUT:
- LLIST_REMOVE(&recur_elist, i);
- return;
- default:
- LLIST_REMOVE(&recur_elist, i);
- mem_free(rev->mesg);
- if (rev->rpt) {
- mem_free(rev->rpt);
- rev->rpt = 0;
- }
- free_exc_list(&rev->exc);
- mem_free(rev);
- break;
- }
+ LLIST_REMOVE(&recur_elist, i);
}
/*
@@ -726,34 +712,22 @@ recur_event_erase(struct recur_event *rev, enum eraseflg flag)
* or delete only one occurence of the recurrent appointment.
*/
void
-recur_apoint_erase(struct recur_apoint *rapt, enum eraseflg flag)
+recur_apoint_erase(struct recur_apoint *rapt)
{
+ LLIST_TS_LOCK(&recur_alist_p);
+
llist_item_t *i = LLIST_TS_FIND_FIRST(&recur_alist_p, rapt, NULL);
int need_check_notify = 0;
if (!i)
EXIT(_("appointment not found"));
- LLIST_TS_LOCK(&recur_alist_p);
if (notify_bar())
need_check_notify = notify_same_recur_item(rapt);
- switch (flag) {
- case ERASE_CUT:
- LLIST_TS_REMOVE(&recur_alist_p, i);
- break;
- default:
- LLIST_TS_REMOVE(&recur_alist_p, i);
- mem_free(rapt->mesg);
- if (rapt->rpt) {
- mem_free(rapt->rpt);
- rapt->rpt = 0;
- }
- free_exc_list(&rapt->exc);
- mem_free(rapt);
- if (need_check_notify)
- notify_check_next_app(0);
- break;
- }
+ LLIST_TS_REMOVE(&recur_alist_p, i);
+ if (need_check_notify)
+ notify_check_next_app(0);
+
LLIST_TS_UNLOCK(&recur_alist_p);
}