Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Fix floating-point divide by zero issue in TH1 reported on the mailing list and add tests. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
479b3de1d201bf0b6880dc3b4dc82fe5 |
| User & Date: | mistachkin 2013-12-29 00:53:13.339 |
Context
|
2013-12-31
| ||
| 08:23 | Set g.isConst on /raw pages if the full UUID is given. ... (check-in: 43a2d0fa70 user: joel tags: trunk) | |
|
2013-12-30
| ||
| 20:57 | merge trunk ... (check-in: 02a0e8890e user: jan.nijtmans tags: win32-longpath) | |
| 19:07 | simplify setup code and fix comment ... (check-in: 9e5a9d1c71 user: jan.nijtmans tags: timeline-utc) | |
|
2013-12-29
| ||
| 00:53 | Fix floating-point divide by zero issue in TH1 reported on the mailing list and add tests. ... (check-in: 479b3de1d2 user: mistachkin tags: trunk) | |
|
2013-12-27
| ||
| 03:42 | Fix segfault on certain /annotate pages. (Discovered using many-www.tcl test script.) ... (check-in: 7a988eed37 user: joel tags: trunk) | |
Changes
Changes to src/th.c.
| ︙ | ︙ | |||
1874 1875 1876 1877 1878 1879 1880 |
}
if( rc==TH_OK && eArgType==ARG_INTEGER ){
int iRes = 0;
switch( pExpr->pOp->eOp ) {
case OP_MULTIPLY: iRes = iLeft*iRight; break;
case OP_DIVIDE:
| | | | 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 |
}
if( rc==TH_OK && eArgType==ARG_INTEGER ){
int iRes = 0;
switch( pExpr->pOp->eOp ) {
case OP_MULTIPLY: iRes = iLeft*iRight; break;
case OP_DIVIDE:
if( !iRight ){
Th_ErrorMessage(interp, "Divide by 0:", zLeft, nLeft);
return TH_ERROR;
}
iRes = iLeft/iRight;
break;
case OP_MODULUS:
if( !iRight ){
Th_ErrorMessage(interp, "Modulo by 0:", zLeft, nLeft);
return TH_ERROR;
}
iRes = iLeft%iRight;
break;
case OP_ADD: iRes = iLeft+iRight; break;
case OP_SUBTRACT: iRes = iLeft-iRight; break;
|
| ︙ | ︙ | |||
1911 1912 1913 1914 1915 1916 1917 |
case OP_LOGICAL_NOT: iRes = !iLeft; break;
default: assert(!"Internal error");
}
Th_SetResultInt(interp, iRes);
}else if( rc==TH_OK && eArgType==ARG_NUMBER ){
switch( pExpr->pOp->eOp ) {
case OP_MULTIPLY: Th_SetResultDouble(interp, fLeft*fRight); break;
| > > > > > | > | 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 |
case OP_LOGICAL_NOT: iRes = !iLeft; break;
default: assert(!"Internal error");
}
Th_SetResultInt(interp, iRes);
}else if( rc==TH_OK && eArgType==ARG_NUMBER ){
switch( pExpr->pOp->eOp ) {
case OP_MULTIPLY: Th_SetResultDouble(interp, fLeft*fRight); break;
case OP_DIVIDE:
if( fRight==0.0 ){
Th_ErrorMessage(interp, "Divide by 0:", zLeft, nLeft);
return TH_ERROR;
}
Th_SetResultDouble(interp, fLeft/fRight);
break;
case OP_ADD: Th_SetResultDouble(interp, fLeft+fRight); break;
case OP_SUBTRACT: Th_SetResultDouble(interp, fLeft-fRight); break;
case OP_LT: Th_SetResultInt(interp, fLeft<fRight); break;
case OP_GT: Th_SetResultInt(interp, fLeft>fRight); break;
case OP_LE: Th_SetResultInt(interp, fLeft<=fRight); break;
case OP_GE: Th_SetResultInt(interp, fLeft>=fRight); break;
case OP_EQ: Th_SetResultInt(interp, fLeft==fRight); break;
|
| ︙ | ︙ |
Changes to test/th1.test.
| ︙ | ︙ | |||
63 64 65 66 67 68 69 |
fossil test-th-eval --th-open-config "setting -- --"
test th1-setting-9 {$RESULT eq {}}
###############################################################################
fossil test-th-eval --th-open-config "setting -strict -- --"
test th1-setting-10 {$RESULT eq {TH_ERROR: no value for setting "--"}}
| > > > > > > > > > > > > > > > > > > > > | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
fossil test-th-eval --th-open-config "setting -- --"
test th1-setting-9 {$RESULT eq {}}
###############################################################################
fossil test-th-eval --th-open-config "setting -strict -- --"
test th1-setting-10 {$RESULT eq {TH_ERROR: no value for setting "--"}}
###############################################################################
fossil test-th-eval "expr 42/0"
test th1-divide-by-zero-1 {$RESULT eq {TH_ERROR: Divide by 0: 42}}
###############################################################################
fossil test-th-eval "expr 42/0.0"
test th1-divide-by-zero-2 {$RESULT eq {TH_ERROR: Divide by 0: 42}}
###############################################################################
fossil test-th-eval "expr 42.0/0"
test th1-divide-by-zero-3 {$RESULT eq {TH_ERROR: Divide by 0: 42.0}}
###############################################################################
fossil test-th-eval "expr 42.0/0.0"
test th1-divide-by-zero-4 {$RESULT eq {TH_ERROR: Divide by 0: 42.0}}
|