mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Allow logical operators to accept any non-string operands.
Make wouldtrig() return a date.
This commit is contained in:
33
src/expr.c
33
src/expr.c
@@ -1125,15 +1125,16 @@ static int LogOR(void)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (v1.type == INT_TYPE && v2.type == INT_TYPE) {
|
||||
if (v1.v.val == 0) {
|
||||
v1.v.val = v2.v.val;
|
||||
}
|
||||
PushValStack(v1);
|
||||
return OK;
|
||||
if (v1.type != v2.type || v1.type == STR_TYPE || v2.type == STR_TYPE) {
|
||||
DestroyValue(v1); DestroyValue(v2);
|
||||
return E_BAD_TYPE;
|
||||
}
|
||||
DestroyValue(v1); DestroyValue(v2);
|
||||
return E_BAD_TYPE;
|
||||
|
||||
if (v1.v.val == 0) {
|
||||
v1.v.val = v2.v.val;
|
||||
}
|
||||
PushValStack(v1);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
@@ -1154,15 +1155,15 @@ static int LogAND(void)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (v1.type == INT_TYPE && v2.type == INT_TYPE) {
|
||||
if (v1.v.val != 0) {
|
||||
v1.v.val = v2.v.val;
|
||||
}
|
||||
PushValStack(v1);
|
||||
return OK;
|
||||
if (v1.type != v2.type || v1.type == STR_TYPE || v2.type == STR_TYPE) {
|
||||
DestroyValue(v1); DestroyValue(v2);
|
||||
return E_BAD_TYPE;
|
||||
}
|
||||
DestroyValue(v1); DestroyValue(v2);
|
||||
return E_BAD_TYPE;
|
||||
if (v1.v.val != 0) {
|
||||
v1.v.val = v2.v.val;
|
||||
}
|
||||
PushValStack(v1);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
@@ -3021,8 +3021,8 @@ FWouldTrig(func_info *info)
|
||||
int jul, scanfrom;
|
||||
int r;
|
||||
|
||||
RetVal.type = DATE_TYPE;
|
||||
if (Nargs == 0) {
|
||||
RetVal.type = DATE_TYPE;
|
||||
RETVAL = LastWouldTrig;
|
||||
return OK;
|
||||
}
|
||||
@@ -3035,7 +3035,6 @@ FWouldTrig(func_info *info)
|
||||
scanfrom = NO_DATE;
|
||||
}
|
||||
|
||||
RetVal.type = INT_TYPE;
|
||||
RETVAL = 0;
|
||||
|
||||
CreateParser(ARGSTR(0), &p);
|
||||
|
||||
@@ -3755,10 +3755,10 @@ psmoon(0) => ../tests/test.rem(731): psmoon() is deprecated; use SPECIAL MOON in
|
||||
# Wouldtrig
|
||||
IF wouldtrig("sun +1") || wouldtrig("thu +1")
|
||||
wouldtrig("sun +1") => ../tests/test.rem(734): Trig = Sunday, 17 February, 1991
|
||||
412
|
||||
1991-02-17
|
||||
wouldtrig("thu +1") => ../tests/test.rem(734): Trig = Thursday, 21 February, 1991
|
||||
0
|
||||
412 || 0 => 412
|
||||
1990-01-01
|
||||
1991-02-17 || 1990-01-01 => 1991-02-17
|
||||
REM [wouldtrig()] +1 MSG Foo %b
|
||||
wouldtrig() => 1991-02-17
|
||||
../tests/test.rem(735): Trig = Sunday, 17 February, 1991
|
||||
@@ -3775,14 +3775,14 @@ x => 1
|
||||
1 / 0 => Division by zero
|
||||
../tests/test.rem(740): `/': Division by zero
|
||||
Leaving UserFN w() => Division by zero
|
||||
0
|
||||
1990-01-01
|
||||
wouldtrig("thu warn w") => ../tests/test.rem(740): Trig = Thursday, 21 February, 1991
|
||||
Entering UserFN w(1)
|
||||
x => 1
|
||||
1 / 0 => Division by zero
|
||||
Leaving UserFN w() => Division by zero
|
||||
0
|
||||
0 || 0 => 0
|
||||
1990-01-01
|
||||
1990-01-01 || 1990-01-01 => 1990-01-01
|
||||
REM [wouldtrig()] +1 MSG Foo %b
|
||||
ENDIF
|
||||
|
||||
@@ -3805,14 +3805,14 @@ Entering UserFN w(3)
|
||||
x => 3
|
||||
choose(3, 5, 3, 1, 0) => 1
|
||||
Leaving UserFN w() => 1
|
||||
412
|
||||
1991-02-17
|
||||
wouldtrig("thu warn w") => ../tests/test.rem(749): Trig = Thursday, 21 February, 1991
|
||||
Entering UserFN w(1)
|
||||
x => 1
|
||||
choose(1, 5, 3, 1, 0) => 5
|
||||
Leaving UserFN w() => 5
|
||||
416
|
||||
412 || 416 => 412
|
||||
1991-02-21
|
||||
1991-02-17 || 1991-02-21 => 1991-02-17
|
||||
REM [wouldtrig()] +5 MSG Foo %b
|
||||
wouldtrig() => 1991-02-21
|
||||
../tests/test.rem(750): Trig = Thursday, 21 February, 1991
|
||||
|
||||
Reference in New Issue
Block a user