catseye / FBBI

MIRROR of https://codeberg.org/catseye/FBBI : The Flaming Bovine Befunge-98 Interpreter.
https://catseye.tc/node/FBBI
Other
4 stars 1 forks source link

Input Decimal command fails on EOF and negative numbers #3

Open j4james opened 7 years ago

j4james commented 7 years ago

According to the specification:

In the case of an end-of-file or other file error condition, the & and ~ both act like r.

However, when it comes to the & (Input Decimal) command, FBBI goes into an infinite loop in the case of an end-of-file.

The problem is the loop at the start of the fi_idec function which tries to skip over any non-digits in the input stream. On end-of-file, a digit is never encountered so the loop never ends.

That loop is also responsible for FBBI failing to read negative numbers correctly, because the sign of the number is dropped before it gets to the scanf call.