troff: fix SIGFPE when using modulus operator
I uncovered this problem while writing unit tests for GNU troff's delimited expression handling. Plan 9 troff's numeric expression evaluator handles division by zero but not modulus by zero. Fixes: $ echo '.if %0%0% .tm true' | 9 troff Floating point exception (core dumped) $ echo '.if 1%0 .tm true' | 9 troff Floating point exception (core dumped) After this patch: $ echo '.if %0%0% .tm true' | 9 troff x T utf x res 720 1 1 x init troff: modulus by zero.; stdin:1 troff: modulus by zero.; stdin:1 x trailer V0 x stop $ echo '.if 1%0 .tm true' | 9 troff x T utf x res 720 1 1 x init troff: modulus by zero.; stdin:1 x trailer V0 x stop
This commit is contained in:
committed by
Dan Cross
parent
37cd522b0a
commit
f39a2407b6
@@ -453,6 +453,11 @@ a0:
|
||||
i = ckph();
|
||||
if (nonumb)
|
||||
break;
|
||||
if (i == 0) {
|
||||
flusho();
|
||||
ERROR "modulus by zero." WARN;
|
||||
acc = 0;
|
||||
} else
|
||||
acc %= i;
|
||||
goto a0;
|
||||
case '&': /*and*/
|
||||
|
||||
Reference in New Issue
Block a user