diff --git a/src/calendar.c b/src/calendar.c index 72ea3d5b..da3f234d 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -286,23 +286,23 @@ static void WriteWeekHeaderLine (void); static void WritePostHeaderLine (void); static void PrintLeft (char const *s, int width, char pad); static void PrintCentered (char const *s, int width, char *pad); -static int WriteOneCalLine (int jul, int wd); +static int WriteOneCalLine (int dse, int wd); static int WriteOneColLine (int col); static void GenerateCalEntries (int col); static void WriteCalHeader (void); static void WriteCalTrailer (void); static int DoCalRem (ParsePtr p, int col); -static void WriteSimpleEntries (int col, int jul); +static void WriteSimpleEntries (int col, int dse); static void WriteTopCalLine (void); static void WriteBottomCalLine (void); static void WriteIntermediateCalLine (void); static void WriteCalDays (void); static int -DayOf(int jul) +DayOf(int dse) { int d; - FromDSE(jul, NULL, NULL, &d); + FromDSE(dse, NULL, NULL, &d); return d; } @@ -426,14 +426,14 @@ void PrintJSONKeyPairString(char const *name, char const *val) printf("\","); } -void PrintJSONKeyPairDate(char const *name, int jul) +void PrintJSONKeyPairDate(char const *name, int dse) { int y, m, d; - if (jul == NO_DATE) { + if (dse == NO_DATE) { /* Skip it! */ return; } - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); printf("\""); PrintJSONString(name); printf("\":\"%04d-%02d-%02d\",", y, m+1, d); @@ -714,7 +714,7 @@ InitMoonsAndShades(void) } static void -SetShadeEntry(int jul, char const *shade) +SetShadeEntry(int dse, char const *shade) { int y, m, d; int r, g, b; @@ -733,14 +733,14 @@ SetShadeEntry(int jul, char const *shade) if (r < 0 || g < 0 || b < 0 || r > 255 || g > 255 || b > 255) { return; } - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); bgcolor[d][0] = r; bgcolor[d][1] = g; bgcolor[d][2] = b; } static void -SetMoonEntry(int jul, char const *moon) +SetMoonEntry(int dse, char const *moon) { int phase; int y, m, d; @@ -764,7 +764,7 @@ SetMoonEntry(int jul, char const *moon) fprintf(stderr, "Oops 2\n"); return; } - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); if (msg[0]) { snprintf(moons[d], sizeof(moons[d]), "%s %s", moonphase_emojis[phase], msg); } else { @@ -851,7 +851,7 @@ static void DoCalendarOneWeek(int nleft) int y, m, d, done, i, l, wd; char buf[128]; int LinesWritten = 0; - int OrigJul = DSEToday; + int OrigDse = DSEToday; InitMoonsAndShades(); /* Fill in the column entries */ @@ -870,7 +870,7 @@ static void DoCalendarOneWeek(int nleft) /* If it's "Simple Calendar" format, do it simply... */ if (DoSimpleCalendar) { for (i=0; i<7; i++) { - WriteSimpleEntries(i, OrigJul+i-wd); + WriteSimpleEntries(i, OrigDse+i-wd); } return; } @@ -880,7 +880,7 @@ static void DoCalendarOneWeek(int nleft) DRAW(tb); goff(); for (i=0; i<7; i++) { - FromDSE(OrigJul+i, &y, &m, &d); + FromDSE(OrigDse+i, &y, &m, &d); char const *mon = get_month_name(m); if (moons[d][0]) { if (weeks[d][0]) { @@ -895,7 +895,7 @@ static void DoCalendarOneWeek(int nleft) snprintf(buf, sizeof(buf), "%d %s ", d, get_month_abbrev(mon)); } } - if (OrigJul+i == RealToday) { + if (OrigDse+i == RealToday) { if (UseVTColors) { printf("\x1B[1m"); /* Bold */ } @@ -931,7 +931,7 @@ static void DoCalendarOneWeek(int nleft) /* Write the body lines */ done = 0; while (!done) { - done = WriteOneCalLine(OrigJul, wd); + done = WriteOneCalLine(OrigDse, wd); LinesWritten++; } @@ -1064,7 +1064,7 @@ static int WriteCalendarRow(void) int y, m, d, wd, i, l; int done; char buf[81]; - int OrigJul = DSEToday; + int OrigDse = DSEToday; int LinesWritten = 0; int moreleft; @@ -1090,7 +1090,7 @@ static int WriteCalendarRow(void) /* If it's "Simple Calendar" format, do it simply... */ if (DoSimpleCalendar) { for (i=wd; i<7 && d+i-wd<=DaysInMonth(m, y); i++) { - WriteSimpleEntries(i, OrigJul+i-wd); + WriteSimpleEntries(i, OrigDse+i-wd); } return (d+7-wd <= DaysInMonth(m, y)); } @@ -1153,7 +1153,7 @@ static int WriteCalendarRow(void) /* Write the body lines */ done = 0; while (!done) { - done = WriteOneCalLine(OrigJul, wd); + done = WriteOneCalLine(OrigDse, wd); LinesWritten++; } @@ -1336,7 +1336,7 @@ static void PrintCentered(char const *s, int width, char *pad) /* Write a single line. */ /* */ /***************************************************************/ -static int WriteOneCalLine(int start_jul, int wd) +static int WriteOneCalLine(int start_dse, int wd) { int done = 1, i; int y, m, d; @@ -1345,7 +1345,7 @@ static int WriteOneCalLine(int start_jul, int wd) DRAW(tb); goff(); for (i=0; i<7; i++) { - FromDSE(start_jul+i, &y, &m, &d); + FromDSE(start_dse+i, &y, &m, &d); d -= wd; if (CalColumn[i]) { Backgroundize(ColToDay[i]); @@ -1745,7 +1745,7 @@ static int DoCalRem(ParsePtr p, int col) TimeTrig tim; Value v; int r, err; - int jul; + int dse; CalEntry *CurCol; CalEntry *e; char const *s, *s2; @@ -1843,14 +1843,14 @@ static int DoCalRem(ParsePtr p, int col) col_b = DefaultColorB; } } - jul = LastTriggerDate; + dse = LastTriggerDate; if (!LastTrigValid) { FreeTrig(&trig); return OK; } } else { /* Calculate the trigger date */ - jul = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1); + dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1); if (r) { if (r == E_CANT_TRIG && trig.maybe_uncomputable) { r = OK; @@ -1862,7 +1862,7 @@ static int DoCalRem(ParsePtr p, int col) /* Add to global OMITs if so indicated */ if (trig.addomit) { - r = AddGlobalOmit(jul); + r = AddGlobalOmit(dse); if (r) { FreeTrig(&trig); return r; @@ -1907,28 +1907,28 @@ static int DoCalRem(ParsePtr p, int col) } if (trig.typ == PASSTHRU_TYPE) { if (!PsCal && !StrCmpi(trig.passthru, "SHADE")) { - if (jul == DSEToday) { + if (dse == DSEToday) { DBufInit(&obuf); - r = DoSubst(p, &obuf, &trig, &tim, jul, CAL_MODE); + r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE); if (r) { DBufFree(&obuf); FreeTrig(&trig); return r; } - SetShadeEntry(jul, DBufValue(&obuf)); + SetShadeEntry(dse, DBufValue(&obuf)); DBufFree(&obuf); } } if (!PsCal && !StrCmpi(trig.passthru, "WEEK")) { - if (jul == DSEToday) { + if (dse == DSEToday) { DBufInit(&obuf); - r = DoSubst(p, &obuf, &trig, &tim, jul, CAL_MODE); + r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE); if (r) { DBufFree(&obuf); FreeTrig(&trig); return r; } - sscanf(DBufValue(&obuf), "%31[^\x01]", weeks[DayOf(jul)]); + sscanf(DBufValue(&obuf), "%31[^\x01]", weeks[DayOf(dse)]); DBufFree(&obuf); } } @@ -1937,15 +1937,15 @@ static int DoCalRem(ParsePtr p, int col) return OK; } if (!PsCal && !StrCmpi(trig.passthru, "MOON")) { - if (jul == DSEToday) { + if (dse == DSEToday) { DBufInit(&obuf); - r = DoSubst(p, &obuf, &trig, &tim, jul, CAL_MODE); + r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE); if (r) { DBufFree(&obuf); FreeTrig(&trig); return r; } - SetMoonEntry(jul, DBufValue(&obuf)); + SetMoonEntry(dse, DBufValue(&obuf)); DBufFree(&obuf); } } @@ -1994,9 +1994,9 @@ static int DoCalRem(ParsePtr p, int col) /* If trigger date == today, add it to the current entry */ DBufInit(&obuf); - if ((jul == DSEToday) || + if ((dse == DSEToday) || (DoSimpleCalDelta && - ShouldTriggerReminder(&trig, &tim, jul, &err))) { + ShouldTriggerReminder(&trig, &tim, dse, &err))) { NumTriggered++; /* The parse_ptr should not be nested, but just in case... */ @@ -2010,7 +2010,7 @@ static int DoCalRem(ParsePtr p, int col) } if (DoSimpleCalendar || tim.ttime != NO_TIME) { /* Suppress time if it's not today or if it's a non-COLOR special */ - if (jul != DSEToday || + if (dse != DSEToday || (trig.typ == PASSTHRU_TYPE && StrCmpi(trig.passthru, "COLOUR") && StrCmpi(trig.passthru, "COLOR"))) { @@ -2055,10 +2055,10 @@ static int DoCalRem(ParsePtr p, int col) /* In -sa mode, run in ADVANCE mode if we're triggering * before the actual date */ - if (jul != DSEToday) { - r = DoSubst(p, &obuf, &trig, &tim, jul, ADVANCE_MODE); + if (dse != DSEToday) { + r = DoSubst(p, &obuf, &trig, &tim, dse, ADVANCE_MODE); } else { - r = DoSubst(p, &obuf, &trig, &tim, jul, CAL_MODE); + r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE); } if (r) { DBufFree(&pre_buf); @@ -2159,7 +2159,7 @@ static int DoCalRem(ParsePtr p, int col) e->passthru[0] = 0; } e->pos = e->text; - if (jul == DSEToday) { + if (dse == DSEToday) { e->time = tim.ttime; } else { e->time = NO_TIME; @@ -2385,13 +2385,13 @@ static void WriteSimpleEntryProtocol2(CalEntry *e, int today) /* Write entries in 'simple calendar' format. */ /* */ /***************************************************************/ -static void WriteSimpleEntries(int col, int jul) +static void WriteSimpleEntries(int col, int dse) { CalEntry *e = CalColumn[col]; CalEntry *n; int y, m, d; - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); while(e) { if (DoPrefixLineNo) { if (PsCal != PSCAL_LEVEL2 && PsCal != PSCAL_LEVEL3) { @@ -2406,7 +2406,7 @@ static void WriteSimpleEntries(int col, int jul) } DidADay = 1; printf("{\"date\":\"%04d-%02d-%02d\",", y, m+1, d); - WriteSimpleEntryProtocol2(e, jul); + WriteSimpleEntryProtocol2(e, dse); printf("}"); if (PsCal != PSCAL_LEVEL3) { printf("\n"); diff --git a/src/dorem.c b/src/dorem.c index 4b5248a3..67fe0dda 100644 --- a/src/dorem.c +++ b/src/dorem.c @@ -29,7 +29,7 @@ static int ParseLocalOmit (ParsePtr s, Trigger *t); static int ParseScanFrom (ParsePtr s, Trigger *t, int type); static int ParsePriority (ParsePtr s, Trigger *t); static int ParseUntil (ParsePtr s, Trigger *t, int type); -static int ShouldTriggerBasedOnWarn (Trigger *t, int jul, int *err); +static int ShouldTriggerBasedOnWarn (Trigger *t, int dse, int *err); static int ComputeTrigDuration(TimeTrig *t); static int @@ -55,7 +55,7 @@ int DoRem(ParsePtr p) Trigger trig; TimeTrig tim; int r, err; - int jul; + int dse; DynamicBuffer buf; Token tok; @@ -124,14 +124,14 @@ int DoRem(ParsePtr p) DBufFree(&buf); } trig.typ = tok.val; - jul = LastTriggerDate; + dse = LastTriggerDate; if (!LastTrigValid || PurgeMode) { FreeTrig(&trig); return OK; } } else { /* Calculate the trigger date */ - jul = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1); + dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1); if (r) { if (PurgeMode) { PurgeEchoLine("%s: %s\n", "#!P! Problem calculating trigger date", ErrMsg[r]); @@ -147,14 +147,14 @@ int DoRem(ParsePtr p) /* Add to global OMITs if so indicated */ if (trig.addomit) { - r = AddGlobalOmit(jul); + r = AddGlobalOmit(dse); if (r) { FreeTrig(&trig); return r; } } if (PurgeMode) { - if (trig.expired || jul < DSEToday) { + if (trig.expired || dse < DSEToday) { if (p->expr_happened) { if (p->nonconst_expr) { PurgeEchoLine("%s\n", "#!P: Next line may have expired, but contains non-constant expression"); @@ -174,7 +174,7 @@ int DoRem(ParsePtr p) } /* Queue the reminder, if necessary */ - if (jul == DSEToday && + if (dse == DSEToday && !(!IgnoreOnce && trig.once != NO_ONCE && FileAccessDate == DSEToday)) @@ -186,8 +186,8 @@ int DoRem(ParsePtr p) } r = OK; - if (ShouldTriggerReminder(&trig, &tim, jul, &err)) { - if ( (r=TriggerReminder(p, &trig, &tim, jul)) ) { + if (ShouldTriggerReminder(&trig, &tim, dse, &err)) { + if ( (r=TriggerReminder(p, &trig, &tim, dse)) ) { FreeTrig(&trig); return r; } @@ -886,7 +886,7 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type) /* Trigger the reminder if it's a RUN or MSG type. */ /* */ /***************************************************************/ -int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) +int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse) { int r, y, m, d; char PrioExpr[VAR_NAME_LEN+25]; @@ -953,13 +953,13 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) /* If it's NextMode, process as a ADVANCE_MODE-type entry, and issue simple-calendar format. */ if (NextMode) { - if ( (r=DoSubst(p, &buf, t, tim, jul, ADVANCE_MODE)) ) return r; + if ( (r=DoSubst(p, &buf, t, tim, dse, ADVANCE_MODE)) ) return r; if (!DBufLen(&buf)) { DBufFree(&buf); DBufFree(&pre_buf); return OK; } - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); sprintf(tmpBuf, "%04d/%02d/%02d ", y, m+1, d); if (DBufPuts(&calRow, tmpBuf) != OK) { DBufFree(&calRow); @@ -1058,7 +1058,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) if (is_color) { DBufPuts(&buf, Colorize(red, green, blue, 0, 1)); } - if ( (r=DoSubst(p, &buf, t, tim, jul, NORMAL_MODE)) ) return r; + if ( (r=DoSubst(p, &buf, t, tim, dse, NORMAL_MODE)) ) return r; if (t->typ != RUN_TYPE) { if (UserFuncExists("msgsuffix") == 1) { sprintf(PrioExpr, "msgsuffix(%d)", t->priority); @@ -1093,7 +1093,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) /* If we are sorting, just queue it up in the sort buffer */ if (SortByDate) { - if (InsertIntoSortBuffer(jul, tim->ttime, DBufValue(&buf), + if (InsertIntoSortBuffer(dse, tim->ttime, DBufValue(&buf), t->typ, t->priority) == OK) { DBufFree(&buf); NumTriggered++; @@ -1140,7 +1140,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) /* triggered. Sets *err non-zero in event of an error. */ /* */ /***************************************************************/ -int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err) +int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int dse, int *err) { int r, omit; *err = 0; @@ -1149,11 +1149,11 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err) if (!IgnoreOnce && t->once !=NO_ONCE && FileAccessDate == DSEToday) return 0; - if (jul < DSEToday) return 0; + if (dse < DSEToday) return 0; /* Don't trigger timed reminders if DontIssueAts is true, and if the reminder is for today */ - if (jul == DSEToday && DontIssueAts && tim->ttime != NO_TIME) { + if (dse == DSEToday && DontIssueAts && tim->ttime != NO_TIME) { if (DontIssueAts > 1) { /* If two or more -a options, then *DO* issue ats that are in the future */ @@ -1167,7 +1167,7 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err) /* Don't trigger "old" timed reminders */ /*** REMOVED... - if (jul == DSEToday && + if (dse == DSEToday && tim->ttime != NO_TIME && tim->ttime < SystemTime(0) / 60) return 0; *** ...UNTIL HERE */ @@ -1178,28 +1178,28 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err) /* If there's a "warn" function, it overrides any deltas */ if (t->warn[0] != 0) { if (DeltaOffset) { - if (jul <= DSEToday + DeltaOffset) { + if (dse <= DSEToday + DeltaOffset) { return 1; } } - return ShouldTriggerBasedOnWarn(t, jul, err); + return ShouldTriggerBasedOnWarn(t, dse, err); } /* Move back by delta days, if any */ if (t->delta != NO_DELTA) { if (t->delta < 0) - jul = jul + t->delta; + dse = dse + t->delta; else { int iter = 0; int max = MaxSatIter; r = t->delta; if (max < r*2) max = r*2; while(iter++ < max) { - if (!r || (jul <= DSEToday)) { + if (!r || (dse <= DSEToday)) { break; } - jul--; - *err = IsOmitted(jul, t->localomit, t->omitfunc, &omit); + dse--; + *err = IsOmitted(dse, t->localomit, t->omitfunc, &omit); if (*err) return 0; if (!omit) r--; } @@ -1212,7 +1212,7 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err) } /* Should we trigger the reminder? */ - return (jul <= DSEToday + DeltaOffset); + return (dse <= DSEToday + DeltaOffset); } /***************************************************************/ @@ -1224,7 +1224,7 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err) /***************************************************************/ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p) { - int iter, jul, r, start; + int iter, dse, r, start; Value v; char const *s; char const *t; @@ -1233,25 +1233,25 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p) iter = 0; start = trig->scanfrom; while (iter++ < MaxSatIter) { - jul = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, 0); + dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, 0); if (r) { if (r == E_CANT_TRIG) return OK; else return r; } - if (jul != start && trig->duration_days) { - jul = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, trig->duration_days); + if (dse != start && trig->duration_days) { + dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, trig->duration_days); if (r) { if (r == E_CANT_TRIG) return OK; else return r; } - } else if (jul == start) { + } else if (dse == start) { if (tt->ttime != NO_TIME) { trig->eventstart = MINUTES_PER_DAY * r + tt->ttime; if (tt->duration != NO_TIME) { trig->eventduration = tt->duration; } } - SaveAllTriggerInfo(trig, tt, jul, tt->ttime, 1); + SaveAllTriggerInfo(trig, tt, dse, tt->ttime, 1); } - if (jul == -1) { + if (dse == -1) { return E_EXPIRED; } s = p->pos; @@ -1261,7 +1261,7 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p) if (v.type != INT_TYPE && v.type != STR_TYPE) return E_BAD_TYPE; if ((v.type == INT_TYPE && v.v.val) || (v.type == STR_TYPE && *v.v.str)) { - AdjustTriggerForDuration(trig->scanfrom, jul, trig, tt, 1); + AdjustTriggerForDuration(trig->scanfrom, dse, trig, tt, 1); if (DebugFlag & DB_PRTTRIG) { int y, m, d; FromDSE(LastTriggerDate, &y, &m, &d); @@ -1286,10 +1286,10 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p) return OK; } p->pos = s; - if (jul+trig->duration_days < start) { + if (dse+trig->duration_days < start) { start++; } else { - start = jul+trig->duration_days+1; + start = dse+trig->duration_days+1; } } p->pos = t; @@ -1396,7 +1396,7 @@ finished: /* function. */ /* */ /***************************************************************/ -static int ShouldTriggerBasedOnWarn(Trigger *t, int jul, int *err) +static int ShouldTriggerBasedOnWarn(Trigger *t, int dse, int *err) { char buffer[VAR_NAME_LEN+32]; int i; @@ -1408,7 +1408,7 @@ static int ShouldTriggerBasedOnWarn(Trigger *t, int jul, int *err) /* If no proper function exists, barf... */ if (UserFuncExists(t->warn) != 1) { Eprint("%s: `%s'", ErrMsg[M_BAD_WARN_FUNC], t->warn); - return (jul == DSEToday); + return (dse == DSEToday); } for (i=1; ; i++) { sprintf(buffer, "%s(%d)", t->warn, i); @@ -1417,28 +1417,28 @@ static int ShouldTriggerBasedOnWarn(Trigger *t, int jul, int *err) if (r) { Eprint("%s: `%s': %s", ErrMsg[M_BAD_WARN_FUNC], t->warn, ErrMsg[r]); - return (jul == DSEToday); + return (dse == DSEToday); } if (v.type != INT_TYPE) { DestroyValue(v); Eprint("%s: `%s': %s", ErrMsg[M_BAD_WARN_FUNC], t->warn, ErrMsg[E_BAD_TYPE]); - return (jul == DSEToday); + return (dse == DSEToday); } /* If absolute value of return is not monotonically decreasing, exit */ if (i > 1 && abs(v.v.val) >= lastReturnVal) { - return (jul == DSEToday); + return (dse == DSEToday); } lastReturnVal = abs(v.v.val); /* Positive values: Just subtract. Negative values: skip omitted days. */ if (v.v.val >= 0) { - if (DSEToday + v.v.val == jul) return 1; + if (DSEToday + v.v.val == dse) return 1; } else { - int j = jul; + int j = dse; int iter = 0; int max = MaxSatIter; if (max < v.v.val * 2) max = v.v.val*2; diff --git a/src/dosubst.c b/src/dosubst.c index 7a82fdd1..3fc21052 100644 --- a/src/dosubst.c +++ b/src/dosubst.c @@ -42,9 +42,9 @@ /* If mode==ADVANCE_MODE, ignore %" but don't add newline */ /* */ /***************************************************************/ -int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, int mode) +int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, int mode) { - int diff = jul - DSEToday; + int diff = dse - DSEToday; int curtime = SystemTime(0) / 60; int err, done; int c; @@ -69,7 +69,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, int r; Value v; - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); if (tim == NO_TIME) tim = curtime; tdiff = tim - curtime; @@ -370,10 +370,10 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, L_A_OVER #else if (altmode == '*' || !strcmp(DynamicOn, "")) { - snprintf(s, sizeof(s), "%s, %d %s, %d", get_day_name(jul%7), d, + snprintf(s, sizeof(s), "%s, %d %s, %d", get_day_name(dse%7), d, get_month_name(m), y); } else { - snprintf(s, sizeof(s), "%s %s, %d %s, %d", DynamicOn, get_day_name(jul%7), d, + snprintf(s, sizeof(s), "%s %s, %d %s, %d", DynamicOn, get_day_name(dse%7), d, get_month_name(m), y); } #endif @@ -394,9 +394,9 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, L_C_OVER #else if (altmode == '*' || !strcmp(DynamicOn, "")) { - snprintf(s, sizeof(s), "%s", get_day_name(jul%7)); + snprintf(s, sizeof(s), "%s", get_day_name(dse%7)); } else { - snprintf(s, sizeof(s), "%s %s", DynamicOn, get_day_name(jul%7)); + snprintf(s, sizeof(s), "%s %s", DynamicOn, get_day_name(dse%7)); } #endif SHIP_OUT(s); @@ -444,9 +444,9 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, L_G_OVER #else if (altmode == '*' || !strcmp(DynamicOn, "")) { - snprintf(s, sizeof(s), "%s, %d %s", get_day_name(jul%7), d, get_month_name(m)); + snprintf(s, sizeof(s), "%s, %d %s", get_day_name(dse%7), d, get_month_name(m)); } else { - snprintf(s, sizeof(s), "%s %s, %d %s", DynamicOn, get_day_name(jul%7), d, get_month_name(m)); + snprintf(s, sizeof(s), "%s %s, %d %s", DynamicOn, get_day_name(dse%7), d, get_month_name(m)); } #endif SHIP_OUT(s); @@ -483,10 +483,10 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, L_J_OVER #else if (altmode == '*' || !strcmp(DynamicOn, "")) { - snprintf(s, sizeof(s), "%s, %s %d%s, %d", get_day_name(jul%7), + snprintf(s, sizeof(s), "%s, %s %d%s, %d", get_day_name(dse%7), get_month_name(m), d, plu, y); } else { - snprintf(s, sizeof(s), "%s %s, %s %d%s, %d", DynamicOn, get_day_name(jul%7), + snprintf(s, sizeof(s), "%s %s, %s %d%s, %d", DynamicOn, get_day_name(dse%7), get_month_name(m), d, plu, y); } #endif @@ -498,10 +498,10 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, L_K_OVER #else if (altmode == '*' || !strcmp(DynamicOn, "")) { - snprintf(s, sizeof(s), "%s, %s %d%s", get_day_name(jul%7), + snprintf(s, sizeof(s), "%s, %s %d%s", get_day_name(dse%7), get_month_name(m), d, plu); } else { - snprintf(s, sizeof(s), "%s %s, %s %d%s", DynamicOn, get_day_name(jul%7), + snprintf(s, sizeof(s), "%s %s, %s %d%s", DynamicOn, get_day_name(dse%7), get_month_name(m), d, plu); } #endif @@ -599,10 +599,10 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, L_U_OVER #else if (altmode == '*' || !strcmp(DynamicOn, "")) { - snprintf(s, sizeof(s), "%s, %d%s %s, %d", get_day_name(jul%7), d, + snprintf(s, sizeof(s), "%s, %d%s %s, %d", get_day_name(dse%7), d, plu, get_month_name(m), y); } else { - snprintf(s, sizeof(s), "%s %s, %d%s %s, %d", DynamicOn, get_day_name(jul%7), d, + snprintf(s, sizeof(s), "%s %s, %d%s %s, %d", DynamicOn, get_day_name(dse%7), d, plu, get_month_name(m), y); } #endif @@ -614,10 +614,10 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, L_V_OVER #else if (altmode == '*' || !strcmp(DynamicOn, "")) { - snprintf(s, sizeof(s), "%s, %d%s %s", get_day_name(jul%7), d, plu, + snprintf(s, sizeof(s), "%s, %d%s %s", get_day_name(dse%7), d, plu, get_month_name(m)); } else { - snprintf(s, sizeof(s), "%s %s, %d%s %s", DynamicOn, get_day_name(jul%7), d, plu, + snprintf(s, sizeof(s), "%s %s, %d%s %s", DynamicOn, get_day_name(dse%7), d, plu, get_month_name(m)); } #endif @@ -628,7 +628,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, #ifdef L_W_OVER L_W_OVER #else - snprintf(s, sizeof(s), "%s", get_day_name(jul%7)); + snprintf(s, sizeof(s), "%s", get_day_name(dse%7)); #endif SHIP_OUT(s); break; @@ -885,21 +885,21 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, /* */ /***************************************************************/ int DoSubstFromString(char const *source, DynamicBuffer *dbuf, - int jul, int tim) + int dse, int tim) { Trigger tempTrig; TimeTrig tempTime; Parser tempP; int r; - if (jul == NO_DATE) jul=DSEToday; + if (dse == NO_DATE) dse=DSEToday; if (tim == NO_TIME) tim=SystemTime(0)/60; CreateParser(source, &tempP); tempP.allownested = 0; tempTrig.typ = MSG_TYPE; tempTime.ttime = tim; - r = DoSubst(&tempP, dbuf, &tempTrig, &tempTime, jul, NORMAL_MODE); + r = DoSubst(&tempP, dbuf, &tempTrig, &tempTime, dse, NORMAL_MODE); DestroyParser(&tempP); return r; } diff --git a/src/expr.c b/src/expr.c index d9bd1661..4d4a7609 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1367,11 +1367,11 @@ int ParseLiteralTime(char const **s, int *tim) /* */ /* ParseLiteralDate */ /* */ -/* Parse a literal date or datetime. Return result in jul */ +/* Parse a literal date or datetime. Return result in dse */ /* and tim; update s. */ /* */ /***************************************************************/ -int ParseLiteralDate(char const **s, int *jul, int *tim) +int ParseLiteralDate(char const **s, int *dse, int *tim) { int y, m, d; int r; @@ -1401,7 +1401,7 @@ int ParseLiteralDate(char const **s, int *jul, int *tim) } if (!DateOK(y, m, d)) return E_BAD_DATE; - *jul = DSE(y, m, d); + *dse = DSE(y, m, d); /* Do we have a time part as well? */ if (**s == ' ' || **s == '@' || **s == 'T' || **s == 't') { diff --git a/src/funcs.c b/src/funcs.c index 1183f340..f35c9c21 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -174,7 +174,7 @@ static int FShellescape (func_info *); static int CleanUpAfterFunc (func_info *); static int CheckArgs (BuiltinFunc *f, int nargs); -static int SunStuff (int rise, double cosz, int jul); +static int SunStuff (int rise, double cosz, int dse); static int tz_set_tz (char const *tz); /* "Overload" the struct Operator definition */ @@ -182,10 +182,10 @@ static int tz_set_tz (char const *tz); /* Caches for extracting months, days, years from dates - may improve performance slightly. */ -static int CacheJul = -1; +static int CacheDse = -1; static int CacheYear, CacheMon, CacheDay; -static int CacheHebJul = -1; +static int CacheHebDse = -1; static int CacheHebYear, CacheHebMon, CacheHebDay; /* We need access to the value stack */ @@ -742,11 +742,11 @@ static int FDay(func_info *info) if (!HASDATE(ARG(0))) return E_BAD_TYPE; v = DATEPART(ARG(0)); - if (v == CacheJul) + if (v == CacheDse) d = CacheDay; else { FromDSE(v, &y, &m, &d); - CacheJul = v; + CacheDse = v; CacheYear = y; CacheMon = m; CacheDay = d; @@ -762,11 +762,11 @@ static int FMonnum(func_info *info) if (!HASDATE(ARG(0))) return E_BAD_TYPE; v = DATEPART(ARG(0)); - if (v == CacheJul) + if (v == CacheDse) m = CacheMon; else { FromDSE(v, &y, &m, &d); - CacheJul = v; + CacheDse = v; CacheYear = y; CacheMon = m; CacheDay = d; @@ -782,11 +782,11 @@ static int FYear(func_info *info) if (!HASDATE(ARG(0))) return E_BAD_TYPE; v = DATEPART(ARG(0)); - if (v == CacheJul) + if (v == CacheDse) y = CacheYear; else { FromDSE(v, &y, &m, &d); - CacheJul = v; + CacheDse = v; CacheYear = y; CacheMon = m; CacheDay = d; @@ -838,11 +838,11 @@ static int FMon(func_info *info) if (m > 11) return E_2HIGH; } else { v = DATEPART(ARG(0)); - if (v == CacheJul) + if (v == CacheDse) m = CacheMon; else { FromDSE(v, &y, &m, &d); - CacheJul = v; + CacheDse = v; CacheYear = y; CacheMon = m; CacheDay = d; @@ -2080,21 +2080,21 @@ static int FArgs(func_info *info) /***************************************************************/ static int FDosubst(func_info *info) { - int jul, tim, r; + int dse, tim, r; DynamicBuffer buf; DBufInit(&buf); - jul = NO_DATE; + dse = NO_DATE; tim = NO_TIME; ASSERT_TYPE(0, STR_TYPE); if (Nargs >= 2) { if (ARG(1).type == DATETIME_TYPE) { - jul = DATEPART(ARG(1)); + dse = DATEPART(ARG(1)); tim = TIMEPART(ARG(1)); } else { ASSERT_TYPE(1, DATE_TYPE); - jul = ARGV(1); + dse = ARGV(1); } if (Nargs >= 3) { if (ARG(1).type == DATETIME_TYPE) { @@ -2105,7 +2105,7 @@ static int FDosubst(func_info *info) } } - if ((r=DoSubstFromString(ARGSTR(0), &buf, jul, tim))) return r; + if ((r=DoSubstFromString(ARGSTR(0), &buf, dse, tim))) return r; r = RetStrVal(DBufValue(&buf), info); DBufFree(&buf); return r; @@ -2161,7 +2161,7 @@ static int FHebdate(func_info *info) year = ARGV(2); r = GetValidHebDate(year, mon, day, 0, &mout, &dout, jahr); if (r) return r; - r = HebToJul(year, mout, dout); + r = HebToDSE(year, mout, dout); if (r<0) return E_DATE_OVER; RETVAL = r; RetVal.type = DATE_TYPE; @@ -2181,11 +2181,11 @@ static int FHebday(func_info *info) if (!HASDATE(ARG(0))) return E_BAD_TYPE; v = DATEPART(ARG(0)); - if (v == CacheHebJul) + if (v == CacheHebDse) d = CacheHebDay; else { - JulToHeb(v, &y, &m, &d); - CacheHebJul = v; + DSEToHeb(v, &y, &m, &d); + CacheHebDse = v; CacheHebYear = y; CacheHebMon = m; CacheHebDay = d; @@ -2202,12 +2202,12 @@ static int FHebmon(func_info *info) if (!HASDATE(ARG(0))) return E_BAD_TYPE; v = DATEPART(ARG(0)); - if (v == CacheHebJul) { + if (v == CacheHebDse) { m = CacheHebMon; y = CacheHebYear; } else { - JulToHeb(v, &y, &m, &d); - CacheHebJul = v; + DSEToHeb(v, &y, &m, &d); + CacheHebDse = v; CacheHebYear = y; CacheHebMon = m; CacheHebDay = d; @@ -2222,11 +2222,11 @@ static int FHebyear(func_info *info) if (!HASDATE(ARG(0))) return E_BAD_TYPE; v = DATEPART(ARG(0)); - if (v == CacheHebJul) + if (v == CacheHebDse) y = CacheHebYear; else { - JulToHeb(v, &y, &m, &d); - CacheHebJul = v; + DSEToHeb(v, &y, &m, &d); + CacheHebDse = v; CacheHebYear = y; CacheHebMon = m; CacheHebDay = d; @@ -2307,15 +2307,15 @@ static int FMinsfromutc(func_info *info) static int FTimeStuff(int wantmins, func_info *info) { - int jul, tim; + int dse, tim; int mins, dst; - jul = DSEToday; + dse = DSEToday; tim = 0; if (Nargs >= 1) { if (!HASDATE(ARG(0))) return E_BAD_TYPE; - jul = DATEPART(ARG(0)); + dse = DATEPART(ARG(0)); if (HASTIME(ARG(0))) { tim = TIMEPART(ARG(0)); } @@ -2326,7 +2326,7 @@ static int FTimeStuff(int wantmins, func_info *info) } } - if (CalcMinsFromUTC(jul, tim, &mins, &dst)) return E_MKTIME_PROBLEM; + if (CalcMinsFromUTC(dse, tim, &mins, &dst)) return E_MKTIME_PROBLEM; RetVal.type = INT_TYPE; if (wantmins) RETVAL = mins; else RETVAL = dst; @@ -2335,24 +2335,24 @@ static int FTimeStuff(int wantmins, func_info *info) static int FTimezone(func_info *info) { - int yr, mon, day, hr, min, jul, now; + int yr, mon, day, hr, min, dse, now; struct tm local, *withzone; time_t t; char buf[64]; if (Nargs == 0) { - jul = DSEToday; + dse = DSEToday; now = (SystemTime(0) / 60); } else { if (!HASDATE(ARG(0))) return E_BAD_TYPE; - jul = DATEPART(ARG(0)); + dse = DATEPART(ARG(0)); if (HASTIME(ARG(0))) { now = TIMEPART(ARG(0)); } else { now = 0; } } - FromDSE(jul, &yr, &mon, &day); + FromDSE(dse, &yr, &mon, &day); hr = now / 60; min = now % 60; @@ -2374,7 +2374,7 @@ static int FTimezone(func_info *info) static int FLocalToUTC(func_info *info) { - int yr, mon, day, hr, min, jul; + int yr, mon, day, hr, min, dse; time_t loc_t; struct tm local, *utc; @@ -2398,15 +2398,15 @@ static int FLocalToUTC(func_info *info) } utc = gmtime(&loc_t); - jul = DSE(utc->tm_year+1900, utc->tm_mon, utc->tm_mday); + dse = DSE(utc->tm_year+1900, utc->tm_mon, utc->tm_mday); RetVal.type = DATETIME_TYPE; - RETVAL = MINUTES_PER_DAY * jul + utc->tm_hour*60 + utc->tm_min; + RETVAL = MINUTES_PER_DAY * dse + utc->tm_hour*60 + utc->tm_min; return OK; } static int FUTCToLocal(func_info *info) { - int yr, mon, day, hr, min, jul; + int yr, mon, day, hr, min, dse; time_t utc_t; struct tm *local, utc; char const *old_tz; @@ -2436,9 +2436,9 @@ static int FUTCToLocal(func_info *info) } local = localtime(&utc_t); - jul = DSE(local->tm_year+1900, local->tm_mon, local->tm_mday); + dse = DSE(local->tm_year+1900, local->tm_mon, local->tm_mday); RetVal.type = DATETIME_TYPE; - RETVAL = MINUTES_PER_DAY * jul + local->tm_hour*60 + local->tm_min; + RETVAL = MINUTES_PER_DAY * dse + local->tm_hour*60 + local->tm_min; return OK; } @@ -2460,7 +2460,7 @@ static int FUTCToLocal(func_info *info) #define DEGRAD (PI/180.0) #define RADDEG (180.0/PI) -static int SunStuff(int rise, double cosz, int jul) +static int SunStuff(int rise, double cosz, int dse) { int mins, hours; int year, mon, day; @@ -2470,7 +2470,7 @@ static int SunStuff(int rise, double cosz, int jul) /* Get offset from UTC */ if (CalculateUTC) { - if (CalcMinsFromUTC(jul, 12*60, &mins, NULL)) { + if (CalcMinsFromUTC(dse, 12*60, &mins, NULL)) { Eprint(ErrMsg[E_MKTIME_PROBLEM]); return NO_TIME; } @@ -2480,10 +2480,10 @@ static int SunStuff(int rise, double cosz, int jul) longdeg = -Longitude; latitude = DEGRAD * Latitude; - FromDSE(jul, &year, &mon, &day); + FromDSE(dse, &year, &mon, &day); /* Following formula on page B6 exactly... */ - t = (double) jul; + t = (double) dse; if (rise) { t += (6.0 + longdeg/15.0) / 24.0; } else { @@ -2570,7 +2570,7 @@ static int SunStuff(int rise, double cosz, int jul) /***************************************************************/ static int FSun(int rise, func_info *info) { - int jul = DSEToday; + int dse = DSEToday; /* Assignment below is not necessary, but it silences a GCC warning about a possibly-uninitialized variable */ double cosz = 0.0; @@ -2591,10 +2591,10 @@ static int FSun(int rise, func_info *info) } if (Nargs >= 1) { if (!HASDATE(ARG(0))) return E_BAD_TYPE; - jul = DATEPART(ARG(0)); + dse = DATEPART(ARG(0)); } - r = SunStuff(rise % 2, cosz, jul); + r = SunStuff(rise % 2, cosz, dse); if (r == NO_TIME) { RETVAL = 0; RetVal.type = INT_TYPE; @@ -3090,7 +3090,7 @@ static int tz_convert(int year, int month, int day, static int FTzconvert(func_info *info) { int year, month, day, hour, minute, r; - int jul, tim; + int dse, tim; struct tm tm; if (ARG(0).type != DATETIME_TYPE || @@ -3113,10 +3113,10 @@ static int FTzconvert(func_info *info) if (r == -1) return E_CANT_CONVERT_TZ; - jul = DSE(tm.tm_year + 1900, tm.tm_mon, tm.tm_mday); + dse = DSE(tm.tm_year + 1900, tm.tm_mon, tm.tm_mday); tim = tm.tm_hour * 60 + tm.tm_min; RetVal.type = DATETIME_TYPE; - RETVAL = jul * MINUTES_PER_DAY + tim; + RETVAL = dse * MINUTES_PER_DAY + tim; return OK; } @@ -3204,7 +3204,7 @@ FNonomitted(func_info *info) static int FWeekno(func_info *info) { - int jul = DSEToday; + int dse = DSEToday; int wkstart = 0; /* Week start on Monday */ int daystart = 29; /* First week starts on wkstart on or after Dec. 29 */ int monstart; @@ -3214,7 +3214,7 @@ FWeekno(func_info *info) if (Nargs >= 1) { if (!HASDATE(ARG(0))) return E_BAD_TYPE; - jul = DATEPART(ARG(0)); + dse = DATEPART(ARG(0)); } if (Nargs >= 2) { ASSERT_TYPE(1, INT_TYPE); @@ -3241,14 +3241,14 @@ FWeekno(func_info *info) monstart = 11; } - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); /* Try this year */ candidate = DSE(y, monstart, daystart); while((candidate % 7) != wkstart) candidate++; - if (candidate <= jul) { - RETVAL = ((jul - candidate) / 7) + 1; + if (candidate <= dse) { + RETVAL = ((dse - candidate) / 7) + 1; return OK; } @@ -3256,8 +3256,8 @@ FWeekno(func_info *info) /* Must be last year */ candidate = DSE(y-1, monstart, daystart); while((candidate % 7) != wkstart) candidate++; - if (candidate <= jul) { - RETVAL = ((jul - candidate) / 7) + 1; + if (candidate <= dse) { + RETVAL = ((dse - candidate) / 7) + 1; return OK; } @@ -3265,7 +3265,7 @@ FWeekno(func_info *info) /* Holy cow! */ candidate = DSE(y-2, monstart, daystart); while((candidate % 7) != wkstart) candidate++; - RETVAL = ((jul - candidate) / 7) + 1; + RETVAL = ((dse - candidate) / 7) + 1; return OK; } @@ -3275,7 +3275,7 @@ FEvalTrig(func_info *info) Parser p; Trigger trig; TimeTrig tim; - int jul, scanfrom; + int dse, scanfrom; int r; ASSERT_TYPE(0, STR_TYPE); @@ -3299,30 +3299,30 @@ FEvalTrig(func_info *info) return E_PARSE_ERR; } if (scanfrom == NO_DATE) { - jul = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 0); + dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 0); } else { /* Hokey... */ if (trig.scanfrom != DSEToday) { Wprint("Warning: SCANFROM is ignored in two-argument form of evaltrig()"); } - jul = ComputeTrigger(scanfrom, &trig, &tim, &r, 0); + dse = ComputeTrigger(scanfrom, &trig, &tim, &r, 0); } if (r == E_CANT_TRIG && trig.maybe_uncomputable) { r = 0; - jul = -1; + dse = -1; } FreeTrig(&trig); DestroyParser(&p); if (r) return r; - if (jul < 0) { + if (dse < 0) { RetVal.type = INT_TYPE; - RETVAL = jul; + RETVAL = dse; } else if (tim.ttime == NO_TIME) { RetVal.type = DATE_TYPE; - RETVAL = jul; + RETVAL = dse; } else { RetVal.type = DATETIME_TYPE; - RETVAL = (MINUTES_PER_DAY * jul) + tim.ttime; + RETVAL = (MINUTES_PER_DAY * dse) + tim.ttime; } return OK; } @@ -3334,7 +3334,7 @@ FTrig(func_info *info) Parser p; Trigger trig; TimeTrig tim; - int jul; + int dse; int r; int i; @@ -3363,16 +3363,16 @@ FTrig(func_info *info) FreeTrig(&trig); return E_PARSE_ERR; } - jul = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 0); + dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 0); if (r == E_CANT_TRIG) { DestroyParser(&p); FreeTrig(&trig); continue; } - if (ShouldTriggerReminder(&trig, &tim, jul, &r)) { - LastTrig = jul; - RETVAL = jul; + if (ShouldTriggerReminder(&trig, &tim, dse, &r)) { + LastTrig = dse; + RETVAL = dse; DestroyParser(&p); FreeTrig(&trig); return OK; diff --git a/src/hbcal.c b/src/hbcal.c index c7e0166d..7e884103 100644 --- a/src/hbcal.c +++ b/src/hbcal.c @@ -155,14 +155,14 @@ char const *DaysInHebMonths(int ylen) /***************************************************************/ /* */ -/* HebToJul */ +/* HebToDSE */ /* */ /* Convert a Hebrew date to DSE. */ /* Hebrew months range from 0-12, but Adar A has 0 length in */ /* non-leap-years. */ /* */ /***************************************************************/ -int HebToJul(int hy, int hm, int hd) +int HebToDSE(int hy, int hm, int hd) { int ylen; char const *monlens; @@ -188,39 +188,39 @@ int HebToJul(int hy, int hm, int hd) /***************************************************************/ /* */ -/* JulToHeb */ +/* DSEToHeb */ /* */ /* Convert a DSE to Hebrew. */ /* Hebrew months range from 0-12, but Adar A has 0 length in */ /* non-leap-years. */ /* */ /***************************************************************/ -void JulToHeb(int jul, int *hy, int *hm, int *hd) +void DSEToHeb(int dse, int *hy, int *hm, int *hd) { int y, m, d; int rh; int ylen; char const *monlen; /* Get the common year */ - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); y += 3763; /* Over-estimate a bit to be on the safe side below... */ /* Find the RH just before desired date */ - while ((rh=RoshHashana(y))>jul) y--; + while ((rh=RoshHashana(y))>dse) y--; /* Got the year - now find the month */ - jul -= rh; + dse -= rh; ylen = DaysInHebYear(y); monlen = DaysInHebMonths(ylen); m = 0; - while((jul >= monlen[m]) || !monlen[m]) { - jul -= monlen[m]; + while((dse >= monlen[m]) || !monlen[m]) { + dse -= monlen[m]; m++; } *hy = y; *hm = m; - *hd = jul+1; + *hd = dse+1; } /***************************************************************/ @@ -389,20 +389,20 @@ int GetValidHebDate(int yin, int min, int din, int adarbehave, /* Returns 0 for success, non-zero for failure. */ /* */ /***************************************************************/ -int GetNextHebrewDate(int julstart, int hm, int hd, +int GetNextHebrewDate(int dsestart, int hm, int hd, int jahr, int adarbehave, int *ans) { - int r, yout, mout, dout, jul=1; + int r, yout, mout, dout, dse=1; int adarflag = adarbehave; - /* I initialize jul above to stop gcc from complaining about + /* I initialize dse above to stop gcc from complaining about possible use of uninitialized variable. You can take it out if the small inefficiency really bothers you. */ /* If adarbehave == ADAR2BOTH, set adarflag to ADAR2ADARA for now */ if (adarbehave == ADAR2BOTH) adarflag = ADAR2ADARA; - JulToHeb(julstart, &yout, &mout, &dout); + DSEToHeb(dsestart, &yout, &mout, &dout); r = 1; while(r) { @@ -419,9 +419,9 @@ int GetNextHebrewDate(int julstart, int hm, int hd, } else yout++; continue; } - jul = HebToJul(yout, mout, dout); - if (jul < 0) return E_DATE_OVER; - if (jul >= julstart) break; + dse = HebToDSE(yout, mout, dout); + if (dse < 0) return E_DATE_OVER; + if (dse >= dsestart) break; else { if (adarbehave == ADAR2BOTH && hm == ADAR) { if (adarflag == ADAR2ADARA) { @@ -434,7 +434,7 @@ int GetNextHebrewDate(int julstart, int hm, int hd, r=1; /* Force loop to continue */ } } - *ans = jul; + *ans = dse; return OK; } diff --git a/src/init.c b/src/init.c index 154b673c..f26e4310 100644 --- a/src/init.c +++ b/src/init.c @@ -164,10 +164,10 @@ void InitRemind(int argc, char const *argv[]) char const *s; int weeks; int x; - int jul; + int dse; int ttyfd; - jul = NO_DATE; + dse = NO_DATE; /* If stdout is a terminal, initialize $FormWidth to terminal width-8, but clamp to [20, 500] */ @@ -638,30 +638,30 @@ void InitRemind(int argc, char const *argv[]) case T_DateTime: if (SysTime != -1L) Usage(); - if (m != NO_MON || d != NO_DAY || y != NO_YR || jul != NO_DATE) Usage(); + if (m != NO_MON || d != NO_DAY || y != NO_YR || dse != NO_DATE) Usage(); SysTime = (tok.val % MINUTES_PER_DAY) * 60; DontQueue = 1; Daemon = 0; - jul = tok.val / MINUTES_PER_DAY; + dse = tok.val / MINUTES_PER_DAY; break; case T_Date: - if (m != NO_MON || d != NO_DAY || y != NO_YR || jul != NO_DATE) Usage(); - jul = tok.val; + if (m != NO_MON || d != NO_DAY || y != NO_YR || dse != NO_DATE) Usage(); + dse = tok.val; break; case T_Month: - if (m != NO_MON || jul != NO_DATE) Usage(); + if (m != NO_MON || dse != NO_DATE) Usage(); else m = tok.val; break; case T_Day: - if (d != NO_DAY || jul != NO_DATE) Usage(); + if (d != NO_DAY || dse != NO_DATE) Usage(); else d = tok.val; break; case T_Year: - if (y != NO_YR || jul != NO_DATE) Usage(); + if (y != NO_YR || dse != NO_DATE) Usage(); else y = tok.val; break; @@ -681,8 +681,8 @@ void InitRemind(int argc, char const *argv[]) Daemon = 0; } - if (jul != NO_DATE) { - FromDSE(jul, &y, &m, &d); + if (dse != NO_DATE) { + FromDSE(dse, &y, &m, &d); } /* Must supply date in the form: day, mon, yr OR mon, yr */ if (m != NO_MON || y != NO_YR || d != NO_DAY) { diff --git a/src/langs/danish.h b/src/langs/danish.h index 3e3dcfc2..14ed8d40 100644 --- a/src/langs/danish.h +++ b/src/langs/danish.h @@ -80,10 +80,10 @@ #define L_AMPM_OVERRIDE(ampm, hour) ampm = (hour < 12) ? (hour<5) ? " om natten" : " om formiddagen" : (hour > 17) ? " om aftenen" : " om eftermiddagen"; #define L_ORDINAL_OVERRIDE plu = "."; -#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y); } +#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[dse%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[dse%7], d, MonthName[m], y); } #define L_E_OVER sprintf(s, "den %02d%c%02d%c%04d", d, DateSep, m+1, DateSep, y); #define L_F_OVER sprintf(s, "den %02d%c%02d%c%04d", m+1, DateSep, d, DateSep, y); -#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]); } +#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[dse%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[dse%7], d, MonthName[m]); } #define L_H_OVER sprintf(s, "den %02d%c%02d", d, DateSep, m+1); #define L_I_OVER sprintf(s, "den %02d%c%02d", m+1, DateSep, d); #define L_U_OVER L_A_OVER diff --git a/src/langs/finnish.h b/src/langs/finnish.h index f82995a8..397b78cb 100644 --- a/src/langs/finnish.h +++ b/src/langs/finnish.h @@ -103,19 +103,19 @@ default: plu = ":ntenä"; break; \ } \ } -#define L_A_OVER if (altmode == '*') { sprintf(s, "%s %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s%s %d. %s%s %d", DayName[jul%7], L_ON, d, MonthName[m], L_PARTIT, y); } -#define L_C_OVER if (altmode == '*') { sprintf(s, "%s", DayName[jul%7]); } else { sprintf(s, "%s%s", DayName[jul%7], L_ON); } +#define L_A_OVER if (altmode == '*') { sprintf(s, "%s %d. %s %d", DayName[dse%7], d, MonthName[m], y); } else { sprintf(s, "%s%s %d. %s%s %d", DayName[dse%7], L_ON, d, MonthName[m], L_PARTIT, y); } +#define L_C_OVER if (altmode == '*') { sprintf(s, "%s", DayName[dse%7]); } else { sprintf(s, "%s%s", DayName[dse%7], L_ON); } #define L_E_OVER sprintf(s, "%02d%c%02d%c%04d", d, DateSep, m+1, DateSep, y); #define L_F_OVER sprintf(s, "%02d%c%02d%c%04d", m+1, DateSep, d, DateSep, y); -#define L_G_OVER if (altmode == '*') { sprintf(s, "%s %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s%s %d. %s%s", DayName[jul%7], L_ON, d, MonthName[m], L_PARTIT); } +#define L_G_OVER if (altmode == '*') { sprintf(s, "%s %d. %s", DayName[dse%7], d, MonthName[m]); } else { sprintf(s, "%s%s %d. %s%s", DayName[dse%7], L_ON, d, MonthName[m], L_PARTIT); } #define L_H_OVER sprintf(s, "%02d%c%02d", d, DateSep, m+1); #define L_I_OVER sprintf(s, "%02d%c%02d", m+1, DateSep, d); -#define L_J_OVER if (altmode == '*') { sprintf(s, "%s %sn %d%s %d", DayName[jul%7], MonthName[m], d, plu, y); } else { sprintf(s, "%s%s %sn %d%s %d", DayName[jul%7], L_ON, MonthName[m], d, plu, y); } -#define L_K_OVER if (altmode == '*') { sprintf(s, "%s %sn %d%s", DayName[jul%7], MonthName[m], d, plu); } else { sprintf(s, "%s%s %sn %d%s", DayName[jul%7], L_ON, MonthName[m], d, plu); } +#define L_J_OVER if (altmode == '*') { sprintf(s, "%s %sn %d%s %d", DayName[dse%7], MonthName[m], d, plu, y); } else { sprintf(s, "%s%s %sn %d%s %d", DayName[dse%7], L_ON, MonthName[m], d, plu, y); } +#define L_K_OVER if (altmode == '*') { sprintf(s, "%s %sn %d%s", DayName[dse%7], MonthName[m], d, plu); } else { sprintf(s, "%s%s %sn %d%s", DayName[dse%7], L_ON, MonthName[m], d, plu); } #define L_L_OVER sprintf(s, "%04d%c%02d%c%02d", y, DateSep, m+1, DateSep, d); #define L_Q_OVER sprintf(s, "n"); -#define L_U_OVER if (altmode == '*') { sprintf(s, "%s %d%s %s %d", DayName[jul%7], d, plu, MonthName[m], y); } else { sprintf(s, "%s%s %d%s %s%s %d", DayName[jul%7], L_ON, d, plu, MonthName[m], L_PARTIT, y); } -#define L_V_OVER if (altmode == '*') { sprintf(s, "%s %d%s %s", DayName[jul%7], d, plu, MonthName[m]); } else { sprintf(s, "%s%s %d%s %s%s", DayName[jul%7], L_ON, d, plu, MonthName[m], L_PARTIT); } +#define L_U_OVER if (altmode == '*') { sprintf(s, "%s %d%s %s %d", DayName[dse%7], d, plu, MonthName[m], y); } else { sprintf(s, "%s%s %d%s %s%s %d", DayName[dse%7], L_ON, d, plu, MonthName[m], L_PARTIT, y); } +#define L_V_OVER if (altmode == '*') { sprintf(s, "%s %d%s %s", DayName[dse%7], d, plu, MonthName[m]); } else { sprintf(s, "%s%s %d%s %s%s", DayName[dse%7], L_ON, d, plu, MonthName[m], L_PARTIT); } #define L_1_OVER \ if (tdiff == 0) \ sprintf(s, "%s", L_NOW); \ diff --git a/src/langs/french.h b/src/langs/french.h index 82d6ce11..0b3505dd 100644 --- a/src/langs/french.h +++ b/src/langs/french.h @@ -106,9 +106,9 @@ else if (tdiff < 0) { \ sprintf(s, "dans %d heure%s et %d minute%s", hdiff, hplu, mdiff, mplu); \ } -#define L_J_OVER if (altmode == '*') { sprintf(s, "%s, %d%s %s, %d", DayName[jul%7], d, plu, MonthName[m], y); } else { sprintf(s, "%s %s, %d%s %s, %d", L_ON, DayName[jul%7], d, plu, MonthName[m], y); } +#define L_J_OVER if (altmode == '*') { sprintf(s, "%s, %d%s %s, %d", DayName[dse%7], d, plu, MonthName[m], y); } else { sprintf(s, "%s %s, %d%s %s, %d", L_ON, DayName[dse%7], d, plu, MonthName[m], y); } -#define L_K_OVER if (altmode == '*') { sprintf(s, "%s, %d%s %s", DayName[jul%7], d, plu, MonthName[m]); } else { sprintf(s, "%s %s, %d%s %s", L_ON, DayName[jul%7], d, plu, MonthName[m]); } +#define L_K_OVER if (altmode == '*') { sprintf(s, "%s, %d%s %s", DayName[dse%7], d, plu, MonthName[m]); } else { sprintf(s, "%s %s, %d%s %s", L_ON, DayName[dse%7], d, plu, MonthName[m]); } /* The next ones are used only when MK_GLOBALS is set */ #ifdef MK_GLOBALS diff --git a/src/langs/german.h b/src/langs/german.h index 380041f6..d84ee40c 100644 --- a/src/langs/german.h +++ b/src/langs/german.h @@ -81,7 +81,7 @@ See the file dosubst.c for more info. */ #define L_AMPM_OVERRIDE(ampm, hour) ampm = (hour < 12) ? (hour<5) ? " nachts" : " vormittags" : (hour > 17) ? " abends" : " nachmittags"; #define L_ORDINAL_OVERRIDE plu = "."; -#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y); } -#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]); } +#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[dse%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[dse%7], d, MonthName[m], y); } +#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[dse%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[dse%7], d, MonthName[m]); } #define L_U_OVER L_A_OVER #define L_V_OVER L_G_OVER diff --git a/src/langs/italian.h b/src/langs/italian.h index 9ab41871..e2e2f338 100644 --- a/src/langs/italian.h +++ b/src/langs/italian.h @@ -84,30 +84,30 @@ #define L_HPLU_OVER hplu = (hdiff == 1 ? "a" : "e"); #define L_MPLU_OVER mplu = (mdiff == 1 ? "o" : "i"); -#define L_A_OVER sprintf(s, "%s, %d %s %d", DayName[jul%7], d,\ +#define L_A_OVER sprintf(s, "%s, %d %s %d", DayName[dse%7], d,\ MonthName[m], y); -#define L_C_OVER sprintf(s, "%s", DayName[jul%7]); +#define L_C_OVER sprintf(s, "%s", DayName[dse%7]); #define L_E_OVER sprintf(s, "%02d%c%02d%c%04d", d, DateSep,\ m+1, DateSep, y); #define L_F_OVER sprintf(s, "%02d%c%02d%c%04d", m+1, DateSep, d, DateSep, y); -#define L_G_OVER sprintf(s, "%s, %d %s", DayName[jul%7], d, MonthName[m]); +#define L_G_OVER sprintf(s, "%s, %d %s", DayName[dse%7], d, MonthName[m]); #define L_H_OVER sprintf(s, "%02d%c%02d", d, DateSep, m+1); #define L_I_OVER sprintf(s, "%02d%c%02d", m+1, DateSep, d); -#define L_J_OVER sprintf(s, "%s, %d %s %d", DayName[jul%7], d, \ +#define L_J_OVER sprintf(s, "%s, %d %s %d", DayName[dse%7], d, \ MonthName[m], y); -#define L_K_OVER sprintf(s, "%s, %d %s", DayName[jul%7], d, \ +#define L_K_OVER sprintf(s, "%s, %d %s", DayName[dse%7], d, \ MonthName[m]); #define L_L_OVER sprintf(s, "%04d%c%02d%c%02d", y, DateSep, m+1, DateSep, d); -#define L_U_OVER sprintf(s, "%s, %d %s %d", DayName[jul%7], d, \ +#define L_U_OVER sprintf(s, "%s, %d %s %d", DayName[dse%7], d, \ MonthName[m], y); -#define L_V_OVER sprintf(s, "%s, %d %s", DayName[jul%7], d, \ +#define L_V_OVER sprintf(s, "%s, %d %s", DayName[dse%7], d, \ MonthName[m]); diff --git a/src/langs/norwgian.h b/src/langs/norwgian.h index 4f1fa7a6..5142071b 100644 --- a/src/langs/norwgian.h +++ b/src/langs/norwgian.h @@ -77,7 +77,7 @@ /* Define any overrides here, such as L_ORDINAL_OVERRIDE, L_A_OVER, etc. See the file dosubst.c for more info. */ #define L_ORDINAL_OVERRIDE plu = "."; -#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y); } -#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]); } +#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[dse%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[dse%7], d, MonthName[m], y); } +#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[dse%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[dse%7], d, MonthName[m]); } #define L_U_OVER L_A_OVER #define L_V_OVER L_G_OVER diff --git a/src/langs/polish.h b/src/langs/polish.h index 02c5ec1f..4974909f 100644 --- a/src/langs/polish.h +++ b/src/langs/polish.h @@ -95,8 +95,8 @@ ampm = (hour<12) ? \ : (hour<22) ? " wieczorem" \ : " w nocy"; #define L_ORDINAL_OVERRIDE plu = ""; -#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y); } -#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s %s, %d. %s", L_ON, DayName[jul%7], d, MonthName[m]); } +#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, %d. %s %d", DayName[dse%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, %d. %s %d", L_ON, DayName[dse%7], d, MonthName[m], y); } +#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, %d. %s", DayName[dse%7], d, MonthName[m]); } else { sprintf(s, "%s %s, %d. %s", L_ON, DayName[dse%7], d, MonthName[m]); } #define L_U_OVER L_A_OVER #define L_V_OVER L_G_OVER diff --git a/src/langs/portbr.h b/src/langs/portbr.h index 666056fa..464b2d75 100644 --- a/src/langs/portbr.h +++ b/src/langs/portbr.h @@ -88,26 +88,26 @@ #define _ON_WEEKDAY(x) ((x % 7) < 2) ? "no" : "na" #define L_A_OVER \ - sprintf(s, "%s %s, %d de %s de %d", _ON_WEEKDAY(jul), DayName[jul%7], d, MonthName[m], y); + sprintf(s, "%s %s, %d de %s de %d", _ON_WEEKDAY(dse), DayName[dse%7], d, MonthName[m], y); #define L_C_OVER \ - sprintf(s, "%s %s", _ON_WEEKDAY(jul), DayName[jul%7]); + sprintf(s, "%s %s", _ON_WEEKDAY(dse), DayName[dse%7]); #define L_G_OVER \ - sprintf(s, "%s %s, %d %s", _ON_WEEKDAY(jul), DayName[jul%7], d, MonthName[m]); + sprintf(s, "%s %s, %d %s", _ON_WEEKDAY(dse), DayName[dse%7], d, MonthName[m]); #define L_J_OVER \ - sprintf(s, "%s %s, %d de %s de %d", _ON_WEEKDAY(jul), DayName[jul%7], d, MonthName[m], y); + sprintf(s, "%s %s, %d de %s de %d", _ON_WEEKDAY(dse), DayName[dse%7], d, MonthName[m], y); #define L_K_OVER \ - sprintf(s, "%s %s, %d de %s", _ON_WEEKDAY(jul), DayName[jul%7], d, MonthName[m]); + sprintf(s, "%s %s, %d de %s", _ON_WEEKDAY(dse), DayName[dse%7], d, MonthName[m]); /* Portuguese does not use some suffixes, some some %u and %j are the same */ #define L_U_OVER \ - sprintf(s, "%s %s, %d de %s de %d", _ON_WEEKDAY(jul), DayName[jul%7], d, MonthName[m], y); + sprintf(s, "%s %s, %d de %s de %d", _ON_WEEKDAY(dse), DayName[dse%7], d, MonthName[m], y); #define L_V_OVER \ - sprintf(s, "%s %s, %d de %s", _ON_WEEKDAY(jul), DayName[jul%7], d, MonthName[m]); + sprintf(s, "%s %s, %d de %s", _ON_WEEKDAY(dse), DayName[dse%7], d, MonthName[m]); #define L_1_OVER \ { \ diff --git a/src/langs/romanian.h b/src/langs/romanian.h index 8861bf2f..c7bafbf0 100644 --- a/src/langs/romanian.h +++ b/src/langs/romanian.h @@ -84,14 +84,14 @@ #define L_AMPM_OVERRIDE(ampm, hour) ampm = (hour < 12) ? (hour<4) ? " noaptea" : " dimineaţa" : (hour > 17) ? " seara" : " după-amiaza"; #define L_ORDINAL_OVERRIDE plu = ""; -#define L_A_OVER sprintf(s, "%s, %d %s %d", DayName[jul%7], d, MonthName[m], y); -#define L_C_OVER sprintf(s, "%s", DayName[jul%7]); -#define L_G_OVER sprintf(s, "%s, %d %s", DayName[jul%7], d, MonthName[m]); -#define L_J_OVER sprintf(s, "%s, %s %d, %d", DayName[jul%7], MonthName[m], d, y); -#define L_K_OVER sprintf(s, "%s, %s %d", DayName[jul%7], MonthName[m], d); +#define L_A_OVER sprintf(s, "%s, %d %s %d", DayName[dse%7], d, MonthName[m], y); +#define L_C_OVER sprintf(s, "%s", DayName[dse%7]); +#define L_G_OVER sprintf(s, "%s, %d %s", DayName[dse%7], d, MonthName[m]); +#define L_J_OVER sprintf(s, "%s, %s %d, %d", DayName[dse%7], MonthName[m], d, y); +#define L_K_OVER sprintf(s, "%s, %s %d", DayName[dse%7], MonthName[m], d); #define L_S_OVER -#define L_U_OVER sprintf(s, "%s, %d %s %d", DayName[jul%7], d, MonthName[m], y); -#define L_V_OVER sprintf(s, "%s, %d %s", DayName[jul%7], d, MonthName[m]); +#define L_U_OVER sprintf(s, "%s, %d %s %d", DayName[dse%7], d, MonthName[m], y); +#define L_V_OVER sprintf(s, "%s, %d %s", DayName[dse%7], d, MonthName[m]); #define L_1_OVER \ if (tdiff == 0) \ sprintf(s, L_NOW); \ diff --git a/src/main.c b/src/main.c index 81727373..bfde918e 100644 --- a/src/main.c +++ b/src/main.c @@ -343,9 +343,9 @@ int DSE(int year, int month, int day) /* NULL for y, m or d if you're not interested in that value */ /* */ /***************************************************************/ -void FromDSE(int jul, int *y, int *m, int *d) +void FromDSE(int dse, int *y, int *m, int *d) { - int try_yr = (jul / 365) + BASE; + int try_yr = (dse / 365) + BASE; int try_mon = 0; int t; @@ -355,17 +355,17 @@ void FromDSE(int jul, int *y, int *m, int *d) int y100 = (y2 / 100) - (y1 / 100); /* Don't count multiples of 100... */ int y400 = (y2 / 400) - (y1 / 400); /* ... but do count multiples of 400 */ - int try_jul= 365 * (try_yr-BASE) + y4 - y100 + y400; + int try_dse= 365 * (try_yr-BASE) + y4 - y100 + y400; - while (try_jul > jul) { + while (try_dse > dse) { try_yr--; - try_jul -= DaysInYear(try_yr); + try_dse -= DaysInYear(try_yr); } - jul -= try_jul; + dse -= try_dse; t = DaysInMonth(try_mon, try_yr); - while (jul >= t) { - jul -= t; + while (dse >= t) { + dse -= t; try_mon++; t = DaysInMonth(try_mon, try_yr); } @@ -376,7 +376,7 @@ void FromDSE(int jul, int *y, int *m, int *d) *m = try_mon; } if (d) { - *d = jul + 1; + *d = dse + 1; } return; } @@ -859,7 +859,7 @@ int DoIfTrig(ParsePtr p) unsigned syndrome; Trigger trig; TimeTrig tim; - int jul; + int dse; if ((size_t) NumIfs >= IF_NEST) return E_NESTED_IF; @@ -867,7 +867,7 @@ int DoIfTrig(ParsePtr p) else { if ( (r=ParseRem(p, &trig, &tim, 1)) ) return r; if (trig.typ != NO_TYPE) return E_PARSE_ERR; - jul = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1); + dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1); if (r) { if (r != E_CANT_TRIG || !trig.maybe_uncomputable) { if (!Hush || r != E_RUN_DISABLED) { @@ -877,7 +877,7 @@ int DoIfTrig(ParsePtr p) syndrome = IF_FALSE | BEFORE_ELSE; } else { - if (ShouldTriggerReminder(&trig, &tim, jul, &err)) { + if (ShouldTriggerReminder(&trig, &tim, dse, &err)) { syndrome = IF_TRUE | BEFORE_ELSE; } else { syndrome = IF_FALSE | BEFORE_ELSE; @@ -1171,24 +1171,24 @@ static int FoldArray[2][7] = { {2024, 2008, 2020, 2004, 2016, 2000, 2012} }; -int CalcMinsFromUTC(int jul, int tim, int *mins, int *isdst) +int CalcMinsFromUTC(int dse, int tim, int *mins, int *isdst) { -/* Convert jul and tim to an Unix tm struct */ +/* Convert dse and tim to an Unix tm struct */ int yr, mon, day; int tdiff; struct tm local, utc, *temp; time_t loc_t, utc_t; int isdst_tmp; - FromDSE(jul, &yr, &mon, &day); + FromDSE(dse, &yr, &mon, &day); /* If the year is greater than 2037, some Unix machines have problems. Fold it back to a "similar" year and trust that the UTC calculations are still valid... */ if (FoldYear && yr>2037) { - jul = DSE(yr, 0, 1); - yr = FoldArray[IsLeapYear(yr)][jul%7]; + dse = DSE(yr, 0, 1); + yr = FoldArray[IsLeapYear(yr)][dse%7]; } local.tm_sec = 0; local.tm_min = tim % 60; diff --git a/src/omit.c b/src/omit.c index 007a5059..400ab663 100644 --- a/src/omit.c +++ b/src/omit.c @@ -187,7 +187,7 @@ int PopOmitContext(ParsePtr p) /* OK or an error code. */ /* */ /***************************************************************/ -int IsOmitted(int jul, int localomit, char const *omitfunc, int *omit) +int IsOmitted(int dse, int localomit, char const *omitfunc, int *omit) { int y, m, d; @@ -199,7 +199,7 @@ int IsOmitted(int jul, int localomit, char const *omitfunc, int *omit) int r; Value v; - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); sprintf(expr, "%s('%04d-%02d-%02d')", omitfunc, y, m+1, d); s = expr; @@ -214,24 +214,24 @@ int IsOmitted(int jul, int localomit, char const *omitfunc, int *omit) } /* Is it omitted because of local omits? */ - if (localomit & (1 << (jul % 7))) { + if (localomit & (1 << (dse % 7))) { *omit = 1; return OK; } /* Is it omitted because of global weekday omits? */ - if (WeekdayOmits & (1 << (jul % 7))) { + if (WeekdayOmits & (1 << (dse % 7))) { *omit = 1; return OK; } /* Is it omitted because of fully-specified omits? */ - if (BexistsIntArray(FullOmitArray, NumFullOmits, jul)) { + if (BexistsIntArray(FullOmitArray, NumFullOmits, dse)) { *omit = 1; return OK; } - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); if (BexistsIntArray(PartialOmitArray, NumPartialOmits, (m << 5) + d)) { *omit = 1; return OK; @@ -479,11 +479,11 @@ int DoOmit(ParsePtr p) } int -AddGlobalOmit(int jul) +AddGlobalOmit(int dse) { if (NumFullOmits == MAX_FULL_OMITS) return E_2MANY_FULL; - if (!BexistsIntArray(FullOmitArray, NumFullOmits, jul)) { - InsertIntoSortedArray(FullOmitArray, NumFullOmits, jul); + if (!BexistsIntArray(FullOmitArray, NumFullOmits, dse)) { + InsertIntoSortedArray(FullOmitArray, NumFullOmits, dse); NumFullOmits++; } return OK; diff --git a/src/protos.h b/src/protos.h index faa4a4eb..e8da5f8c 100644 --- a/src/protos.h +++ b/src/protos.h @@ -34,11 +34,11 @@ int DoRem (ParsePtr p); int DoFlush (ParsePtr p); void DoExit (ParsePtr p); int ParseRem (ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals); -int TriggerReminder (ParsePtr p, Trigger *t, TimeTrig *tim, int jul); -int ShouldTriggerReminder (Trigger *t, TimeTrig *tim, int jul, int *err); -int DoSubst (ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, int mode); -int DoSubstFromString (char const *source, DynamicBuffer *dbuf, int jul, int tim); -int ParseLiteralDate (char const **s, int *jul, int *tim); +int TriggerReminder (ParsePtr p, Trigger *t, TimeTrig *tim, int dse); +int ShouldTriggerReminder (Trigger *t, TimeTrig *tim, int dse, int *err); +int DoSubst (ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, int mode); +int DoSubstFromString (char const *source, DynamicBuffer *dbuf, int dse, int tim); +int ParseLiteralDate (char const **s, int *dse, int *tim); int ParseLiteralTime (char const **s, int *tim); int EvalExpr (char const **e, Value *v, ParsePtr p); int DoCoerce (char type, Value *v); @@ -50,13 +50,13 @@ int DoInclude (ParsePtr p, enum TokTypes tok); int DoIncludeCmd (ParsePtr p); int IncludeFile (char const *fname); int GetAccessDate (char const *file); -int SetAccessDate (char const *fname, int jul); +int SetAccessDate (char const *fname, int dse); int TopLevel (void); int CallFunc (BuiltinFunc *f, int nargs); void InitRemind (int argc, char const *argv[]); void Usage (void); int DSE (int year, int month, int day); -void FromDSE (int jul, int *y, int *m, int *d); +void FromDSE (int dse, int *y, int *m, int *d); int ParseChar (ParsePtr p, int *err, int peek); int ParseToken (ParsePtr p, DynamicBuffer *dbuf); int ParseIdentifier (ParsePtr p, DynamicBuffer *dbuf); @@ -86,7 +86,7 @@ int DoClear (ParsePtr p); int DestroyOmitContexts (void); int PushOmitContext (ParsePtr p); int PopOmitContext (ParsePtr p); -int IsOmitted (int jul, int localomit, char const *omitfunc, int *omit); +int IsOmitted (int dse, int localomit, char const *omitfunc, int *omit); int DoOmit (ParsePtr p); int QueueReminder (ParsePtr p, Trigger *trig, TimeTrig *tim, char const *sched); void HandleQueuedReminders (void); @@ -120,24 +120,24 @@ unsigned int HashVal (char const *str); int DateOK (int y, int m, int d); Operator *FindOperator (char const *name, Operator where[], int num); BuiltinFunc *FindFunc (char const *name, BuiltinFunc where[], int num); -int InsertIntoSortBuffer (int jul, int tim, char const *body, int typ, int prio); +int InsertIntoSortBuffer (int dse, int tim, char const *body, int typ, int prio); void IssueSortedReminders (void); int UserFuncExists (char const *fn); -void JulToHeb (int jul, int *hy, int *hm, int *hd); +void DSEToHeb (int dse, int *hy, int *hm, int *hd); int HebNameToNum (char const *mname); char const *HebMonthName (int m, int y); int RoshHashana (int i); long DaysToHebYear (int y); int DaysInHebYear (int y); char const *DaysInHebMonths (int ylen); -int HebToJul (int hy, int hm, int hd); +int HebToDSE (int hy, int hm, int hd); int GetValidHebDate (int yin, int min, int din, int adarbehave, int *mout, int *dout, int yahr); -int GetNextHebrewDate (int julstart, int hm, int hd, int yahr, int adarbehave, int *ans); +int GetNextHebrewDate (int dsestart, int hm, int hd, int yahr, int adarbehave, int *ans); int ComputeJahr (int y, int m, int d, int *ans); int GetSysVar (char const *name, Value *val); int SetSysVar (char const *name, Value *val); void DumpSysVarByName (char const *name); -int CalcMinsFromUTC (int jul, int tim, int *mins, int *isdst); +int CalcMinsFromUTC (int dse, int tim, int *mins, int *isdst); void FillParagraph (char const *s); void LocalToUTC (int locdate, int loctime, int *utcdate, int *utctime); void UTCToLocal (int utcdate, int utctime, int *locdate, int *loctime); @@ -161,12 +161,12 @@ char const *Colorize(int r, int g, int b, int bg, int clamp); void PrintJSONString(char const *s); void PrintJSONKeyPairInt(char const *name, int val); void PrintJSONKeyPairString(char const *name, char const *val); -void PrintJSONKeyPairDate(char const *name, int jul); +void PrintJSONKeyPairDate(char const *name, int dse); void PrintJSONKeyPairDateTime(char const *name, int dt); void PrintJSONKeyPairTime(char const *name, int t); void System(char const *cmd); int ShellEscape(char const *in, DynamicBuffer *out); -int AddGlobalOmit(int jul); +int AddGlobalOmit(int dse); void set_lat_and_long_from_components(void); void set_components_from_lat_and_long(void); diff --git a/src/sort.c b/src/sort.c index fa1d747b..a1179984 100644 --- a/src/sort.c +++ b/src/sort.c @@ -34,8 +34,8 @@ typedef struct sortrem { /* The sorted reminder queue */ static Sortrem *SortedQueue = (Sortrem *) NULL; -static Sortrem *MakeSortRem (int jul, int tim, char const *body, int typ, int prio); -static void IssueSortBanner (int jul); +static Sortrem *MakeSortRem (int dse, int tim, char const *body, int typ, int prio); +static void IssueSortBanner (int dse); /***************************************************************/ /* */ @@ -44,7 +44,7 @@ static void IssueSortBanner (int jul); /* Create a new Sortrem entry - return NULL on failure. */ /* */ /***************************************************************/ -static Sortrem *MakeSortRem(int jul, int tim, char const *body, int typ, int prio) +static Sortrem *MakeSortRem(int dse, int tim, char const *body, int typ, int prio) { Sortrem *new = NEW(Sortrem); if (!new) return NULL; @@ -55,7 +55,7 @@ static Sortrem *MakeSortRem(int jul, int tim, char const *body, int typ, int pri return NULL; } - new->trigdate = jul; + new->trigdate = dse; new->trigtime = tim; new->typ = typ; new->priority = prio; @@ -70,9 +70,9 @@ static Sortrem *MakeSortRem(int jul, int tim, char const *body, int typ, int pri /* Insert a reminder into the sort buffer */ /* */ /***************************************************************/ -int InsertIntoSortBuffer(int jul, int tim, char const *body, int typ, int prio) +int InsertIntoSortBuffer(int dse, int tim, char const *body, int typ, int prio) { - Sortrem *new = MakeSortRem(jul, tim, body, typ, prio); + Sortrem *new = MakeSortRem(dse, tim, body, typ, prio); Sortrem *cur = SortedQueue, *prev = NULL; int ShouldGoAfter; @@ -168,7 +168,7 @@ void IssueSortedReminders(void) /* defined to take one argument. */ /* */ /***************************************************************/ -static void IssueSortBanner(int jul) +static void IssueSortBanner(int dse) { char BanExpr[64]; int y, m, d; @@ -178,13 +178,13 @@ static void IssueSortBanner(int jul) if (UserFuncExists("sortbanner") != 1) return; - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); sprintf(BanExpr, "sortbanner('%04d/%02d/%02d')", y, m+1, d); y = EvalExpr(&s, &v, NULL); if (y) return; if (DoCoerce(STR_TYPE, &v)) return; DBufInit(&buf); - if (!DoSubstFromString(v.v.str, &buf, jul, NO_TIME)) { + if (!DoSubstFromString(v.v.str, &buf, dse, NO_TIME)) { if (*DBufValue(&buf)) printf("%s\n", DBufValue(&buf)); DBufFree(&buf); } diff --git a/src/token.c b/src/token.c index 604fa5e2..be6151e0 100644 --- a/src/token.c +++ b/src/token.c @@ -239,16 +239,16 @@ void FindNumericToken(char const *s, Token *t) /* If we hit a '-' or a '/', we may have a date or a datetime */ if (*s == '-' || *s == '/') { char const *p = s_orig; - int jul, tim; - if (ParseLiteralDate(&p, &jul, &tim) == OK) { + int dse, tim; + if (ParseLiteralDate(&p, &dse, &tim) == OK) { if (*p) return; if (tim == NO_TIME) { t->type = T_Date; - t->val = jul; + t->val = dse; return; } t->type = T_DateTime; - t->val = MINUTES_PER_DAY * jul + tim; + t->val = MINUTES_PER_DAY * dse + tim; } return; } diff --git a/src/trigger.c b/src/trigger.c index 8d0fb0c9..695b8341 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -26,8 +26,8 @@ #define ADVANCE_TO_WD(x, wd) while (! ((wd) & (1 << ((x)%7)))) (x)++ -static int JYear(int jul); -static int JMonth(int jul); +static int DSEYear(int dse); +static int DSEMonth(int dse); static int NextSimpleTrig(int startdate, Trigger *trig, int *err); static int GetNextTriggerDate(Trigger *trig, int start, int *err, int *nextstart); @@ -125,14 +125,14 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err) if (y < trig->y) j = DSE(trig->y, 0, 1); else j = startdate; ADVANCE_TO_WD(j, trig->wd); - if (JYear(j) > trig->y) return -1; + if (DSEYear(j) > trig->y) return -1; return j; case GOT_MON+GOT_WD: if (m == trig->m) { j = startdate; ADVANCE_TO_WD(j, trig->wd); - if (JMonth(j) == trig->m) return j; + if (DSEMonth(j) == trig->m) return j; } if (m >= trig->m) j = DSE(y+1, trig->m, 1); else j = DSE(y, trig->m, 1); @@ -185,7 +185,7 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err) while (trig->d > DaysInMonth(m2, trig->y)) m2--; j = DSE(trig->y, m2, trig->d); ADVANCE_TO_WD(j, trig->wd); - if (JYear(j) > trig->y) return -1; + if (DSEYear(j) > trig->y) return -1; if (j >= startdate) return j; } } @@ -193,7 +193,7 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err) if (trig->d <= DaysInMonth(m, trig->y)) { j = DSE(trig->y, m, trig->d); ADVANCE_TO_WD(j, trig->wd); - if (JYear(j) > trig->y) return -1; + if (DSEYear(j) > trig->y) return -1; if (j >= startdate) return j; } @@ -203,7 +203,7 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err) while (trig->d > DaysInMonth(m, trig->d)) m++; j = DSE(trig->y, m, trig->d); ADVANCE_TO_WD(j, trig->wd); - if (JYear(j) > trig->y) return -1; + if (DSEYear(j) > trig->y) return -1; return j; case GOT_DAY+GOT_MON+GOT_WD: @@ -269,25 +269,25 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err) /***************************************************************/ /* */ -/* JMonth - Given a DSE date, what's the month? */ +/* DSEMonth - Given a DSE date, what's the month? */ /* */ /***************************************************************/ -static int JMonth(int jul) +static int DSEMonth(int dse) { int y, m, d; - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); return m; } /***************************************************************/ /* */ -/* JYear - Given a DSE date, what's the year? */ +/* DSEYear - Given a DSE date, what's the year? */ /* */ /***************************************************************/ -static int JYear(int jul) +static int DSEYear(int dse) { int y, m, d; - FromDSE(jul, &y, &m, &d); + FromDSE(dse, &y, &m, &d); return y; }