diff --git a/src/calendar.c b/src/calendar.c index a067e1d3..ff2864cd 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -591,10 +591,11 @@ static int DoCalRem(ParsePtr p, int col) CalEntry *CurPs = CalPs[col]; CalEntry *e; char *s, *s2; - DynamicBuffer buf, obuf; + DynamicBuffer buf, obuf, pre_buf; Token tok; DBufInit(&buf); + DBufInit(&pre_buf); /* Parse the trigger date and time */ if ( (r=ParseRem(p, &trig, &tim)) ) return r; @@ -638,21 +639,28 @@ static int DoCalRem(ParsePtr p, int col) strcpy(trig.passthru, "PSFile"); trig.typ = PASSTHRU_TYPE; } - if (!PsCal) { - if (trig.typ == PASSTHRU_TYPE) { - if (strcmp(trig.passthru, "COLOR")) return OK; - /* Strip off the three color numbers */ - DBufFree(&buf); - r=ParseToken(p, &buf); - DBufFree(&buf); - if (r) return r; - r=ParseToken(p, &buf); - DBufFree(&buf); - if (r) return r; - r=ParseToken(p, &buf); - DBufFree(&buf); - if (r) return r; - } + if (trig.typ == PASSTHRU_TYPE) { + if (!PsCal && strcmp(trig.passthru, "COLOR")) return OK; + /* Strip off the three color numbers */ + DBufFree(&buf); + r=ParseToken(p, &buf); + DBufPuts(&pre_buf, DBufValue(&buf)); + DBufPutc(&pre_buf, ' '); + DBufFree(&buf); + if (r) return r; + r=ParseToken(p, &buf); + DBufPuts(&pre_buf, DBufValue(&buf)); + DBufPutc(&pre_buf, ' '); + DBufFree(&buf); + if (r) return r; + r=ParseToken(p, &buf); + DBufPuts(&pre_buf, DBufValue(&buf)); + DBufPutc(&pre_buf, ' '); + DBufFree(&buf); + if (r) return r; + if (!PsCal && !DoSimpleCalendar) { + DBufFree(&pre_buf); + } } /* Remove any "at" times from PS or PSFILE reminders */ @@ -674,11 +682,13 @@ static int DoCalRem(ParsePtr p, int col) if (jul != JulianToday) { if (DBufPuts(&obuf, SimpleTime(NO_TIME)) != OK) { DBufFree(&obuf); + DBufFree(&pre_buf); return E_NO_MEM; } } else { if (DBufPuts(&obuf, SimpleTime(tim.ttime)) != OK) { DBufFree(&obuf); + DBufFree(&pre_buf); return E_NO_MEM; } } @@ -694,6 +704,7 @@ static int DoCalRem(ParsePtr p, int col) if (DBufPuts(&obuf, v.v.str) != OK) { DestroyValue(v); DBufFree(&obuf); + DBufFree(&pre_buf); return E_NO_MEM; } } @@ -710,11 +721,13 @@ static int DoCalRem(ParsePtr p, int col) r = DoSubst(p, &obuf, &trig, &tim, jul, CAL_MODE); } if (r) { + DBufFree(&pre_buf); DBufFree(&obuf); return r; } if (DBufLen(&obuf) <= oldLen) { DBufFree(&obuf); + DBufFree(&pre_buf); return OK; } if (trig.typ != PASSTHRU_TYPE && @@ -728,6 +741,7 @@ static int DoCalRem(ParsePtr p, int col) if (DBufPuts(&obuf, v.v.str) != OK) { DestroyValue(v); DBufFree(&obuf); + DBufFree(&pre_buf); return E_NO_MEM; } } @@ -736,13 +750,17 @@ static int DoCalRem(ParsePtr p, int col) } s = DBufValue(&obuf); if (!DoSimpleCalendar) while (isspace(*s)) s++; + DBufPuts(&pre_buf, s); + s = DBufValue(&pre_buf); e = NEW(CalEntry); if (!e) { DBufFree(&obuf); + DBufFree(&pre_buf); return E_NO_MEM; } e->text = StrDup(s); DBufFree(&obuf); + DBufFree(&pre_buf); if (!e->text) { free(e); return E_NO_MEM; diff --git a/src/dorem.c b/src/dorem.c index 4b5796a8..4cfe591b 100644 --- a/src/dorem.c +++ b/src/dorem.c @@ -552,11 +552,13 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) char PrioExpr[25]; char tmpBuf[64]; DynamicBuffer buf, calRow; + DynamicBuffer pre_buf; char *s; Value v; DBufInit(&buf); DBufInit(&calRow); + DBufInit(&pre_buf); if (t->typ == RUN_TYPE && RunDisabled) return E_RUN_DISABLED; if ((t->typ == PASSTHRU_TYPE && strcmp(t->passthru, "COLOR")) || t->typ == CAL_TYPE || @@ -568,12 +570,18 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) if (t->typ == PASSTHRU_TYPE && !strcmp(t->passthru, "COLOR")) { /* Strip off three tokens */ r = ParseToken(p, &buf); + DBufPuts(&pre_buf, DBufValue(&buf)); + DBufPutc(&pre_buf, ' '); DBufFree(&buf); if (r) return r; r = ParseToken(p, &buf); + DBufPuts(&pre_buf, DBufValue(&buf)); + DBufPutc(&pre_buf, ' '); DBufFree(&buf); if (r) return r; r = ParseToken(p, &buf); + DBufPuts(&pre_buf, DBufValue(&buf)); + DBufPutc(&pre_buf, ' '); DBufFree(&buf); if (r) return r; t->typ = MSG_TYPE; @@ -595,12 +603,14 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) if ( (r=DoSubst(p, &buf, t, tim, jul, CAL_MODE)) ) return r; if (!DBufLen(&buf)) { DBufFree(&buf); + DBufFree(&pre_buf); return OK; } FromJulian(jul, &y, &m, &d); sprintf(tmpBuf, "%04d/%02d/%02d ", y, m+1, d); if (DBufPuts(&calRow, tmpBuf) != OK) { DBufFree(&calRow); + DBufFree(&pre_buf); return E_NO_MEM; } /* If DoSimpleCalendar==1, output *all* simple calendar fields */ @@ -608,6 +618,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) /* ignore passthru field when in NextMode */ if (DBufPuts(&calRow, "* ") != OK) { DBufFree(&calRow); + DBufFree(&pre_buf); return E_NO_MEM; } if (t->tag[0]) { @@ -617,6 +628,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) } if (DBufPuts(&calRow, tmpBuf) != OK) { DBufFree(&calRow); + DBufFree(&pre_buf); return E_NO_MEM; } if (tim->duration != NO_TIME) { @@ -626,6 +638,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) } if (DBufPuts(&calRow, tmpBuf) != OK) { DBufFree(&calRow); + DBufFree(&pre_buf); return E_NO_MEM; } if (tim->ttime != NO_TIME) { @@ -635,16 +648,19 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) } if (DBufPuts(&calRow, tmpBuf) != OK) { DBufFree(&calRow); + DBufFree(&pre_buf); return E_NO_MEM; } } if (DBufPuts(&calRow, SimpleTime(tim->ttime)) != OK) { DBufFree(&calRow); + DBufFree(&pre_buf); return E_NO_MEM; } - printf("%s%s\n", DBufValue(&calRow), DBufValue(&buf)); + printf("%s%s%s\n", DBufValue(&calRow), DBufValue(&pre_buf), DBufValue(&buf)); DBufFree(&buf); + DBufFree(&pre_buf); DBufFree(&calRow); return OK; }