andreasgal/j2me.js — pull request #599 by mykmelez (2014-11-14 21:17:50+00:00)
Title: start numbering file descriptors from 3

FCOutputStream hardcodes 1 and 2 as file descriptors for stdout and stderr, respectively; and it ignores calls to flush() for descriptors < 3; so we should start incrementing descriptors from 3.

But our descriptors are just indexes into an array, so we have to do that by making the array long enough.

Along the way, I made fstests.js store the descriptor for the file it uses for a bunch of its tests (instead of hardcoding it everywhere), so we won't have to touch as many lines of code the next time the descriptor changes.

We may want to change the way we increment and store descriptors in the future, but this is the minimal fix for the bug.