mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Add purge mode.
This commit is contained in:
@@ -60,7 +60,7 @@ int DoRem(ParsePtr p)
|
||||
|
||||
if (trig.typ == NO_TYPE) return E_EOLN;
|
||||
if (trig.typ == SAT_TYPE) {
|
||||
PurgeEchoLine("%s\n", "### Cannot purge SATISFY-type reminders");
|
||||
PurgeEchoLine("%s\n", "#!PURGE Cannot purge SATISFY-type reminders");
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
r=DoSatRemind(&trig, &tim, p);
|
||||
if (r) return r;
|
||||
@@ -100,10 +100,10 @@ int DoRem(ParsePtr p)
|
||||
if (PurgeMode) {
|
||||
if (trig.expired) {
|
||||
if (p->expr_happened) {
|
||||
PurgeEchoLine("%s\n", "### Next line may have expired, but contains expression");
|
||||
PurgeEchoLine("%s\n", "#!PURGE Next line may have expired, but contains expression");
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
} else {
|
||||
PurgeEchoLine("### EXPIRED: %s\n", CurLine);
|
||||
PurgeEchoLine("#!PURGE EXPIRED: %s\n", CurLine);
|
||||
}
|
||||
} else {
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
|
||||
@@ -101,6 +101,14 @@ static int PopFile (void);
|
||||
static void OpenPurgeFile(char const *fname, char const *mode)
|
||||
{
|
||||
DynamicBuffer fname_buf;
|
||||
|
||||
/* Do not open a purge file if we're below purge
|
||||
include depth */
|
||||
if (IStackPtr-2 >= PurgeIncludeDepth) {
|
||||
PurgeFP = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
DBufInit(&fname_buf);
|
||||
if (DBufPuts(&fname_buf, fname) != OK) return;
|
||||
if (DBufPuts(&fname_buf, ".purged") != OK) return;
|
||||
|
||||
@@ -80,6 +80,7 @@ EXTERN INIT( int MaxStringLen, MAX_STR_LEN);
|
||||
EXTERN INIT( char *FileName, NULL);
|
||||
EXTERN INIT( int UseStdin, 0);
|
||||
EXTERN INIT( int PurgeMode, 0);
|
||||
EXTERN INIT( int PurgeIncludeDepth, 99999);
|
||||
EXTERN FILE *ErrFp;
|
||||
EXTERN INIT( FILE *PurgeFP, NULL);
|
||||
EXTERN INIT( int NumIfs, 0);
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
* -kcmd = Run 'cmd' for MSG-type reminders instead of printing to stdout
|
||||
* -iVAR=EXPR = Initialize and preserve VAR.
|
||||
* -m = Start calendar with Monday instead of Sunday.
|
||||
* -j = Purge all junk from reminder files
|
||||
* -j[n] = Purge all junk from reminder files (n = INCLUDE depth)
|
||||
* A minus sign alone indicates to take input from stdin
|
||||
*
|
||||
**************************************************************/
|
||||
@@ -200,6 +200,9 @@ void InitRemind(int argc, char const *argv[])
|
||||
case 'j':
|
||||
case 'J':
|
||||
PurgeMode = 1;
|
||||
if (*arg) {
|
||||
PARSENUM(PurgeIncludeDepth, arg);
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
case 'I':
|
||||
@@ -616,6 +619,7 @@ void Usage(void)
|
||||
fprintf(ErrFp, " -ivar=val Initialize var to val and preserve var\n");
|
||||
fprintf(ErrFp, " -m Start calendar with Monday rather than Sunday\n");
|
||||
fprintf(ErrFp, " -y Synthesize tags for tagless reminders\n");
|
||||
fprintf(ErrFp, " -j[n] Run in 'purge' mode. [n = INCLUDE depth]\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif /* L_USAGE_OVERRIDE */
|
||||
|
||||
14
src/main.c
14
src/main.c
@@ -265,7 +265,7 @@ static void DoReminders(void)
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
} else {
|
||||
if (r) {
|
||||
PurgeEchoLine("### Could not parse next line: %s\n", ErrMsg[r]);
|
||||
PurgeEchoLine("#!PURGE Could not parse next line: %s\n", ErrMsg[r]);
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
}
|
||||
}
|
||||
@@ -715,8 +715,8 @@ int DoIf(ParsePtr p)
|
||||
} else {
|
||||
syndrome = IF_FALSE | BEFORE_ELSE;
|
||||
if (PurgeMode) {
|
||||
PurgeEchoLine("%s\n", "### The next IF evaluated false...");
|
||||
PurgeEchoLine("%s\n", "### REM statements in IF block not checked for purging.");
|
||||
PurgeEchoLine("%s\n", "#!PURGE The next IF evaluated false...");
|
||||
PurgeEchoLine("%s\n", "#!PURGE REM statements in IF block not checked for purging.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -748,8 +748,8 @@ int DoElse(ParsePtr p)
|
||||
|
||||
IfFlags |= AFTER_ELSE << (2 * NumIfs - 2);
|
||||
if (PurgeMode && ShouldIgnoreLine() && !was_ignoring) {
|
||||
PurgeEchoLine("%s\n", "### The previous IF evaluated true.");
|
||||
PurgeEchoLine("%s\n", "### REM statements in ELSE block not checked for purging");
|
||||
PurgeEchoLine("%s\n", "#!PURGE The previous IF evaluated true.");
|
||||
PurgeEchoLine("%s\n", "#!PURGE REM statements in ELSE block not checked for purging");
|
||||
}
|
||||
return VerifyEoln(p);
|
||||
}
|
||||
@@ -794,8 +794,8 @@ int DoIfTrig(ParsePtr p)
|
||||
syndrome = IF_TRUE | BEFORE_ELSE;
|
||||
} else {
|
||||
syndrome = IF_FALSE | BEFORE_ELSE;
|
||||
PurgeEchoLine("%s\n", "### The next IFTRIG did not trigger.");
|
||||
PurgeEchoLine("%s\n", "### REM statements in IFTRIG block not checked for purging.");
|
||||
PurgeEchoLine("%s\n", "#!PURGE The next IFTRIG did not trigger.");
|
||||
PurgeEchoLine("%s\n", "#!PURGE REM statements in IFTRIG block not checked for purging.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user