Fossil SCM
Fix using the unary bitwise NOT operator in TH1.
Commit
ee1aa460a40e91f502f9540053612c64c78128bb
Parent
cf52a9ab7bbff4f…
2 files changed
+1
+50
M
src/th.c
+1
| --- src/th.c | ||
| +++ src/th.c | ||
| @@ -1996,10 +1996,11 @@ | ||
| 1996 | 1996 | case OP_BITWISE_OR: iRes = iLeft|iRight; break; |
| 1997 | 1997 | case OP_LOGICAL_AND: iRes = iLeft&&iRight; break; |
| 1998 | 1998 | case OP_LOGICAL_OR: iRes = iLeft||iRight; break; |
| 1999 | 1999 | case OP_UNARY_MINUS: iRes = -iLeft; break; |
| 2000 | 2000 | case OP_UNARY_PLUS: iRes = +iLeft; break; |
| 2001 | + case OP_BITWISE_NOT: iRes = ~iLeft; break; | |
| 2001 | 2002 | case OP_LOGICAL_NOT: iRes = !iLeft; break; |
| 2002 | 2003 | default: assert(!"Internal error"); |
| 2003 | 2004 | } |
| 2004 | 2005 | Th_SetResultInt(interp, iRes); |
| 2005 | 2006 | }else if( rc==TH_OK && eArgType==ARG_NUMBER ){ |
| 2006 | 2007 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -1996,10 +1996,11 @@ | |
| 1996 | case OP_BITWISE_OR: iRes = iLeft|iRight; break; |
| 1997 | case OP_LOGICAL_AND: iRes = iLeft&&iRight; break; |
| 1998 | case OP_LOGICAL_OR: iRes = iLeft||iRight; break; |
| 1999 | case OP_UNARY_MINUS: iRes = -iLeft; break; |
| 2000 | case OP_UNARY_PLUS: iRes = +iLeft; break; |
| 2001 | case OP_LOGICAL_NOT: iRes = !iLeft; break; |
| 2002 | default: assert(!"Internal error"); |
| 2003 | } |
| 2004 | Th_SetResultInt(interp, iRes); |
| 2005 | }else if( rc==TH_OK && eArgType==ARG_NUMBER ){ |
| 2006 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -1996,10 +1996,11 @@ | |
| 1996 | case OP_BITWISE_OR: iRes = iLeft|iRight; break; |
| 1997 | case OP_LOGICAL_AND: iRes = iLeft&&iRight; break; |
| 1998 | case OP_LOGICAL_OR: iRes = iLeft||iRight; break; |
| 1999 | case OP_UNARY_MINUS: iRes = -iLeft; break; |
| 2000 | case OP_UNARY_PLUS: iRes = +iLeft; break; |
| 2001 | case OP_BITWISE_NOT: iRes = ~iLeft; break; |
| 2002 | case OP_LOGICAL_NOT: iRes = !iLeft; break; |
| 2003 | default: assert(!"Internal error"); |
| 2004 | } |
| 2005 | Th_SetResultInt(interp, iRes); |
| 2006 | }else if( rc==TH_OK && eArgType==ARG_NUMBER ){ |
| 2007 |
+50
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -362,5 +362,55 @@ | ||
| 362 | 362 | |
| 363 | 363 | ############################################################################### |
| 364 | 364 | |
| 365 | 365 | fossil test-th-eval "expr +2147483649.0" |
| 366 | 366 | test th1-expr-13 {$RESULT eq {2147483649.0}} |
| 367 | + | |
| 368 | +############################################################################### | |
| 369 | + | |
| 370 | +fossil test-th-eval "expr ~(-1)" | |
| 371 | +test th1-expr-14 {$RESULT eq {0}} | |
| 372 | + | |
| 373 | +############################################################################### | |
| 374 | + | |
| 375 | +fossil test-th-eval "expr ~-1" | |
| 376 | +test th1-expr-15 {$RESULT eq {0}} | |
| 377 | + | |
| 378 | +############################################################################### | |
| 379 | + | |
| 380 | +fossil test-th-eval "expr ~0" | |
| 381 | +test th1-expr-16 {$RESULT eq {-1}} | |
| 382 | + | |
| 383 | +############################################################################### | |
| 384 | + | |
| 385 | +fossil test-th-eval "expr ~+0" | |
| 386 | +test th1-expr-17 {$RESULT eq {-1}} | |
| 387 | + | |
| 388 | +############################################################################### | |
| 389 | + | |
| 390 | +fossil test-th-eval "expr ~-0" | |
| 391 | +test th1-expr-18 {$RESULT eq {-1}} | |
| 392 | + | |
| 393 | +############################################################################### | |
| 394 | + | |
| 395 | +fossil test-th-eval "expr ~(+0)" | |
| 396 | +test th1-expr-19 {$RESULT eq {-1}} | |
| 397 | + | |
| 398 | +############################################################################### | |
| 399 | + | |
| 400 | +fossil test-th-eval "expr ~(-0)" | |
| 401 | +test th1-expr-20 {$RESULT eq {-1}} | |
| 402 | + | |
| 403 | +############################################################################### | |
| 404 | + | |
| 405 | +fossil test-th-eval "expr ~1" | |
| 406 | +test th1-expr-21 {$RESULT eq {-2}} | |
| 407 | + | |
| 408 | +############################################################################### | |
| 409 | + | |
| 410 | +fossil test-th-eval "expr ~+1" | |
| 411 | +test th1-expr-22 {$RESULT eq {-2}} | |
| 412 | + | |
| 413 | +############################################################################### | |
| 414 | + | |
| 415 | +fossil test-th-eval "expr ~(+1)" | |
| 416 | +test th1-expr-23 {$RESULT eq {-2}} | |
| 367 | 417 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -362,5 +362,55 @@ | |
| 362 | |
| 363 | ############################################################################### |
| 364 | |
| 365 | fossil test-th-eval "expr +2147483649.0" |
| 366 | test th1-expr-13 {$RESULT eq {2147483649.0}} |
| 367 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -362,5 +362,55 @@ | |
| 362 | |
| 363 | ############################################################################### |
| 364 | |
| 365 | fossil test-th-eval "expr +2147483649.0" |
| 366 | test th1-expr-13 {$RESULT eq {2147483649.0}} |
| 367 | |
| 368 | ############################################################################### |
| 369 | |
| 370 | fossil test-th-eval "expr ~(-1)" |
| 371 | test th1-expr-14 {$RESULT eq {0}} |
| 372 | |
| 373 | ############################################################################### |
| 374 | |
| 375 | fossil test-th-eval "expr ~-1" |
| 376 | test th1-expr-15 {$RESULT eq {0}} |
| 377 | |
| 378 | ############################################################################### |
| 379 | |
| 380 | fossil test-th-eval "expr ~0" |
| 381 | test th1-expr-16 {$RESULT eq {-1}} |
| 382 | |
| 383 | ############################################################################### |
| 384 | |
| 385 | fossil test-th-eval "expr ~+0" |
| 386 | test th1-expr-17 {$RESULT eq {-1}} |
| 387 | |
| 388 | ############################################################################### |
| 389 | |
| 390 | fossil test-th-eval "expr ~-0" |
| 391 | test th1-expr-18 {$RESULT eq {-1}} |
| 392 | |
| 393 | ############################################################################### |
| 394 | |
| 395 | fossil test-th-eval "expr ~(+0)" |
| 396 | test th1-expr-19 {$RESULT eq {-1}} |
| 397 | |
| 398 | ############################################################################### |
| 399 | |
| 400 | fossil test-th-eval "expr ~(-0)" |
| 401 | test th1-expr-20 {$RESULT eq {-1}} |
| 402 | |
| 403 | ############################################################################### |
| 404 | |
| 405 | fossil test-th-eval "expr ~1" |
| 406 | test th1-expr-21 {$RESULT eq {-2}} |
| 407 | |
| 408 | ############################################################################### |
| 409 | |
| 410 | fossil test-th-eval "expr ~+1" |
| 411 | test th1-expr-22 {$RESULT eq {-2}} |
| 412 | |
| 413 | ############################################################################### |
| 414 | |
| 415 | fossil test-th-eval "expr ~(+1)" |
| 416 | test th1-expr-23 {$RESULT eq {-2}} |
| 417 |