mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 06:48:47 +02:00
More work on purge mode.
This commit is contained in:
17
src/dorem.c
17
src/dorem.c
@@ -58,7 +58,10 @@ int DoRem(ParsePtr p)
|
||||
/* Parse the trigger date and time */
|
||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) return r;
|
||||
|
||||
if (trig.typ == NO_TYPE) return E_EOLN;
|
||||
if (trig.typ == NO_TYPE) {
|
||||
PurgeEchoLine("%s\n%s\n", "#!PURGE Cannot parse next line", CurLine);
|
||||
return E_EOLN;
|
||||
}
|
||||
if (trig.typ == SAT_TYPE) {
|
||||
PurgeEchoLine("%s\n", "#!PURGE Cannot purge SATISFY-type reminders");
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
@@ -94,14 +97,20 @@ int DoRem(ParsePtr p)
|
||||
} else {
|
||||
/* Calculate the trigger date */
|
||||
jul = ComputeTrigger(trig.scanfrom, &trig, &r, 1);
|
||||
if (r) return r;
|
||||
if (r) {
|
||||
if (PurgeMode) {
|
||||
PurgeEchoLine("%s: %s\n", "#!PURGE Problem calculating trigger date", ErrMsg[r]);
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
if (PurgeMode) {
|
||||
if (trig.expired) {
|
||||
if (trig.expired || jul < JulianToday) {
|
||||
if (p->expr_happened) {
|
||||
PurgeEchoLine("%s\n", "#!PURGE Next line may have expired, but contains expression");
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
} else {
|
||||
PurgeEchoLine("#!PURGE EXPIRED: %s\n", CurLine);
|
||||
}
|
||||
|
||||
60
src/files.c
60
src/files.c
@@ -102,6 +102,11 @@ static void OpenPurgeFile(char const *fname, char const *mode)
|
||||
{
|
||||
DynamicBuffer fname_buf;
|
||||
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
|
||||
/* Do not open a purge file if we're below purge
|
||||
include depth */
|
||||
if (IStackPtr-2 >= PurgeIncludeDepth) {
|
||||
@@ -195,12 +200,6 @@ static int ReadLineFromFile(void)
|
||||
}
|
||||
if (feof(fp)) {
|
||||
FCLOSE(fp);
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
}
|
||||
l = DBufLen(&buf);
|
||||
if (l && (DBufValue(&buf)[l-1] == '\\')) {
|
||||
@@ -244,6 +243,13 @@ int OpenFile(char const *fname)
|
||||
CachedFile *h = CachedFiles;
|
||||
int r;
|
||||
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
|
||||
/* Assume we own the file for now */
|
||||
RunDisabled &= ~RUN_NOTOWNER;
|
||||
|
||||
@@ -332,12 +338,6 @@ static int CacheFile(char const *fname)
|
||||
if (!cf) {
|
||||
ShouldCache = 0;
|
||||
FCLOSE(fp);
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
return E_NO_MEM;
|
||||
}
|
||||
cf->filename = StrDup(fname);
|
||||
@@ -345,12 +345,6 @@ static int CacheFile(char const *fname)
|
||||
ShouldCache = 0;
|
||||
FCLOSE(fp);
|
||||
free(cf);
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
return E_NO_MEM;
|
||||
}
|
||||
|
||||
@@ -367,12 +361,6 @@ static int CacheFile(char const *fname)
|
||||
DestroyCache(cf);
|
||||
ShouldCache = 0;
|
||||
FCLOSE(fp);
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
/* Skip blank chars */
|
||||
@@ -387,12 +375,6 @@ static int CacheFile(char const *fname)
|
||||
DestroyCache(cf);
|
||||
ShouldCache = 0;
|
||||
FCLOSE(fp);
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
return E_NO_MEM;
|
||||
}
|
||||
cl = cf->cache;
|
||||
@@ -402,12 +384,6 @@ static int CacheFile(char const *fname)
|
||||
DBufFree(&LineBuffer);
|
||||
DestroyCache(cf);
|
||||
ShouldCache = 0;
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
FCLOSE(fp);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
@@ -420,12 +396,6 @@ static int CacheFile(char const *fname)
|
||||
if (!cl->text) {
|
||||
DestroyCache(cf);
|
||||
ShouldCache = 0;
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
FCLOSE(fp);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
@@ -700,12 +670,6 @@ int IncludeFile(char const *fname)
|
||||
if (fp) {
|
||||
i->offset = ftell(fp);
|
||||
FCLOSE(fp);
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
IStackPtr++;
|
||||
|
||||
@@ -794,8 +794,10 @@ int DoIfTrig(ParsePtr p)
|
||||
syndrome = IF_TRUE | BEFORE_ELSE;
|
||||
} else {
|
||||
syndrome = IF_FALSE | BEFORE_ELSE;
|
||||
PurgeEchoLine("%s\n", "#!PURGE The next IFTRIG did not trigger.");
|
||||
PurgeEchoLine("%s\n", "#!PURGE REM statements in IFTRIG block not checked for purging.");
|
||||
if (PurgeMode) {
|
||||
PurgeEchoLine("%s\n", "#!PURGE The next IFTRIG did not trigger.");
|
||||
PurgeEchoLine("%s\n", "#!PURGE REM statements in IFTRIG block not checked for purging.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,10 @@ static int GetNextTriggerDate(Trigger *trig, int start, int *err, int *nextstart
|
||||
|
||||
/* First: Have we passed the UNTIL date? */
|
||||
if (trig->until != NO_UNTIL &&
|
||||
trig->until < start) return -1; /* expired */
|
||||
trig->until < start) {
|
||||
trig->expired = 1;
|
||||
return -1; /* expired */
|
||||
}
|
||||
|
||||
/* Next: If it's an "AFTER"-type skip, back up
|
||||
until we're at the start of a block of holidays */
|
||||
|
||||
7
tests/purge_dir/f1.rem
Normal file
7
tests/purge_dir/f1.rem
Normal file
@@ -0,0 +1,7 @@
|
||||
# This is f1.rem
|
||||
INCLUDE f2.rem
|
||||
INCLUDE f2.rem
|
||||
|
||||
REM 1 Oct 1991 MSG old1.
|
||||
|
||||
REM Monday UNTIL 1 Oct 1991 MSG old2.
|
||||
6
tests/purge_dir/f2.rem
Normal file
6
tests/purge_dir/f2.rem
Normal file
@@ -0,0 +1,6 @@
|
||||
# This is f2.rem
|
||||
|
||||
REM 3 feb 2012 MSG new
|
||||
REM 3 1998 MSG old
|
||||
|
||||
INCLUDE f3.rem
|
||||
18
tests/purge_dir/f3.rem
Normal file
18
tests/purge_dir/f3.rem
Normal file
@@ -0,0 +1,18 @@
|
||||
# This is f3.rem
|
||||
|
||||
REM Mon MSG repeat
|
||||
|
||||
REM Mon SATISFY [1] MSG repeat
|
||||
|
||||
IF 0
|
||||
REM 1991 MSG wookie
|
||||
ENDIF
|
||||
|
||||
IF 1
|
||||
REM 1991 MSG wookie
|
||||
ENDIF
|
||||
|
||||
IFTRIG 1991
|
||||
REM MSG wookie
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user