Add the "-dq" debugging flag, for outputing TRANSLATE commands needed by a reminder script.
All checks were successful
Remind unit tests / tests (push) Successful in 44s

This commit is contained in:
Dianne Skoll
2025-01-17 08:46:29 -05:00
parent 6b31778973
commit 4f351c089e
6 changed files with 34 additions and 8 deletions

View File

@@ -318,6 +318,10 @@ tree. This is unlikely to be useful unless you are working on
.TP
.B h
Dump hash-table statistics on exit.
.TP
.B q
Output a TRANSLATE command each time the \fB_()\fR built-in function
is called or the \fB%(...)\fR substitution sequence is encountered.
.RE
.TP
\fB\-g\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR]]]]
@@ -5790,6 +5794,14 @@ you can update it by running:
.PP
and then editing \fBmylang-update.rem\fR to add in the missing translations.
.PP
If you have some reminder scripts that use the \fB_()\fR built-in function
or \fB%(...)\fR substitution sequence, you can generate a list of needed
TRANSLATE commands by running:
.PP
.nf
remind -q -n -dq myscript.rem 2>&1 | grep ^TRANSLATE | sort | uniq
.fi
.PP
Note that if you \fBSET\fR various translation-related system
variables such as \fB$Monday\fR, \fB$December\fR, \fB$Ago\fR, etc,
then \fBRemind\fR \fIalso\fR makes a corresponding translation

View File

@@ -240,6 +240,9 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
} else {
err = DBufPuts(dbuf, DBufValue(&orig));
}
if (DebugFlag & DB_TRANSLATE) {
TranslationTemplate(DBufValue(&orig));
}
DBufFree(&orig);
DBufFree(&translated);
if (err) return err;

View File

@@ -392,6 +392,9 @@ static int F_(func_info *info)
}
r = RetStrVal(DBufValue(&translated), info);
DBufFree(&translated);
if (DebugFlag & DB_TRANSLATE) {
TranslationTemplate(ARGSTR(0));
}
return r;
}

View File

@@ -642,6 +642,7 @@ void InitRemind(int argc, char const *argv[])
case 'v': case 'V': DebugFlag |= DB_DUMP_VARS; break;
case 'l': case 'L': DebugFlag |= DB_PRTLINE; break;
case 'f': case 'F': DebugFlag |= DB_TRACE_FILES; break;
case 'q': case 'Q': DebugFlag |= DB_TRANSLATE; break;
default:
fprintf(ErrFp, GetErr(M_BAD_DB_FLAG), *(arg-1));
fprintf(ErrFp, "\n");

View File

@@ -1268,6 +1268,12 @@ int DoDebug(ParsePtr p)
else DebugFlag &= ~DB_ECHO_LINE;
break;
case 'q':
case 'Q':
if (val) DebugFlag |= DB_TRANSLATE;
else DebugFlag &= ~DB_TRANSLATE;
break;
case 's':
case 'S':
if (val) DebugFlag |= DB_PARSE_EXPR;

View File

@@ -200,14 +200,15 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */
#define NO_MAX 127
/* DEFINES for debugging flags */
#define DB_PRTLINE 0x01
#define DB_PRTEXPR 0x02
#define DB_PRTTRIG 0x04
#define DB_DUMP_VARS 0x08
#define DB_ECHO_LINE 0x10
#define DB_TRACE_FILES 0x20
#define DB_PARSE_EXPR 0x40
#define DB_HASHSTATS 0x80
#define DB_PRTLINE 0x001
#define DB_PRTEXPR 0x002
#define DB_PRTTRIG 0x004
#define DB_DUMP_VARS 0x008
#define DB_ECHO_LINE 0x010
#define DB_TRACE_FILES 0x020
#define DB_PARSE_EXPR 0x040
#define DB_HASHSTATS 0x080
#define DB_TRANSLATE 0x100
/* Enumeration of the tokens */
enum TokTypes