mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Be pickier about $WarningLevel. Make sure it matches the Perl regex: ^\d\d\.\d\d\.\d\d$
This commit is contained in:
@@ -3462,14 +3462,21 @@ at most 85 out of 255, and if the maximum of any component is at most
|
||||
As new versions of \fBRemind\fR are released, new warnings may be added.
|
||||
If your formerly-fine scripts suddenly start issuing warnings when you
|
||||
upgrade \fBRemind\fR, then as a \fIstopgap\fR measure, you may set
|
||||
\fB$WarningLevel\fR to a string of the form \fIAA.BB.CC\fR where
|
||||
\fIAA\fR, \fIBB\fR and \fICC\fR are decimal digits. This will
|
||||
\fB$WarningLevel\fR to a string of the form \fIAB\fR.\fICD\fR.\fIEF\fR where
|
||||
\fIAB\fR, \fICD\fR and \fIEF\fR are pairs of decimal digits. This will
|
||||
suppress any warnings that were introduced \fIafter\fR \fBRemind\fR
|
||||
version \fIAA.BB.CC\fR. If you do not set \fB$WarningLevel\fR, then
|
||||
version \fIAB\fR.\fICD\fR.\fIEF\fR. If you do not set \fB$WarningLevel\fR, then
|
||||
it defaults to the current version of \fBRemind\fR, meaning all warnings
|
||||
will be issued.
|
||||
.RS
|
||||
.PP
|
||||
For example, if you want the warnings you receive limited to what
|
||||
Remind 05.00.00 would have produced, use:
|
||||
.PP
|
||||
.nf
|
||||
SET $WarningLevel "05.00.00"
|
||||
.fi
|
||||
.PP
|
||||
We do \fInot\fR recommend setting \fB$WarningLevel\fR as a matter
|
||||
of course; you should use it to suppress warnings only for as long as
|
||||
it takes for you to fix your remind scripts so they no longer cause
|
||||
|
||||
24
src/var.c
24
src/var.c
@@ -193,7 +193,6 @@ static int latitude_func(int do_set, Value *val)
|
||||
|
||||
static int warning_level_func(int do_set, Value *val)
|
||||
{
|
||||
int a, b, c;
|
||||
if (do_set) {
|
||||
if (val->type != STR_TYPE) return E_BAD_TYPE;
|
||||
if (!val->v.str || ! (*val->v.str)) {
|
||||
@@ -201,12 +200,29 @@ static int warning_level_func(int do_set, Value *val)
|
||||
WarningLevel = NULL;
|
||||
return OK;
|
||||
}
|
||||
if (sscanf(val->v.str, "%d.%d.%d", &a, &b, &c) != 3) {
|
||||
if (strlen(val->v.str) != 8) {
|
||||
return E_BAD_NUMBER;
|
||||
}
|
||||
/* Must match regex: ^\d\d\.\d\d\.\d\d$ */
|
||||
if (!isdigit(val->v.str[0]) ||
|
||||
!isdigit(val->v.str[1]) ||
|
||||
val->v.str[2] != '.' ||
|
||||
!isdigit(val->v.str[3]) ||
|
||||
!isdigit(val->v.str[4]) ||
|
||||
val->v.str[5] != '.' ||
|
||||
!isdigit(val->v.str[6]) ||
|
||||
!isdigit(val->v.str[7])) {
|
||||
return E_BAD_NUMBER;
|
||||
}
|
||||
|
||||
if (WarningLevel) free((void *) WarningLevel);
|
||||
WarningLevel = StrDup(val->v.str);
|
||||
if (!WarningLevel) return E_NO_MEM;
|
||||
/* If it's the same as VERSION, just leave it as NULL */
|
||||
if (strcmp(val->v.str, VERSION)) {
|
||||
WarningLevel = StrDup(val->v.str);
|
||||
if (!WarningLevel) return E_NO_MEM;
|
||||
} else {
|
||||
WarningLevel = NULL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
if (!WarningLevel) {
|
||||
|
||||
@@ -843,8 +843,11 @@ EOF
|
||||
BANNER %
|
||||
SET $AddBlankLines 0
|
||||
REM Monday ADDOMIT MSG woohoo!
|
||||
set $WarningLevel "06.01.02"
|
||||
SET $WarningLevel "06.01.02"
|
||||
REM Tuesday ADDOMIT MSG Cabbage.
|
||||
SET $WarningLevel "cabbage"
|
||||
SET $WarningLevel today()
|
||||
SET $WarningLevel "3.1.4"
|
||||
EOF
|
||||
|
||||
cmp -s ../tests/test.out ../tests/test.cmp
|
||||
|
||||
@@ -39905,6 +39905,12 @@ BANNER %
|
||||
SET $AddBlankLines 0
|
||||
REM Monday ADDOMIT MSG woohoo!
|
||||
-stdin-(3): Warning: Consider using SCANFROM with recurring ADDOMIT
|
||||
set $WarningLevel "06.01.02"
|
||||
SET $WarningLevel "06.01.02"
|
||||
REM Tuesday ADDOMIT MSG Cabbage.
|
||||
SET $WarningLevel "cabbage"
|
||||
-stdin-(6): Ill-formed number
|
||||
SET $WarningLevel today()
|
||||
-stdin-(7): Type mismatch
|
||||
SET $WarningLevel "3.1.4"
|
||||
-stdin-(8): Ill-formed number
|
||||
|
||||
|
||||
Reference in New Issue
Block a user